How codingbsilva/fastapi-production-template works
This repository is a production-oriented FastAPI service template. Its demonstrated request workflow enters the FastAPI app, which serves an item-creation endpoint and operational probes; Prometheus instrumentation exposes metrics. The tree also contains a separate API router and reusable core modules for health checks, settings, error responses, middleware, and logging. The excerpts do not show those modules being registered with the app, so they are shown as separate components rather than wired into the request path. Gunicorn/Uvicorn process orchestration is documented in the README.
Main entry points: main.py FastAPI app · health_router.py Health probes · gunicorn.conf.py Gunicorn supervisor · schemas.py Health and error schemas
Components 15
Application API
- FastAPI app
app/main.py - Item endpoint
app/main.py - Items router
app/api/router.py - Item schemas
app/api/schemas.py - Metrics endpoint
app/main.py
Core Operations
- Health probes
app/core/health_router.py - Environment settings
app/core/config.py - Health and error schemas
app/core/schemas.py - Exception mapping
app/core/exceptions.py - Request middleware
app/core/middleware.py - Structured logging
app/core/logging.py
Runtime Serving
- Gunicorn supervisor
gunicorn.conf.py - Uvicorn workers
- Container runtime
Dockerfile
Other components
- API client
Connections 9
- API client → FastAPI app: sends requests
README.md - FastAPI app → Item endpoint: routes items
app/main.py - FastAPI app → Metrics endpoint: exposes metrics
app/main.py - Items router → Item schemas: uses models
app/api/router.py - Health probes → Environment settings: reads settings
app/core/health_router.py - Health probes → Health and error schemas: returns health model
app/core/health_router.py - Exception mapping → Health and error schemas: builds error response
app/core/exceptions.py - Container runtime → Gunicorn supervisor: runs server
README.md - Gunicorn supervisor → Uvicorn workers: manages workers
README.md