Week 07: Production APIs — FastAPI, Docker & Cloud Deployment
What You'll Learn
Wrap your agent in a real API. Containerize it. Deploy it. You'll build a FastAPI service with authentication, rate limiting, and proper error handling, then containerize with Docker and deploy to AWS/GCP/Azure.
Session Schedule
| Day | Time | Focus |
|---|---|---|
| Saturday | 8:00 - 11:00 PM WAT | FastAPI & Docker |
| Sunday | 8:00 - 11:00 PM WAT | Cloud Deployment & CI/CD |
Pre-Requisites
- Weeks 01-06 completed
- Docker Desktop installed
- AWS/GCP account (free tier)
- Basic Git knowledge
Topics Covered
FastAPI with Async Endpoints
async/await, dependency injection, middleware, streaming responses. Build APIs that handle concurrent requests without breaking a sweat.
FastAPI Async MiddlewareLangServe for Agent Deployment
Wrapping LangChain in LangServe, playground UI, input/output schemas. Deploy your agent with a built-in testing interface.
LangServe Playground SchemasDocker & docker-compose
Dockerfile best practices, multi-stage builds, compose for multi-service. Package your entire stack into reproducible containers.
Docker Compose Multi-stageAWS / GCP / Azure Deployment
ECS/Cloud Run/Container Apps, load balancing, auto-scaling. Get your containerized agent running in the cloud with production-grade infrastructure.
AWS GCP AzureEnvironment Management & Secrets
.env files, secrets managers, 12-factor app patterns. Keep your API keys safe and your deployments consistent across environments.
Secrets .env 12-FactorWeekly Build: Production AI API
Build and deploy a complete FastAPI service wrapping your agent, with auth, rate limiting, Docker, and cloud deployment.
Architecture
Client Request (API key + query)
|
v
FastAPI Application
├── Auth Middleware (API key validation)
├── Rate Limiter (token bucket)
├── /chat endpoint (streaming)
├── /documents endpoint (upload → async)
└── /health endpoint
|
v
Docker Container → Cloud (ECS/Cloud Run)
├── PGVector (managed DB)
├── Redis (ElastiCache/Memorystore)
└── Monitoring (CloudWatch/Logging)
Key Files
| File | Purpose |
|---|---|
api/main.py | FastAPI app |
api/auth.py | API key middleware |
api/rate_limit.py | Token bucket |
Dockerfile | Container definition |
docker-compose.yml | Multi-service orchestration |
deploy/cloudrun.yaml | Cloud Run deployment config |
Resources
Required Reading
- FastAPI Official Documentation — Advanced User Guide
- Docker Best Practices for Python
- 12-Factor App Methodology
Code Repository
Clone the bootcamp repo and switch to the week-07 branch:
git clone https://github.com/softbricks-academy/agentic-ai-bootcamp.git cd agentic-ai-bootcamp git checkout week-07
Session Recording
Recording will be available within 24 hours after the live session. Check the WhatsApp group for the link.
Homework
Due before Week 8 live session.
- Deploy your API to the cloud — push your Docker container to a cloud provider and share the live URL
- Add API key authentication — implement middleware that validates keys against a database
- Implement rate limiting — token bucket algorithm with configurable limits per API key
- Write a Dockerfile with multi-stage build — optimize image size below 500MB