fastapi-patterns
FastAPI best practices covering project structure, Pydantic v2 schemas, dependency injection, async handlers, authentication, authorization, transactional service layers, and testing with httpx and pytest. Use when building or reviewing FastAPI apps — Pydantic schemas, dependencies, async handlers, auth, or tests.
- Kind
- Skill
- Works with
- Claude Code, Codex
- Languages
- Python
- Source
- affaan-m/ECC @ d3b8a3e90890
- Path
- skills/fastapi-patterns/SKILL.md
- Jobs
- Testing, Review
- Topics
- Unit tests & TDD, Auth & identity, Backend frameworks
Credit
- Made by
- affaan-m
- Original
- github.com/affaan-m/ECC/blob/d3b8a3e908904e242ed2dbe66af62cca…
- License
- MIT
Listed by Skill Manifest; not made by us.
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
- Adds
- .claude/skills/fastapi-patterns/ (the skill folder)
- Runs scripts
- None found
- Uses the network
- Yes
- HTTP client calls
- Needs secrets
- None found
- Calls other skills
- /users
- /token
- Source revision
- d3b8a3e90890
- Licence
- MIT
- Last activity
- 23 Nov 2026
- Source changed after the scan
- Yes
- Last push 23 Nov 2026, scanned 3 Nov 2026; read it again before you rely on this scan
- Review
- Reviewed
Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.
# FastAPI Patterns Modern, production-grade FastAPI development: project layout, Pydantic v2 schemas, dependency injection, async patterns, auth, transactional service methods, and testing. ## Project Structure ```text my_app/ |-- app/ | |-- main.py # App factory, lifespan, middleware | |-- config.py # Settings via pydantic-settings | |-- dependencies.py # Shared FastAPI dependencies | |-- database.py # SQLAlchemy engine + session | |-- routers/ | | `-- users.py | |-- models/ # SQLAlchemy ORM models | | `-- user.py | |-- schemas/ # Pydantic request/response schemas | | `-- user.py | `-- services/ # Business logic layer | `-- user_service.py |-- tests/ | |-- conftest.py | `-- test_users.py |-- pyproject.toml `-- .env ``` --- ## App Factory and Lifespan ```python # app/main.py from contextlib import asynccontextmanager from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.config import settings from app.database import engine, Base from app.routers import users @asynccontextmanager async def lifespan(app: FastAPI): …