@tank/fastapi-mastery

Installation
SKILL.md

FastAPI Mastery

Core Philosophy

  1. Type hints are the contract -- FastAPI derives validation, serialization, and OpenAPI docs from type annotations. Invest in precise types and Pydantic models; everything downstream improves.
  2. Dependencies replace globals -- Use Depends() for database sessions, settings, auth, and shared logic. Dependencies are composable, testable, and self-documenting.
  3. Async by default, sync when blocking -- Use async def for I/O-bound routes (database, HTTP calls). Use def for CPU-bound work so FastAPI runs it in a thread pool automatically.
  4. Thin routes, fat services -- Route functions validate input and return output. Business logic belongs in service classes injected via dependencies.
  5. Test through the API -- Use TestClient with dependency overrides. Test behavior, not implementation. Override only what varies between environments.

Quick-Start: Common Problems

"How should I structure my FastAPI project?"

Project Size Structure
Small (< 10 routes) Single main.py with inline routes
Medium (10-50 routes) Feature-based: app/{feature}/router.py, service.py, models.py
Large (50+ routes) Layered: routers -> services -> repositories + shared core/
Installs
–
GitHub Stars
1
First Seen
–
@tank/fastapi-mastery — tankpkg/packages