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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for fastapi_production_template-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3ca0931519a389a4f9b93894eee3e9732568b0923d67a0831b7047455121fb95
MD5 e6bd369e1c29fd0b17dad30a5a750ce0
BLAKE2b-256 87a1b7d67f6a6d6985332425a5caa9711eb22781979296e0c79e613c14867903

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastapi_production_template-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dd0a658067042fd13cc00a793f476da07ce030e949b00ea6ac056e1bde00b565
MD5 5bcb51e7d749a83391cc7facd3f6f069
BLAKE2b-256 577922c16c57ac3cf9a4526095d5f6059a8a7e45cf31463b12a9a738a7a67ccf

See more details on using hashes here.

Provenance

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