This repository is a small, realistic FastAPI project built for teaching context engineering in Python codebases.
It is intentionally simple in domain (an in-memory "items" API) but structured like a real project, with routing, models, storage, tests, and quality gates.
Read the Context Engineering vs Prompt Engineering blog for a step by step explaination on working with AI agents in IDEs.
This repo is for students who:
- already know core Python
- are comfortable reading API code
- are using AI tools to understand, change, and maintain codebases
By working in this project, you can practice how to give AI assistants better context across:
- Domain context (what the app is supposed to do)
- Repo reality (how dependencies and tooling actually work here)
- Coding conventions (style, typing, FastAPI patterns)
- Project structure and architecture (where code lives and why)
- Quality gates (tests, linting, type checks)
- Constraints and context hygiene (what not to add, what to ignore)
The app manages Item objects in memory.
Each item has:
id: intname: strdescription: str | None
Endpoints:
GET /items/- list all itemsPOST /items/- create an itemGET /items/{item_id}- get one item by ID (returns404if missing)
app/
__init__.py
main.py
models.py
storage.py
routers/
__init__.py
items.py
tests/
test_items.py
pyproject.toml
uv.lock
AGENTS.md
- Python 3.11+
- uv for dependency and environment management
From the project root:
uv run python -V
uv run uvicorn app.main:app --reloadOpen:
- API docs: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
Note: / is not defined in this project, so visiting the root URL returns 404 by design.
Run these from the project root:
uv run pytest
uv run ruff check app tests
uv run mypy appExpected result: tests pass, lint is clean, and mypy reports no type errors.
This project deliberately avoids databases and ORMs so students can focus on:
- code reading and navigation
- architecture awareness
- safe, incremental edits with AI assistance
- test-driven verification loops
- Read endpoint behavior in
app/routers/items.py. - Trace model and storage usage through
app/models.pyandapp/storage.py. - Run tests before making changes.
- Make one small change.
- Re-run tests/lint/types.
- Reflect on what context the AI needed (or missed).
Unless an exercise says otherwise:
- keep storage in memory (
app/storage.py) - do not add database/ORM layers
- keep architecture small and explicit
- prefer clear type hints and readable FastAPI patterns