How zhanymkanov/fastapi_production_template works
Main system components
• FastAPI Application – The core API logic is implemented in the "src" directory, with src/main.py as the entry point and additional modules for configuration, constants, database connectivity, utils, etc.
• Database – Postgres is used as the persistent storage, and there are scripts in the “scripts/postgres” directory to handle backups and restores. The configuration and migrations (using Alembic) further emphasize the database’s central role.
• Migration System – The “alembic” directory contains scripts and configuration for handling migrations, which is an essential part of managing the database schema.
• Production Components – Docker (via Dockerfile.prod and docker-compose.prod.yml), Gunicorn (via the gunicorn directory and entrypoints scripts), and logging configurations (logging.ini, logging_production.ini) provide production-readiness.
• Development Utilities – Environment setups, linting (ruff via the configuration files and justfile commands), and poetry configuration.
• Optionally, show the external tooling layer that uses just commands and poetry for local development, highlighting that these scripts automate tasks like running the development server, linting, and managing migrations.
Architectural patterns and technologies
• Separation of concerns: configuration management (src/config.py), main server logic (src/main.py), and database components (src/database.py & alembic migrations).
• That production deployments are managed through Docker and docker-compose, which orchestrates the infrastructure (both API container and Postgres server container).