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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_prod-1.1.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_prod-1.1.1-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_prod-1.1.1.tar.gz.

File metadata

  • Download URL: fastapi_prod-1.1.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fastapi_prod-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a0b013ee013d0ba48626c65d0ed262e9063f1ba037cd8393c682ca05dba4304f
MD5 bde7f72ff6cf4c633359b71e698918f8
BLAKE2b-256 19fad2ef148d2860751f51df16055be45465d8e4402d82dc8f67fe8ff8682c6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_prod-1.1.1.tar.gz:

Publisher: publish.yml on tarunkumarhp72/fastapi-prod

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastapi_prod-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: fastapi_prod-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fastapi_prod-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f70e70d7cf41215cc14781fbd94848d8fcde5984232570376c03d0287be4b30c
MD5 d99930cebc0ee963067a11acf40862be
BLAKE2b-256 6711094f1ef2346c4b631f726de2bd38bec1b87a44f2a4201d05e59ec2551098

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_prod-1.1.1-py3-none-any.whl:

Publisher: publish.yml on tarunkumarhp72/fastapi-prod

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page