fastapi-prod
A production-ready FastAPI backend project generator — like django-admin startproject, nest new, ng new, or rails new, but for FastAPI.
fastapi-prod is not a template you clone. It's a CLI you install once, and reuse to scaffold every new FastAPI service with a consistent, production-grade architecture.
Install
With pip:
pip install fastapi-prod
With uv:
uv add fastapi-prod
# or, to just run it without adding it as a project dependency:
uvx fastapi-prod create ecommerce
Usage
fastapi-prod create ecommerce
This launches an interactive wizard:
Project name: ecommerce
Database: PostgreSQL / MySQL / SQLite
Use Redis? (Y/N)
Use Celery? (Y/N)
Use Docker? (Y/N)
All options can also be passed as flags, skipping the corresponding prompt:
fastapi-prod create ecommerce --database postgres --redis --celery --docker
fastapi-prod create internal_tool --database sqlite --no-redis --no-celery --no-docker
Once generated:
cd ecommerce
cp .env.example .env
# with Docker
docker compose up --build
# without Docker (pip)
pip install -e ".[dev]"
alembic revision --autogenerate -m "init"
alembic upgrade head
uvicorn app.main:app --reload
# without Docker (uv)
uv pip install -e ".[dev]"
uv run alembic revision --autogenerate -m "init"
uv run alembic upgrade head
uv run uvicorn app.main:app --reload
What you get
- Layered architecture:
Route -> Service -> Repository -> Database. Routes never touch the database directly. - FastAPI app factory with lifespan events, request logging middleware, and a centralized exception handler.
- SQLAlchemy 2.x (async) + Alembic (async migrations), pre-wired for PostgreSQL, MySQL, or SQLite.
- Pydantic Settings based configuration, loaded from
.env. - A working
GET /healthendpoint and a full sample CRUD resource (model, schema, repository, service, routes) to copy for your own resources. - Optional Redis client, optional Celery worker (Redis-backed), optional Docker +
docker-compose.yml— only generated when you opt in. pytesttest suite,ruff/black/isort/mypyconfiguration, and aMakefilewithrun,test,lint,format,revision,migrate.
Developing this package locally
Clone the repo, then install it in editable mode so fastapi-prod picks up code changes immediately.
With pip
git clone https://github.com/tarunkumarhp72/fastapi-prod.git
cd fastapi-prod
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
pip install -e .
With uv
git clone https://github.com/tarunkumarhp72/fastapi-prod.git
cd fastapi-prod
uv venv
uv pip install -e .
# or skip the venv step entirely and just:
uv run fastapi-prod --help
Verifying the install actually works
# CLI is on PATH and importable
fastapi-prod --help
# generate a throwaway project
fastapi-prod create smoke_test --database sqlite --no-redis --no-celery --no-docker
# prove the generated project itself is valid
cd smoke_test
cp .env.example .env
pip install -e ".[dev]" # or: uv pip install -e ".[dev]"
python -m pytest -v # should show 1 passed (test_health.py)
alembic revision --autogenerate -m "init"
alembic upgrade head
uvicorn app.main:app --reload
Then visit http://127.0.0.1:8000/docs and http://127.0.0.1:8000/api/v1/health.
Architecture of this package
src/fastapi_prod/
cli/ # Typer commands (create.py, main.py)
config/ # ProjectConfig — the single source of truth for a generation run
prompts/ # Interactive wizard
generators/ # One generator per concern: project (core), redis, celery, docker
renderers/ # Jinja2 rendering
utils/ # Generic template-tree file writer, shared errors/paths
templates/
base/ # Always generated (core FastAPI app, DB-agnostic)
redis/ # Only rendered if Redis is selected
celery/ # Only rendered if Celery is selected
docker/ # Only rendered if Docker is selected
Every generator implements the same tiny BaseGenerator.generate(context) interface, and all of them reuse a single generic render_template_tree() helper. Adding a new optional feature later (auth, email, websockets, RabbitMQ, Kafka, monitoring, ...) means adding a new template folder + a new generator + a new CLI command — no existing generator or template needs to change.
Roadmap
fastapi-prod create is the only command in v1.0. Future versions add fastapi-prod add <feature> commands (auth, email, websocket, rabbitmq, kafka, monitoring, sentry, aws, kubernetes) on top of the same architecture, without breaking v1 projects.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_prod-1.0.0.tar.gz.
File metadata
- Download URL: fastapi_prod-1.0.0.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fad312690973b9f0606ad340d3cc9d6b1f12d6530014d4855851bde8eee97c20
|
|
| MD5 |
085241dba822188e5411def4f48256d6
|
|
| BLAKE2b-256 |
42ff74085490516c222cd1a48de27f5043894bf7bd57b33eb4b8b49362ac05ed
|
Provenance
The following attestation bundles were made for fastapi_prod-1.0.0.tar.gz:
Publisher:
publish.yml on tarunkumarhp72/fastapi-prod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_prod-1.0.0.tar.gz -
Subject digest:
fad312690973b9f0606ad340d3cc9d6b1f12d6530014d4855851bde8eee97c20 - Sigstore transparency entry: 2300573484
- Sigstore integration time:
-
Permalink:
tarunkumarhp72/fastapi-prod@d9dbe13dc632605268f95883c9ecff2ac5d1f69c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/tarunkumarhp72
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d9dbe13dc632605268f95883c9ecff2ac5d1f69c -
Trigger Event:
release
-
Statement type:
File details
Details for the file fastapi_prod-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fastapi_prod-1.0.0-py3-none-any.whl
- Upload date:
- Size: 34.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
910bc76637f8796492ce3ed8b33d87f43a834426217479bf437e395f4e4cfc78
|
|
| MD5 |
f0c7fdd3b95639574163c02823baf4e7
|
|
| BLAKE2b-256 |
5dd09db1a69caba37e21d1bbdb5e057548ce91c9f0cdd1c875b2aaa5b2b5dc06
|
Provenance
The following attestation bundles were made for fastapi_prod-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on tarunkumarhp72/fastapi-prod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_prod-1.0.0-py3-none-any.whl -
Subject digest:
910bc76637f8796492ce3ed8b33d87f43a834426217479bf437e395f4e4cfc78 - Sigstore transparency entry: 2300573493
- Sigstore integration time:
-
Permalink:
tarunkumarhp72/fastapi-prod@d9dbe13dc632605268f95883c9ecff2ac5d1f69c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/tarunkumarhp72
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d9dbe13dc632605268f95883c9ecff2ac5d1f69c -
Trigger Event:
release
-
Statement type: