← ClaudeAtlas

fastapi-architectlisted

Framework-specific delta on rest-api-architect — FastAPI 0.136 on Python 3.14. Feature layout, Pydantic v2 request/response separation, async DI with lifespan, URL-prefix versioning, RFC 7807 errors, in-house OAuth2+JWT or external IdP. Read rest-api-architect first for the cross-cutting REST conventions. Use when scaffolding or reviewing a FastAPI service.
ralvarezdev/ralvaskills · ★ 2 · API & Backend · score 75
Install: claude install-skill ralvarezdev/ralvaskills
# FastAPI Architecture Targets **FastAPI 0.136** on **Python 3.14**. Companion to [python-architect](../../languages/python-architect/SKILL.md) and [sql-architect](../../databases/sql-architect/SKILL.md) (data access via `psycopg + .sql files`). Implementation skeletons in [RECIPES.md](RECIPES.md); pinned deps in [STACK.md](STACK.md). ## 1. Project structure — feature-based One folder per bounded context. Each feature owns its router, service, repo, schemas, and SQL files. Full tree in [RECIPES.md](RECIPES.md). - **`router.py`** depends on `service.py`; never reaches into `repo.py` directly. - **`service.py`** is pure Python — no FastAPI imports. Easy to unit-test. - **`schemas.py`** holds Pydantic models — never reused as ORM models or DB rows. ## 2. Routing & versioning - **URL-prefix versioning:** `/v1/users`, `/v1/orders`. Mount each version's routers under a `v1_router = APIRouter(prefix="/v1")`. Deprecate by mounting `/v2` alongside, never by mutating `/v1`. - **One `APIRouter` per feature**, included in `main.py`. - **Tags** match feature folder names (`tags=["users"]`) — drives OpenAPI grouping. - **Path parameter types in the signature** (`user_id: UUID`) — FastAPI validates and parses for free. - **Response model declared per route** (`response_model=UserResponse`) — sets the contract and trims extra fields automatically. - **Status codes explicit** (`status_code=status.HTTP_201_CREATED`). ## 3. Pydantic schemas — separate request and response Three shapes p