Skip to main content

Week 02 — Deployment & API Engineering

Goal: Take a Python function from your laptop to a live, observable, authenticated API on the internet — in one week.

By the end of Week 2 you will have built and deployed a production-grade FastAPI service with Google OAuth, Docker containers, Redis caching, Prometheus metrics, and Grafana dashboards. You will also run local LLMs on your own machine.


What You'll Build

code
Your laptop
└── FastAPI app (Python)
├── Google OAuth 2.0 (authentication)
├── Redis (caching + rate limiting)
├── Prometheus + OpenTelemetry (metrics & traces)
└── Docker container
└── Deployed → HuggingFace Spaces / Render / Railway
└── Grafana dashboard (live monitoring)

Topics This Week

#TopicWhat You'll Learn
01FastAPI FundamentalsBuild REST APIs with auto docs
02CORS & MiddlewareHandle cross-origin, rate limiting
03Google OAuth 2.0Secure endpoints with real auth
04FastAPI AdvancedWebSockets, background tasks, DI
05Config Management.env, secrets, 12-factor app
06Docker & ComposeContainerize everything
07Deployment PlatformsHuggingFace, Render, Railway
08Logging & Testingstructlog, pytest, coverage
09ObservabilityPrometheus, OpenTelemetry, Grafana
10CloudFlare TunnelsExpose localhost to the internet
11Local LLMsRun Ollama & LM Studio locally
12Redis CachingCache responses, manage sessions

Labs This Week

LabTitleSkills
Lab 2.1Gemma API on HuggingFace Spaces + Google AuthFastAPI · HuggingFace · OAuth
Lab 2.2FastAPI Observability + Grafana DashboardPrometheus · OpenTelemetry · Grafana

Prerequisites

  • Completed Week 1 (UV, Git, basic Python)
  • Python 3.11+ installed via UV
  • Docker Desktop installed
  • A Google account (for OAuth)
  • A HuggingFace account (free)

Mental Model for This Week

Think of it in three layers:

code
┌─────────────────────────────────────┐
│ Layer 3: OBSERVABILITY │ ← Know what's happening
│ Prometheus · Grafana · Loki │
├─────────────────────────────────────┤
│ Layer 2: RUNTIME │ ← Keep it running
│ Docker · Redis · CloudFlare │
├─────────────────────────────────────┤
│ Layer 1: APPLICATION │ ← Make it work
│ FastAPI · OAuth · Config │
└─────────────────────────────────────┘

Build bottom-up. Get the app working first, then containerize, then observe.


Week 2 in one sentence

FastAPI + Docker + Prometheus = production-ready API. Everything else this week supports these three pillars.