This template provides a clean and well-structured foundation for building FastAPI applications using Clean Architecture principles. It uses SQLModel as the ORM and PostgreSQL as the database. It clearly separates business logic, use cases, infrastructure, and the API layer to ensure maintainability, testability, and scalability. With an explicit project structure and built-in testing strategy, it serves as a solid starting point for developing professional and production-ready backends.
- Python 3.10 or higher
- PostgreSQL
- uv for managing virtual environments and dependencies
- justfile for command runner
| Description | Status |
|---|---|
| Setup project structure | ✅ |
| Create database models and implement database connection | ✅ |
| Test with real database (e.g., PostgreSQL, MySQL) | ✅ |
| Setup migration (alembic) | ✅ |
| Test on real project | ☕ |
| Implement end-to-end tests setup | ⛔ |
| Implement integration tests setup | ⛔ |
- Create project with
uvx create-modern-fastapi
- Navigate to the project directory:
- Install dependencies:
uv sync
- Run the application:
just start
flowchart LR
ENTRY[Entry Point]
PRESENTATION[Presentation]
APPLICATION[Application]
INFRASTRUCTURE[Infrastructure]
DOMAIN[Domain]
ENTRY --> PRESENTATION
PRESENTATION --> APPLICATION
PRESENTATION --> INFRASTRUCTURE
PRESENTATION --> DOMAIN
APPLICATION --> DOMAIN
INFRASTRUCTURE --> DOMAIN
In progress...
To run tests, use the following command:
- Run unit tests:
just test-unit
- Run tests with coverage:
just test-coverage
- Run test for clean architecture dependency rules:
just test-clean