A production-ready FastAPI template with comprehensive integrations for modern web development.
This template provides a solid foundation for building production-ready web services with FastAPI. It combines modern tools and best practices to help you get started quickly:
- Core Stack: FastAPI + PostgreSQL + SQLAlchemy
- Deployment: Docker + Nginx + Certs configuration ready to go
- Monitoring: Prometheus metrics and Grafana dashboards
- Development: Poetry for dependencies, Ruff for linting, pytest for testing
- CI/CD: GitHub Actions workflow included
- Tooling: Custom module system to automate routine tasks
- Pre-configured: App-logging, api-limiter, openapi-specification, metrics and CORS middlewares, etc.
- Testing: Container-free testing system
Everything is pre-configured and tested to work together. Just clone, customize, and start building your application.
You'll need these tools installed:
Quick Install: run
./deploy/dependencies.sh
to install requirements
Use make help
to see all available commands:
make help
make env # Creates .env from .env.example
Note: View supported env-variables in
backend/app/config/default.py
Note:
env.example
contains minimal required variables
Choose your configuration:
run-local
- Local development:backend[local] + database[docker]
run-dev1
- Basic deployment:nginx[http] + backend + database
run-dev2
- Full development:nginx[http] + backend + database + grafana + prometheus
run-prod
- Production:nginx[https + http] + backend + database + grafana + prometheus + pgbackups
make <target-config>
Local setup: starts database, setup poetry and make migrations besides runing app itself.
Production: Also there is script to run prod setup as linux-unit:
/deploy/deploy-service.sh
.
Assume, that you run app on localhost:
- Backend/Swagger :
localhost/swagger
- Backend/Scalar :
localhost/scalar
- Graphana :
localhost:3333
, admin/admin
make poetry # Installs all dependency groups (test, dev)
pre-commit install
Note: ruff formatting works only for
/backend
dir
Now you're ready to develop!
This project is built using layered architecture pattern, which provides clear separation of concerns and maintainable codebase.
To accelerate development process, I provide automated tools located in /backend/.utils/
directory.
Generate a new module:
make module name=<module-name>
The generator will:
- Create module structure in
backend/app/src/modules/{module-name}
- Setup testsuite in
backend/tests/testsuites/{module-name}
- Add necessary base classes and metadata
Note: Import your new module in
backend/app/src/modules/__init__.py