← All packs

FastAPI + Python 3.12

Pydantic v2 and SQLAlchemy 2.0 async only (no legacy APIs), router → service → repository layering, Alembic migrations, JWT auth, pytest + httpx.

Download free sample (2 files)Buy · $12

Included files

FileCoversRulesScope
00-core.mdcCore conventions for a Python 3.12 FastAPI service9Always on
10-routers-schemas.mdc in free sampleFastAPI routers, dependencies and Pydantic v2 schemas9Auto-attaches to src/app/**/router.py src/app/**/schemas.py src/app/**/deps.py
20-errors.mdcError handling and exception mapping6Auto-attaches to src/app/**/*.py
30-database.mdc in free sampleSQLAlchemy 2.0 async models, sessions, repositories and Alembic migrations8Auto-attaches to src/app/**/models.py src/app/**/repository.py src/app/core/db.py alembic/**/*.py
40-security.mdcAuthentication, authorization and secure coding8Auto-attaches to src/app/core/security.py src/app/**/deps.py src/app/auth/**/*.py src/app/main.py
50-testing.mdcTesting with pytest, httpx AsyncClient and a real Postgres8Auto-attaches to tests/**/*.py
60-naming-style.mdcPython naming and style6Auto-attaches to src/**/*.py tests/**/*.py
CLAUDE.mdClaude Code project instructions — sections: Commands, Architecture, Pydantic v2 / SQLAlchemy 2.0, Errors, Security, Testing, Style21Always on (Claude Code)
README.mdInstall steps for Cursor and Claude Code, customization notes––

Preview: 10-routers-schemas.mdc (from the free sample)

# Routers & schemas

- One `APIRouter(prefix="/<plural-resource>", tags=["<resource>"])` per feature; mounted in `main.py` under `/api/v1`.
- Endpoints are `async def`, thin: parse → call service → return schema. No SQL or business rules in routers.
- Always declare `response_model` (or return-type annotation) and explicit `status_code` (`201` create, `204` delete).
- Schema naming: `XCreate`, `XUpdate` (all fields optional, apply with `model_dump(exclude_unset=True)`), `XRead`.
- Pydantic v2 only: `model_config = ConfigDict(from_attributes=True, extra="forbid")` on input models; `model_validate`, `model_dump`, `field_validator`, `model_validator`. Never v1 APIs (`.dict()`, `.parse_obj`, `class Config`, `orm_mode`, `@validator`).
- Constrain inputs: `Annotated[str, StringConstraints(min_length=1, max_length=200)]`, `EmailStr`, `PositiveInt`.
- Never return ORM objects without a response schema; never accept ORM models as input.
- Pagination: `limit: int = Query(20, ge=1, le=100)`, `offset: int = Query(0, ge=0)`; return `Page[XRead]` with `items` and `total`.
- Dependencies (`get_current_user`, `SessionDep`) are `Annotated` aliases defined in `deps.py`.