Build production APIs with Python & FastAPI
A hands-on backend path — modern Python, FastAPI's dependency injection system, REST APIs, SQLAlchemy, authentication, testing and async concurrency — then into the territory that separates "I built a CRUD API" from "I can run this in production": gRPC, distributed sagas, GraphQL, data pipelines, and profiling the GIL. It ends with a two-week capstone service you architect, secure, test and deploy yourself.
Prerequisites & tooling
What you should already know
- Basic programming in any language — variables, functions, loops
- Comfortable with the command line and Git
- No prior Python or web framework experience required
- Python 3.12 and a code editor like VS Code installed
Stack you'll work with
The same tools teams use to ship real Python services in production.
Your 26-week learning path
Twenty-two modules, from your first typed function through gRPC, sagas, GraphQL and data pipelines, to a two-week capstone service you deploy in a container.
Python Foundations & Environment Setup
Refresh modern Python and get your backend toolchain running.
- Type hints, dataclasses & the
matchstatement - Python 3.12, virtual environments & Poetry
- Running your first FastAPI application
FastAPI Core & Dependency Injection
Understand the system that powers every FastAPI application.
- Path operations, path/query params & Pydantic models
Depends()& the dependency injection system- Auto-generated docs with Swagger UI & ReDoc
Building REST APIs
Design and build clean, well-validated HTTP APIs.
APIRouter, request/response models & status codes- Validation with Pydantic & custom validators
- Centralized error handling with exception handlers
Data Persistence with SQLAlchemy
Model your domain and talk to a real relational database.
- Models, sessions & the SQLAlchemy 2.0 query API
- Relationships, lazy loading & transactions
- Schema migrations with Alembic
Authentication & Security
Lock down your API with modern, stateless authentication.
- Password hashing with
passlib& OAuth2 password flow - JWT-based authentication & refresh tokens
- Scoped permissions via dependency-based authorization
Testing FastAPI Applications
Build a layered test suite you can trust before every deploy.
- Unit testing with pytest & fixtures
TestClient& dependency overrides- Real-database integration tests with Testcontainers
Microservices & Messaging
Move from a single service to a small distributed system.
- Service-to-service calls with
httpx - Event-driven messaging with Celery & RabbitMQ
- Resilience patterns: retries, timeouts & circuit breakers
Caching & Performance
Keep a growing service fast under real load.
- Caching with Redis & cache invalidation strategies
- Connection pooling & query performance
- Background tasks with
BackgroundTasks
Observability & Production Readiness
Understand what your service is doing once it's live.
- Structured logging & health-check endpoints
- Metrics with
prometheus-client - Distributed tracing basics
Containerization & Deployment
Package and ship your service the way production teams do.
- Multi-stage Docker images for a Python service
- CI/CD pipelines for a FastAPI service
- Deploying with Gunicorn + Uvicorn workers
Async Python & Concurrency
A deep dive into the async model FastAPI is built on.
asyncio: the event loop, coroutines & tasks- Async database drivers & when
async defactually helps - When to reach for threads, processes, or Celery instead
Advanced SQLAlchemy — Complex Queries, N+1 & Migrations at Scale
Move past basic queries into the patterns real production repositories need.
- Dynamic queries with the 2.0
select()API selectinload/joinedload& solving N+1 for real- Bulk operations & zero-downtime Alembic migrations
API Design at Scale — Versioning, Pagination & OpenAPI
Design an API surface that can evolve without breaking every client.
- API versioning strategies & deprecation headers
- Cursor-based pagination, filtering & sorting conventions
- Customizing FastAPI's OpenAPI docs & per-client rate limiting
gRPC & Protocol Buffers for Service-to-Service Calls
A faster, strongly-typed alternative to REST for internal service communication.
- Defining a service contract with Protocol Buffers
- Generating & implementing a Python gRPC server and client
- Streaming RPCs & when gRPC beats REST between your own services
Distributed Transactions & the Saga Pattern
Keep data consistent across services without a distributed database transaction.
- Why two-phase commit doesn't fit microservices
- Choreography-based sagas with Celery & compensating actions
- The transactional outbox pattern for reliable event publishing
Advanced Auth — OAuth2 Provider, API Keys & Multi-Tenancy
Go from consuming OAuth2 to issuing your own tokens, and isolating tenants correctly.
- Building your own OAuth2 authorization server with
authlib - API keys & service-to-service client-credentials auth
- Multi-tenant data isolation strategies
Data Pipelines & Batch Processing with Airflow
Process large volumes of data reliably, on a schedule, outside the request/response cycle.
- DAGs, tasks & the Airflow scheduler model
- Building a real Extract-Transform-Load pipeline
- Retries, backfills & monitoring a production DAG
GraphQL with Strawberry
Give clients a query language instead of a fixed set of REST shapes.
- Code-first schema design with Strawberry & type hints
- Query & mutation resolvers over your existing SQLAlchemy models
- Solving GraphQL's own N+1 problem with
DataLoader
Contract Testing & Advanced Test Strategy
Test the boundary between services, not just the code inside one.
- Consumer-driven contract testing with Pact
- Mutation testing with
mutmutto check what your tests actually catch - Testing resilience under deliberate fault injection
Python Performance — Profiling, the GIL & Free-Threaded Python
Understand what CPython is actually doing when your service gets slow.
- Profiling with
cProfile&py-spyagainst a live process - What the GIL actually serializes, and what it doesn't
- Free-threaded Python 3.13 & when it's worth the risk
CI/CD & Progressive Delivery for FastAPI
Take deployment from "push and hope" to a pipeline with a real safety net.
- Multi-stage pipelines: test, build, scan, deploy
- Blue-green & canary deploys for a FastAPI service
- Feature flags for decoupling deploy from release
Capstone: Ship a Production FastAPI Service
Apply every module in one project — built, tested, secured and deployed by you.
- Fully tested, secured, containerized service
- A real CI/CD pipeline with a progressive rollout
- Portfolio-ready project you can show employers