HOW FASTAPI
ACTUALLY WORKS
Modern Python web framework for building APIs. Conventions, patterns, and architecture extracted from the fastapi/fastapi repository by sourcebook.
WHAT_MATTERS
-
→
Uses FastAPI endpoints for routing — follow this pattern, don't add REST routes directly
KEY_FINDINGS
FastAPI project. Use Pydantic models for request/response schemas, not raw dicts.
HIGHUses SQLAlchemy/SQLModel for ORM. Database sessions must be properly closed (use dependency injection).
HIGHUses pytest. Test files should be named `test_*.py` or `*_test.py`.
HIGHTests live in a separate test/ directory, mirroring src/ structure. New tests go there, not next to source files.
HIGHAPI endpoints use FastAPI endpoints. Follow this pattern for new routes.
HIGH96 files use FastAPI endpoints
Use Pydantic BaseModel for data classes. This is the project's standard validation approach.
HIGH36 files use Pydantic
Tests use pytest.
HIGH32 test files
Route definitions live in: fastapi, fastapi/security, fastapi/openapi. Add new endpoints here.
HIGH3 route directories