A production-ready FastAPI template designed for scalability, observability, and clean architecture.
It demonstrates a modern Python backend stack using:
- Clean Architecture (DDD-inspired)
- Docker-first development
- Observability (OpenTelemetry + Jaeger)
- Strong typing & linting (Ruff + Ty)
- Modern tooling (uv + mise)
- Fully automated dev workflow
- β‘ FastAPI (async-first API framework)
- π§± Clean Architecture (domain / application / data / presentation)
- π PostgreSQL (asyncpg + SQLAlchemy 2 + SQLModel)
- π Alembic migrations
- π¦ Dockerize full stack (backend + postgres + observability stack)
- π OpenTelemetry tracing (FastAPI + collector + Jaeger)
- π§ Strong typing (Ty)
- π§Ή Ruff for linting + formatting
- π§ͺ Pytest + coverage + benchmarking
- π Security scanning (bandit + detect-secrets)
- π§Ύ Conventional commits (Commitizen)
- π Developer experience via
mise
This project follows a modular domain-driven structure:
src/
βββ apps/
β βββ users/
β βββ domain/ # Entities + DTOs (pure business logic)
β βββ application/ # Use cases / services
β βββ data/ # Repositories / DB layer
β βββ presentation/ # API routes (FastAPI)
β
βββ core/
β βββ settings.py
β βββ base_service.py
β βββ base_repository.py
β βββ deps.py
β
βββ utils/
β βββ logging_config.py
β βββ middleware.py
β βββ exceptions.py
β βββ pagination.py
β
βββ migrations/ # Alembic migrations
βββ main.pyThis project uses mise:
mise installmise run setupThis will:
- Install dependencies (uv)
- Setup pre-commit hooks
mise run upThis starts:
- Backend API
- PostgreSQL
- Observability stack (Jaeger + OpenTelemetry collector)
mise run migratemise run logsor run backend shell:
mise run shellOnce backend is running:
mise run swaggerπ http://localhost:8000/docs
Run all tests:
mise run testRun with coverage:
mise run coverageOutput:
- Terminal coverage report
- HTML report β
htmlcov/index.html
Run performance benchmarks:
mise run benchmarkRun security checks:
mise run securityIncludes:
- Bandit (static security analysis)
- Detect-secrets (secret scanning)
mise run fmtmise run lintmise run lint-fixmise run typecheckmise run checkmise run upmise run downmise run rebuildmise run logsmise run shellmise run migratemise run makemigrations -m "your message"mise run db-current
mise run db-historyThis project includes full distributed tracing:
- OpenTelemetry SDK
- FastAPI instrumentation
- OTEL Collector
- Jaeger UI
Access Jaeger:
This project enforces Conventional Commits.
mise run commitmise run bumpSimulate CI locally:
mise run ciRuns:
- formatting
- linting
- typing
- tests
- security checks
| Layer | Tech |
|---|---|
| API | FastAPI |
| DB | PostgreSQL |
| ORM | SQLAlchemy + SQLModel |
| Migrations | Alembic |
| Observability | OpenTelemetry + Jaeger |
| Validation | Pydantic v2 |
| Typing | Ty |
| Linting | Ruff |
| Testing | Pytest |
| Runtime | Uvicorn |
| Packaging | uv |
| Dev UX | mise |
This template is built around:
- Predictable structure
- Zero hidden magic
- Fast local iteration
- Production parity with Docker
- Strict typing + linting
- Observability by default
users/
βββ domain/ β pure logic
βββ application/ β use cases
βββ data/ β DB layer
βββ presentation/ β API routesEach layer is independent β easy testing, scaling, and refactoring.
- No global dependencies (everything via
uv) - No Node required
- Fully reproducible environments
- Designed for scaling into microservices