Dockerized FastAPI, SQLAlchemy 2 and PostgreSQL app template with DI.
- tests on
pytestwith automatic rollback after each test case - IOC (Inversion of Control) container built on modern-di
- Observability tools integration built on lite-bootstrap
- Linting and formatting with
ruff, type checking withty Alembicfor DB migrations
Authentication is intentionally omitted: pick the scheme that fits your project and add it as a FastAPI dependency.
just --listSetting OPENTELEMETRY_ENDPOINT turns tracing on, and by default every request is traced. In a benchmark of GET /api/decks/{id}/, that cut throughput by about 40%. Sampling with the standard OpenTelemetry variables brings that down to about 20%:
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.1This keeps one trace in ten, and follows the caller's decision when a request arrives with a trace context. Errors still reach Sentry when SENTRY_DSN is set.
The template also turns off the ASGI send and receive spans (opentelemetry_exclude_spans in app/settings.py), so each request records its server span and database spans only. With every request traced, that raised throughput by 5 to 8% in the same benchmark. Remove the setting if you need those spans.
📝 License
Browse the full list of templates and libraries in
modern-python; the org profile has the categorized index.