Skip to main content

Production-ready FastAPI template with CI/CD, Terraform, and complete tests

Project description

FastAPI Production Template

Production-ready FastAPI starter focused on clean architecture, strict quality gates, and cloud-ready infrastructure baselines.

Tech stack

  • Python 3.14
  • FastAPI + Pydantic v2
  • SQLAlchemy async + asyncpg
  • UV package management
  • Ruff + Ty + Pytest
  • Docker + Docker Compose
  • Terraform (AWS, Azure, GCP)
  • GitHub Actions CI

What is included

  • App factory setup with versioned API routes (/api/v1)
  • Typed request/response models and domain layer separation
  • SQLAlchemy async ORM + repository-backed document workflows
  • PoC-mode DB lifecycle wiring with dependency injection and startup schema creation
  • API key auth (X-API-Key) for document endpoints
  • Structured JSON logging + request ID middleware (X-Request-ID)
  • Lightweight Prometheus-style metrics endpoint
  • Quality checks wired for linting, typing, tests, and coverage gate
  • Terraform starter modules for container registry setup:
    • AWS ECR
    • Azure Container Registry
    • GCP Artifact Registry

API endpoints

  • GET /api/v1/health
  • GET /api/v1/metrics
  • POST /api/v1/documents/analyze
  • POST /api/v1/documents
  • GET /api/v1/documents
  • GET /api/v1/documents/{document_id}
  • PUT /api/v1/documents/{document_id}
  • DELETE /api/v1/documents/{document_id}

/health and /metrics are public. All /documents* routes require X-API-Key.

Local development

uv sync --all-groups
uv run uvicorn fastapi_production_template.main:app --reload

Example authenticated request:

curl -H "X-API-Key: dev-api-key" http://localhost:8000/api/v1/documents

Tests and quality gates

uv run pytest
uv run ruff check .
uv run ty check .
uv run tox

Pre-commit hooks (Ruff, unit tests, Terraform fmt check):

uv run pre-commit install
uv run pre-commit run --all-files

Docker

Standard compose setup:

docker compose up --build

Dev profile with file watching (src, tests, pyproject.toml):

docker compose --profile dev up --build --watch api-dev postgres

Terraform validation

terraform -chdir=infra/terraform-aws init
terraform -chdir=infra/terraform-aws validate
terraform -chdir=infra/terraform-azure init
terraform -chdir=infra/terraform-azure validate
terraform -chdir=infra/terraform-gcp init
terraform -chdir=infra/terraform-gcp validate

Freelance work

I am Kevin Meinon, a freelance backend developer focused on Python/FastAPI, API architecture, and production hardening.

If your team needs support with:

  • backend feature delivery
  • API performance and reliability
  • test strategy and CI quality gates
  • cloud deployment foundations

Reach out at kevin@meinon.de.

Project details


Download files

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

Source Distribution

fastapi_production_template-0.1.1.tar.gz (9.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_production_template-0.1.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_production_template-0.1.1.tar.gz.

File metadata

File hashes

Hashes for fastapi_production_template-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aa4228e207056258953bb9b30a3f623b95489ce47af88815c753c1229a795cb0
MD5 1af96400a2ec7ca8d6a6efa19a29bf52
BLAKE2b-256 8ebcd521cf94a5a2d3996f25003e0ec1689e8c4a619343f9ad0696f6939ec07a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_production_template-0.1.1.tar.gz:

Publisher: ci.yml on Krytos/fastapi-production-template

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_production_template-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_production_template-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 756d562ddcfb53cd5c69268d0ca47d8f04515bf53eaab39444e31a3211f33d83
MD5 a73ef1c87d94c6bced10541824657e2d
BLAKE2b-256 d416c50c1e3b514aca5f0d3e671728139e28c5bf3db5fbf31a61cc7fa72796af

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_production_template-0.1.1-py3-none-any.whl:

Publisher: ci.yml on Krytos/fastapi-production-template

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