Week 07: Production APIs — FastAPI, Docker & Cloud Deployment

Build: Full production AI API deployed to cloud with CI/CD
Overview
Topics
Weekly Build
Resources
Homework

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

DayTimeFocus
Saturday8:00 - 11:00 PM WATFastAPI & Docker
Sunday8:00 - 11:00 PM WATCloud 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 Middleware

LangServe for Agent Deployment

Wrapping LangChain in LangServe, playground UI, input/output schemas. Deploy your agent with a built-in testing interface.

LangServe Playground Schemas

Docker & docker-compose

Dockerfile best practices, multi-stage builds, compose for multi-service. Package your entire stack into reproducible containers.

Docker Compose Multi-stage

AWS / 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 Azure

Environment Management & Secrets

.env files, secrets managers, 12-factor app patterns. Keep your API keys safe and your deployments consistent across environments.

Secrets .env 12-Factor

Weekly 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

FilePurpose
api/main.pyFastAPI app
api/auth.pyAPI key middleware
api/rate_limit.pyToken bucket
DockerfileContainer definition
docker-compose.ymlMulti-service orchestration
deploy/cloudrun.yamlCloud 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.

  1. Deploy your API to the cloud — push your Docker container to a cloud provider and share the live URL
  2. Add API key authentication — implement middleware that validates keys against a database
  3. Implement rate limiting — token bucket algorithm with configurable limits per API key
  4. Write a Dockerfile with multi-stage build — optimize image size below 500MB