Skip to main content

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

Project description

FastAPI Production Template

CI Tests PyPI version Python versions Coverage gate Code style: Ruff Type checking: Ty Publish: PyPI Package manager: uv Framework: FastAPI ORM: SQLAlchemy Database: PostgreSQL Infra: Terraform Container: Docker

Open for Freelance Hire Me Contact

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.3.tar.gz (9.8 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.3-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for fastapi_production_template-0.1.3.tar.gz
Algorithm Hash digest
SHA256 06b508fd80186a8d23aa43a2d8f64b95a4d990452ba4ec97e10a8b2fac077a4f
MD5 798a1ffe7b09e9d0945f38d6d903a4bb
BLAKE2b-256 64cb4da01dba422242fff4a5593ed2ccb5df88c823d165ae49dfe8da7d2018ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_production_template-0.1.3.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.3-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_production_template-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0fbb1dfb529a34cb6a936903ad056652e85e042a97d3218a755bd1eb7e5c7e43
MD5 13a055b279bf19aba3a82ed43821f7e1
BLAKE2b-256 cda55cf735aa8196617d582b72c7722640973dc809fc2b2aa117e09581b7b2c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_production_template-0.1.3-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