A production-ready FastAPI full-stack boilerplate to kickstart your modern backend projects with a clean architecture. Built with performance and scalability in mind, this template comes with everything you need for rapid development.
Before Getting Started understand the Project Structure
git clone https://github.com/Dev-Shivaprasad/Fastapi-Tamplate.git
cd fastapi-fullstack-template/backenduv sync- There is already a file is provided called
example_env.txtwhich contains all the necessary variables just replace them.
# linux
cp example_env.txt .env
# windows
copy example_env.txt .env- All the DataBase table schemas and models are stored in the
models/folder
alembic upgrade headuse
alembic revision --autogenerate -m <name_of_the_migration>to create the migration
or
alembic revision -m <name_of_the_migration>for empty migration
All the necessary server configuration is done in the
main.pyfile
docs / Swagger UI is locally hosted on this linkhttp://localhost:8000/docs
uv run main.py-
⚡ FastAPI + Uvicorn — High-performance async API server
-
🔗 SQLModel — ORM by the creator of FastAPI (based on SQLAlchemy)
-
📦 Alembic — Robust and flexible database migrations
-
🔐 JWT Authentication — Secure token-based auth with PyJWT
-
🧂 Password Hashing — Credential hashing via Bcrypt
-
🚀 Orjson — Super-fast JSON parsing for response speed
-
🧩 Modular Architecture — Clean, scalable, and organized codebase
-
🌱 .env Support — Environment-based flexible configuration
-
⏱️ Rate Limiting — Prevent abuse & DoS
-
🐳 Docker — Dockerfile, docker-compose, and Nginx setup
-
🟥 Redis — Caching layer
FASTAPI-TEMPLATE/
│
├── backend/
│ ├── .venv/ # uv-managed virtual environment
│ │
│ ├── alembic # Alembic migration files
│ │
│ ├── core
│ │├─ authentication/ # JWT logic, login, password hashing
│ │├─ cache/ # redis cache setup and initialization (optional)
│ │├─ database/ # DB session setup and initialization
│ │├─ ratelimiter/ # ratelimiter setup and initialization (optional)
│ │└─ helperfunctions.py # contains helper functions
│ │
│ ├── docker/ (optional)
│ │ ├─ .dockerignore # Docker build exclusions
│ │ └─ .Dockerfile # Backend container definition
│ │
│ ├── services/ # contains services (like JWT middleware) for business logic and operations.
│ │
│ ├── src/
│ │ ├─ controllers/ # API route handlers
│ │ ├─ models/ # SQLModel ORM models
│ │ └─ ControllerTemplate.py # controller boilerplate
│ │
│ ├── .env.backup # a demo .env
│ ├── .gitignore # File specifying untracked files to ignore.
│ ├── .python-version # Python version pin
│ ├── alembic.ini # Alembic configuration
│ ├── main.py # App entry point
│ ├── pyproject.toml # uv dependency definition
│ └── uv.lock # Dependency lock file
│
├── docker_and_nginix_configurations/ (optional)
│ ├── env.production # Production environment
│ ├── docker-compose.dev.yml # Development Docker Compose
│ ├── docker-compose.yml # Main Docker Compose configuration
│ ├── DOCKER.md # Docker documentation
│ ├── env.production.example # Production environment template
│ └── nginx.conf # Nginx reverse proxy config
│
├── frontend/ # Optional frontend (React, Vue, etc.)
│
└── README.md # Main documentation
For containerized development and deployment, we now provide comprehensive Docker support:
Development Environment:
# Start development environment with hot reload
docker-compose -f ./docker_and_nginix_configurations/docker-compose.dev.yml up --buildProduction Environment:
# Copy production environment template
cp ./docker_and_nginix_configurations/env.production.example docker_and_nginix_configurations/.env.production
# Edit .env.production with your values
# Start production stack
docker-compose --env-file ./docker_and_nginix_configurations/.env.production --profile production up -d- 🚀 Multi-stage builds : for optimized production images
- 🔄 Hot reload : for development
- 🗄️ PostgreSQL : for production database
- 🔒 Nginx : reverse proxy and abstraction
- 📊 Health checks : and monitoring
- 🔐 Security : best practices
📖 Full Docker documentation: See DOCKER.md for detailed setup and usage instructions.
Here’s what’s planned or coming soon:
-
Rate Limiting — Prevent abuse & DoS
-
Nginx — secure routing and abstraction
-
Docker — Dockerfile & docker-compose setup
-
Redis — Caching layer
-
The frontend/ folder is a placeholder — use it with any frontend framework like:
-
⚛️ React / Next.js
-
🔥 Vue / Nuxt
-
🌌 Astro / SvelteKit
You can remove it if not needed.
Feel free to open issues, suggest improvements, or submit a pull request. Let’s make this great together 😊.