Production FastAPI PostgreSQL stack
Task Management REST API demonstrating production-ready practices: FastAPI framework, PostgreSQL database, Docker orchestration, Nginx reverse proxy, SQLAlchemy ORM, Alembic migrations, two-tier rate limiting, and comprehensive security features.
Features
- FastAPI - High-performance async API
- PostgreSQL - Relational database
- SQLAlchemy ORM - SQL injection protection
- Alembic Migrations - Database version control
- Nginx Reverse Proxy - Security and rate limiting
- Two-tier Rate Limiting - Nginx (10 req/s) + FastAPI (100 req/60s)
- Docker Compose - Complete containerized environment
- Swagger docs - Autogenerated docs at http://localhost/docs
Prerequisites
- Docker 20.10+
- Docker Compose 2.0+
Quick Start
# Start all services (builds images, runs migrations, starts servers)
make up
# Seed database with test data (optional)
make seed
Makefile Commands
Basic Operations
make up # Start all services
make down # Stop all services
make restart # Restart services
make status # Show container status
make health # Check API health
Logs
make logs # View all logs
make logs-api # API logs only
make logs-nginx # Nginx logs only
make logs-db # Database logs only
Database
make migrate # Run migrations
make seed # Seed database with test data
make migration-create # Create new migration (interactive)
make db-shell # Open PostgreSQL shell
Cleanup
make clean # Remove containers & volumes (keep images)
make clean-all # Remove everything (containers, volumes, images)
Utilities
make api-shell # Open API container shell
make build # Rebuild images
Environment Variables
Create .env file in project root (optional):