- ⚡ FastAPI — high-performance async API framework
- 🧱 Modular Monolith Architecture — scalable structure without microservices overhead
- 🗃️ SQLAlchemy (async) — modern ORM with async support
- 🔄 Unit of Work pattern — transaction management abstraction
- 📦 Repository pattern — clean data access layer
- 🧪 Pytest — unit & integration testing setup
- 🐳 Docker support — ready for containerized environments
- 🧬 Alembic migrations — database versioning
- ⚙️ Environment-based config
- 🧵 Async-first design
- Separation of concerns
- Dependency inversion
- Testability
- Explicit transaction handling (UoW)
The project includes a testing setup using pytest:
- Unit tests for repositories and services
- Integration tests with a test database
- Async test support
Run tests:
pytestgit clone https://github.com/AstralMortem/fastapi-monolith-template.git
cd fastapi-monolith-templateuv sync
source .venv/bin/activateThe project uses
uvfor fast dependency management ([GitHub][1])
Copy .env.example:
cp .env.example .envUpdate variables (DB, Redis, etc.)
alembic upgrade headuvicorn app.main:app --reloadRun with Docker:
docker-compose up --build- FastAPI
- SQLAlchemy (async)
- PostgreSQL
- Alembic
- Redis (optional)
- Pytest
- Docker
- Repository Pattern
- Unit of Work
- Dependency Injection (FastAPI-based)
- Service Layer
A modular monolith gives you:
- Simpler deployment than microservices
- Clear boundaries between modules
- Easier refactoring
- Ability to scale into microservices later