Skip to main content

Cookiecutter FastAPI Starter

PyPI version Python versions CI License: MIT

A pragmatic, production-minded FastAPI project generator, inspired by cookiecutter-django.

It generates a project with:

  • FastAPI application factory
  • Versioned API routes (/api/v1)
  • Settings via pydantic-settings
  • SQLAlchemy 2.0 session management
  • Alembic migrations
  • Optional JWT authentication
  • A single, consistent API error envelope
  • Request ID middleware
  • Structured logging
  • Health check endpoint
  • Pytest test setup
  • GitHub Actions CI
  • Optional pre-commit hooks
  • Optional Docker and Docker Compose files
  • Optional Ruff and mypy configuration

Install

pip install cookiecutter-fastapi-starter

Usage

cookiecutter-fastapi-starter

Answer the prompts and you get a runnable project. To skip the prompts and override individual values:

cookiecutter-fastapi-starter --no-input -o ./projects include_auth=no database=sqlite

--help lists the flags. If you already use Cookiecutter, you can skip the install entirely and point it at the repository:

cookiecutter gh:pratik16102001/cookiecutter-fastapi

Running the generated project

cd my-fastapi-app
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
cp .env.example .env
alembic upgrade head
uvicorn app.main:app --reload

Template options

Option Default Description
project_name FastAPI Starter Human-readable project name
project_slug derived Kebab-case folder name
package_name derived Python import package name
description ... Short project description
author_name / email ... Project metadata
python_version 3.12 Targeted Python version
fastapi_version 0.115.0 Pinned FastAPI version
database postgresql postgresql or sqlite
include_auth yes JWT auth, user model, and auth routes
cors_origins localhost origins Comma-separated allowed origins
use_docker yes Dockerfile and Compose file
use_ruff yes Ruff lint configuration
use_mypy yes mypy configuration
use_pre_commit yes pre-commit hooks
license MIT MIT, Apache-2.0, or Proprietary

Generated layout

my-fastapi-app/
├── app/
│   ├── api/v1/            # Router and route modules
│   ├── core/              # Config, logging, errors, security
│   ├── db/                # Declarative base and session factory
│   ├── middleware/        # Request ID middleware
│   ├── models/            # SQLAlchemy models
│   ├── schemas/           # Pydantic schemas
│   ├── services/          # Business logic and data access
│   └── main.py            # Application factory
├── alembic/               # Migration environment and versions
├── tests/
└── pyproject.toml

Every error response uses one shape, carrying the request ID so that a client report can be traced to a log line:

{ "error": { "code": "http_error", "message": "Not Found", "request_id": "..." } }

Before you deploy a generated project

The defaults are tuned for local development. Change these first:

  • Set a real SECRET_KEY in .env.
  • Set ENVIRONMENT=production (this also disables /docs and /redoc).
  • Narrow allowed_hosts from ["*"] to your actual hostnames.
  • Narrow CORS_ORIGINS to your real front-end origins.

Contributing

See CONTRIBUTING.md and our Code of Conduct. To report a security issue, see SECURITY.md.

Roadmap

  • Role-based access control
  • Redis cache option
  • Celery/RQ background jobs
  • OpenAPI client generation
  • Kubernetes deployment examples

License

MIT — see LICENSE.

Metadata

Release files for cookiecutter-fastapi-starter 0.2.0

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

Source distribution (sdist)

Source distribution for cookiecutter-fastapi-starter 0.2.0
File Size Uploaded
cookiecutter_fastapi_starter-0.2.0.tar.gz 21.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cookiecutter-fastapi-starter 0.2.0
File Interpreter ABI Platform
cookiecutter_fastapi_starter-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.3 kB

Release files / cookiecutter_fastapi_starter-0.2.0.tar.gz

Download URL cookiecutter_fastapi_starter-0.2.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
37279730e180b16e71b96522aa9ef05bb1dee8fcb57da33c9034ca4e98c5e0a7
BLAKE2b-256 checksum
How to use checksums
fbc84261680e481ccf49aef6c10982575befcd93503509d6c98552243ba30117
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 5, 2026.

Transparency log

Release files / cookiecutter_fastapi_starter-0.2.0-py3-none-any.whl

Download URL cookiecutter_fastapi_starter-0.2.0-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28124a77e56813729338359238ddefe4075cb0d3eea7e900a6fe282170d7f63c
BLAKE2b-256 checksum
How to use checksums
4efa287f62fac921f1de868c75b2f484e1718c237db41d52a9b78209cb6f2956
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 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

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