Batteries-included FastAPI starter with production-ready defaults, optional modules, and clear docs.
๐ Docs ยท ๐ง DeepWiki ยท ๐ฌ Discord
- โก๏ธ Fully async FastAPI + SQLAlchemy 2.0
- ๐งฑ Pydantic v2 models & validation
- ๐ JWT auth (access + refresh), cookies for refresh
- ๐ฎ Rate limiter + tiers (free/pro/etc.)
- ๐งฐ FastCRUD for efficient CRUD & pagination
- ๐งโ๐ผ CRUDAdmin: minimal admin panel (optional)
- ๐ฆ ARQ background jobs (Redis)
- ๐ง Redis caching (server + client-side headers)
- ๐ณ One-command Docker Compose
- ๐ NGINX & Gunicorn recipes for prod
Perfect if you want:
- A pragmatic starter with auth, CRUD, jobs, caching and rate-limits
- Sensible defaults with the freedom to opt-out of modules
- Docs over boilerplate in README - depth lives in the site
Not a fit if you need a monorepo microservices scaffold - see the docs for pointers.
What you get:
- App: FastAPI app factory, env-aware docs exposure
- Auth: JWT access/refresh, logout via token blacklist
- DB: Postgres + SQLAlchemy 2.0, Alembic migrations
- CRUD: FastCRUD generics (get, get_multi, create, update, delete, joins)
- Caching: decorator-based endpoints cache; client cache headers
- Queues: ARQ worker (async jobs), Redis connection helpers
- Rate limits: per-tier + per-path rules
- Admin: CRUDAdmin views for common models (optional)
This is what we've been using in production apps. Several applications running in production started from this boilerplate as their foundation - from SaaS platforms to internal tools. It's proven, stable technology that works together reliably. Use this as the foundation for whatever you want to build on top.
Building an AI SaaS? Skip even more setup with FastroAI - our production-ready template with AI integration, payments, and frontend included.
Use the template on GitHub, create your repo, then:
git clone https://github.com/<you>/FastAPI-boilerplate
cd FastAPI-boilerplateQuick setup: Run the interactive setup script to choose your deployment configuration:
./setup.pyOr directly specify the deployment type: ./setup.py local, ./setup.py staging, or ./setup.py production.
The script copies the right files for your deployment scenario. Here's what each option sets up:
Best for: Development and testing
Copies:
scripts/local_with_uvicorn/DockerfileโDockerfilescripts/local_with_uvicorn/docker-compose.ymlโdocker-compose.ymlscripts/local_with_uvicorn/.env.exampleโsrc/.env
Sets up Uvicorn with auto-reload enabled. The example environment values work fine for development.
Manual setup: ./setup.py local or copy the files above manually.
Best for: Staging environments and load testing
Copies:
scripts/gunicorn_managing_uvicorn_workers/DockerfileโDockerfilescripts/gunicorn_managing_uvicorn_workers/docker-compose.ymlโdocker-compose.ymlscripts/gunicorn_managing_uvicorn_workers/.env.exampleโsrc/.env
Sets up Gunicorn managing multiple Uvicorn workers for production-like performance testing.
Warning
Change SECRET_KEY and passwords in the .env file for staging environments.
Manual setup: ./setup.py staging or copy the files above manually.
Best for: Production deployments
Copies:
scripts/production_with_nginx/DockerfileโDockerfilescripts/production_with_nginx/docker-compose.ymlโdocker-compose.ymlscripts/production_with_nginx/.env.exampleโsrc/.env
Sets up NGINX as reverse proxy with Gunicorn + Uvicorn workers for production.
Caution
You MUST change SECRET_KEY, all passwords, and sensitive values in the .env file before deploying!
Manual setup: ./setup.py production or copy the files above manually.
Start your application:
docker compose upAccess your app:
- Local: http://127.0.0.1:8000 (auto-reload enabled) โ API docs
- Staging: http://127.0.0.1:8000 (production-like performance)
- Production: http://localhost (NGINX reverse proxy)
Create your first admin user:
docker compose run --rm create_superuserRun database migrations (if you add models):
cd src && uv run alembic revision --autogenerate && uv run alembic upgrade headTest background jobs:
curl -X POST 'http://127.0.0.1:8000/api/v1/tasks/task?message=hello'Or run locally without Docker:
uv sync && uv run uvicorn src.app.main:app --reloadFull setup (from-scratch, .env examples, PostgreSQL & Redis, gunicorn, nginx) lives in the docs.
Create src/.env and set app, database, JWT, and environment settings. See the docs for a copy-pasteable example and production guidance.
https://benavlabs.github.io/FastAPI-boilerplate/getting-started/configuration/
ENVIRONMENT=local|staging|productioncontrols API docs exposure- Set
ADMIN_*to enable the first admin user
# run locally with reload (without Docker)
uv sync && uv run uvicorn src.app.main:app --reload
# run Alembic migrations
cd src && uv run alembic revision --autogenerate && uv run alembic upgrade head
# enqueue a background job (example endpoint)
curl -X POST 'http://127.0.0.1:8000/api/v1/tasks/task?message=hello'More examples (superuser creation, tiers, rate limits, admin usage) in the docs.
Read contributing.
This project was inspired by a few projects, it's based on them with things changed to the way I like (and pydantic, sqlalchemy updated)
Full Stack FastAPI and PostgreSQLby @tiangolo himselfFastAPI Microservicesby @kludex which heavily inspired this boilerplateAsync Web API with FastAPI + SQLAlchemy 2.0for sqlalchemy 2.0 ORM examplesFastaAPI Rocket Boilerplatefor docker compose
Benav Labs โ benav.io, discord server