Skip to content

FastAPI Mastery Path

Mastery Path
BOOTCAMP

FastAPI turns ordinary Python functions with type hints into a validated, documented HTTP API. Declare book_id: int and a request for /books/forty-two is answered with a precise 422 before your code runs; declare a response model and a password hash can't leak into the JSON; the OpenAPI document and the interactive /docs page come for free. That's why FastAPI is quick to start with. It's also why its failures are recognisable: an async def endpoint that calls a blocking library and freezes every request in the process, a list endpoint that loads a whole table, a commit that fails after the client was already told "saved", an API that checks who you are but not whether the record is yours. This course teaches you to build with FastAPI and to understand the machinery well enough to avoid those mistakes.

Level 1 follows one request from the ASGI server to your function and back — path and query parameters, Pydantic request bodies and response models, Pydantic v2 in depth, errors and exception handlers, forms and uploads, routers — and ends with a tested in-memory notes API. Level 2 adds real data: dependency injection, yield dependencies and their teardown timing, async def versus def measured under load, SQLAlchemy 2.x sync and async, N+1 queries, Alembic migrations, typed settings, isolated database tests and pagination, ending with a bookshelf API. Level 3 makes it multi-user and real-time: Argon2 password hashing, OAuth2 and JWT with rotating refresh tokens, scopes and object-level authorization, middleware and CORS, lifespan and background tasks, WebSockets and Server-Sent Events, OpenAPI and generated clients, async tests, caching, ETags and rate limits, ending with an authenticated bookmarks service. Level 4 is production: profiling and load testing, worker processes and graceful shutdown, reverse proxies, logs, metrics and FastAPI's built-in OpenTelemetry, OWASP API hardening, versioning, job queues, upgrades, and a capstone booking API that sells exactly the seats it has under concurrent load from four processes.

Every lesson has a How It Actually Works section — what FastAPI does with your function signature at import time, why validation errors list every problem at once, why a lazy-loaded relationship raises MissingGreenlet in async code, why allow_origins=["*"] with credentials reflects any origin, why an exception handler can't see a request ID stored in a context variable.

Run, not imagined

Code, commands, responses and error messages in this course come from real runs on FastAPI 0.143.0, Pydantic 2.14.0, Starlette 1.7.0, Uvicorn 0.54.0 and SQLAlchemy 2.1.4 with Python 3.14, mostly against SQLite. Several lessons show first attempts that failed — a test-database setup that broke three different ways, a migration that left a temporary table behind, a codemod whose output didn't import — because you'll meet those too. Each level page lists what was run and what wasn't (no Docker, nginx, PostgreSQL or Redis were available). Timings are one laptop's results, not benchmarks.

How the program is organized

Level Focus Modules
Level 1 · Entry ASGI and the request lifecycle, first app, path and query parameters, request bodies, response models, Pydantic v2, errors, forms and uploads, routers 9 topics + 1 project (an in-memory notes API)
Level 2 · Intermediate Dependency injection, yield dependencies, async vs sync, SQLAlchemy 2.x sync and async, Alembic, settings, testing, pagination 9 topics + 1 project (a bookshelf API with a database and tests)
Level 3 · Advanced Password hashing, OAuth2 and JWT, authorization, middleware and CORS, lifespan and background tasks, WebSockets and streaming, OpenAPI, async tests, caching and rate limits 9 topics + 1 project (a multi-user authenticated API)
Level 4 · Master Performance, deployment, reverse proxies, observability, security hardening, versioning, job queues, advanced patterns, upgrading 9 topics + 1 capstone (a production-ready event booking API)

How to use this site

  • Know your Python first. FastAPI relies on type hints, classes, decorators and async/await more than most frameworks. If Annotated[int, Query(ge=1)] or async def looks unfamiliar, start with Python Mastery Path.
  • Run every example. Each lesson's code is complete enough to paste into a file and run; the outputs shown are what it printed. If yours differ, check the versions — the lessons point out the places where versions matter.
  • Read the 422s and the SQL. Validation errors and the ORM's queries tell you most of what you need to know when something's wrong. Several lessons start by reading them.
  • Related courses. For API design beyond FastAPI, see REST API Mastery Path; for a batteries-included Python web framework, Django Mastery Path; for testing in depth, Python Testing Mastery Path; for SQL itself, SQL Mastery Path; for containers, Docker Mastery Path.
  • Do the Exercise at the end of each lesson; the module-10 projects build on them.

Start here → Level 1 · Entry

🎥 Prefer video? Watch the Mastery Path video series on YouTube — Shorts and full walkthroughs of lessons across the series.

More from the Mastery Path series

Free, structured, module-wise training across 78 other languages, platforms and disciplines: