Course map
Stage 1: Foundations
Stage 2: Data Integration
Stage 3: Building & Shipping
Stage 4: Customer Engagement
Stage 5: Specialization

Project

Stage 3 project: Acme Dispatch Service

Start after Part 12

Stage 3

Everything from Stage 3 in one service: the authenticated API over the pipeline's data, validated configuration, health and readiness, observability, a circuit breaker around Acme's fragile API, and the security pass.

Time: ~3–4 hours if you build it yourself (recommended). Run the reference version: PYTHONPATH=tools .venv/bin/python stage-3-building-and-shipping/project-dispatch-service/dispatch_service.py

Core (build this)

  1. The Shipments API (Part 9): read + status-update endpoints, API-key auth (constant-time), 404/422 contract, /healthz and /readyz, TestClient contract tests.
  2. Validated Settings at startup (Part 10): environment, API key — refuse to start on bad config.

Stretch

  1. Observability (Part 11): JSON logs, latency percentiles per endpoint, a circuit breaker around the Acme API — an Acme outage degrades the service (cached data, degraded in readyz) instead of crashing it.
  2. The security pass (Part 12): secret masking on the log handler, PII redaction, an audit record for every write.

Production level

  1. Containerise it (Dockerfile, non-root), deploy to staging with secrets injected from a manager, per-environment config rules in CI, and two symptom alerts (error rate, p95) with runbook links.

What "done" looks like

  • The four contract asserts pass: 200 / 401 / 404 / 422.
  • With Acme's API hard-down, the service still answers from cached data and readyz reports degraded, not dead.
  • No token or personal data appears in any log line.
  • "Who changed S-2001?" is answerable from the audit log.

The reference implementation is dispatch_service.py; its output below came from a real run (Acme's API simulated as hard-down to exercise the breaker).

contract: 200 401 404 422
{"level": "WARNING", "msg": "acme refresh failed", "status": 429, "failures": 1}
{"level": "WARNING", "msg": "acme refresh failed", "status": 429, "failures": 2}
{"level": "WARNING", "msg": "acme refresh failed", "status": 429, "failures": 3}
{"level": "ERROR", "msg": "circuit open: serving cached data", "cached_rows": 8}
readyz while degraded: {'ready': True, 'degraded': ['acme_api']}
{"level": "INFO", "msg": "latency report", "p50_ms": 43, "p95_ms": 63, "requests": 9}
audit: [{"when": "2026-11-29T18:10:10+00:00", "actor": "ravi@acme", "action": "shipment.status.update", "object": "S-2001", "from": "in_transit", "to": "delayed"}]

Search the guide