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/healthGET /api/v1/metricsPOST /api/v1/documents/analyzePOST /api/v1/documentsGET /api/v1/documentsGET /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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_production_template-0.1.3.tar.gz.
File metadata
- Download URL: fastapi_production_template-0.1.3.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06b508fd80186a8d23aa43a2d8f64b95a4d990452ba4ec97e10a8b2fac077a4f
|
|
| MD5 |
798a1ffe7b09e9d0945f38d6d903a4bb
|
|
| BLAKE2b-256 |
64cb4da01dba422242fff4a5593ed2ccb5df88c823d165ae49dfe8da7d2018ee
|
Provenance
The following attestation bundles were made for fastapi_production_template-0.1.3.tar.gz:
Publisher:
ci.yml on Krytos/fastapi-production-template
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_production_template-0.1.3.tar.gz -
Subject digest:
06b508fd80186a8d23aa43a2d8f64b95a4d990452ba4ec97e10a8b2fac077a4f - Sigstore transparency entry: 1217314285
- Sigstore integration time:
-
Permalink:
Krytos/fastapi-production-template@bc8a0fcfcbb21bbb404a1a223d3e49d75635999a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Krytos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@bc8a0fcfcbb21bbb404a1a223d3e49d75635999a -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastapi_production_template-0.1.3-py3-none-any.whl.
File metadata
- Download URL: fastapi_production_template-0.1.3-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fbb1dfb529a34cb6a936903ad056652e85e042a97d3218a755bd1eb7e5c7e43
|
|
| MD5 |
13a055b279bf19aba3a82ed43821f7e1
|
|
| BLAKE2b-256 |
cda55cf735aa8196617d582b72c7722640973dc809fc2b2aa117e09581b7b2c1
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_production_template-0.1.3-py3-none-any.whl -
Subject digest:
0fbb1dfb529a34cb6a936903ad056652e85e042a97d3218a755bd1eb7e5c7e43 - Sigstore transparency entry: 1217314302
- Sigstore integration time:
-
Permalink:
Krytos/fastapi-production-template@bc8a0fcfcbb21bbb404a1a223d3e49d75635999a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Krytos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@bc8a0fcfcbb21bbb404a1a223d3e49d75635999a -
Trigger Event:
push
-
Statement type: