Skip to main content

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 /health endpoint 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.
  • pytest test suite, ruff / black / isort / mypy configuration, and a Makefile with run, 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

Metadata

Release files for fastapi-prod 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-prod 1.1.1
File Size Uploaded
fastapi_prod-1.1.1.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-prod 1.1.1
File Interpreter ABI Platform
fastapi_prod-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 54.6 kB

Release files / fastapi_prod-1.1.1.tar.gz

Download URL fastapi_prod-1.1.1.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a0b013ee013d0ba48626c65d0ed262e9063f1ba037cd8393c682ca05dba4304f
BLAKE2b-256 checksum
How to use checksums
19fad2ef148d2860751f51df16055be45465d8e4402d82dc8f67fe8ff8682c6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

Release files / fastapi_prod-1.1.1-py3-none-any.whl

Download URL fastapi_prod-1.1.1-py3-none-any.whl
Size 36.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f70e70d7cf41215cc14781fbd94848d8fcde5984232570376c03d0287be4b30c
BLAKE2b-256 checksum
How to use checksums
6711094f1ef2346c4b631f726de2bd38bec1b87a44f2a4201d05e59ec2551098
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page