Production-ready FastAPI template with CI/CD, Terraform, and complete tests
Project description
⚡ FastAPI Production Template
Battle-tested Python backend architecture — ready to ship.
By Kevin Meinon · Freelance Backend Engineer
About
I'm Kevin Meinon, a freelance backend engineer specialising in Python and production-grade API systems — primarily FastAPI, but equally at home with Flask and Django depending on what the project calls for.
This template is a living showcase of the architecture patterns and engineering standards I bring to every engagement — not boilerplate to fill in, but a reference for what production-ready actually looks like.
What I build:
- High-throughput REST & async APIs with clean domain separation
- End-to-end CI pipelines with strict quality gates (lint, types, coverage)
- Cloud-portable infrastructure baselines (AWS / Azure / GCP)
- Systems that are easy for your team to own after I'm done
If your team needs a backend that ships fast and holds up — let's talk.
What this demonstrates
| Concern | Approach |
|---|---|
| Architecture | App factory, versioned routes, repository pattern, domain layer separation — framework-agnostic patterns that port cleanly to Flask or Django |
| Data layer | SQLAlchemy async ORM + asyncpg + dependency-injected sessions |
| Auth | API key middleware (X-API-Key) with per-route enforcement |
| Observability | Structured JSON logging, request ID propagation, Prometheus-style metrics |
| Quality | 100% coverage gate, Ruff linting, Ty type checking, pre-commit hooks |
| Infrastructure | Terraform modules for ECR (AWS), ACR (Azure), GAR (GCP) |
| Dev experience | Docker Compose with hot-reload dev profile, full local parity |
Tech stack
- Runtime: Python 3.14
- Framework: FastAPI + Pydantic v2 · Flask · Django
- Database: PostgreSQL · SQLAlchemy async · asyncpg
- Tooling: uv · Ruff · Ty · pytest · tox
- Infrastructure: Docker · Docker Compose · Terraform (AWS / Azure / GCP)
- CI/CD: GitHub Actions
The FastAPI layer is intentionally thin and architecturally isolated — swapping it for Flask or Django is a configuration change, not a rewrite.
API surface
GET /api/v1/health # public
GET /api/v1/metrics # public
POST /api/v1/documents/analyze # requires X-API-Key
POST /api/v1/documents # requires X-API-Key
GET /api/v1/documents # requires X-API-Key
GET /api/v1/documents/{document_id} # requires X-API-Key
PUT /api/v1/documents/{document_id} # requires X-API-Key
DELETE /api/v1/documents/{document_id} # requires X-API-Key
Local development
uv sync --all-groups
uv run uvicorn fastapi_production_template.main:app --reload
curl -H "X-API-Key: dev-api-key" http://localhost:8000/api/v1/documents
Quality gates
uv run pytest # tests + coverage
uv run ruff check . # linting
uv run ty check . # type checking
uv run tox # full gate
uv run pre-commit install
uv run pre-commit run --all-files
Docker
docker compose up --build
# Dev profile with hot reload
docker compose --profile dev up --build --watch api-dev postgres
Terraform
terraform -chdir=infra/terraform-aws init && validate
terraform -chdir=infra/terraform-azure init && validate
terraform -chdir=infra/terraform-gcp init && validate
Hire me
I'm available for backend contracts and freelance projects.
Backend feature delivery · API performance & reliability · CI quality gates · Cloud deployment
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.4.tar.gz.
File metadata
- Download URL: fastapi_production_template-0.1.4.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d617706f3a55dbcc98409c2eb294cd10e00bce0bb5e08dc181e604127a3e7bd
|
|
| MD5 |
a7b8294e3f2b54a8eaaec2c066ff3db1
|
|
| BLAKE2b-256 |
84e7281bf9646e43ea5cee83a3d5566b579535a3942f4830674a5cc54c7cab0e
|
Provenance
The following attestation bundles were made for fastapi_production_template-0.1.4.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.4.tar.gz -
Subject digest:
4d617706f3a55dbcc98409c2eb294cd10e00bce0bb5e08dc181e604127a3e7bd - Sigstore transparency entry: 1217509458
- Sigstore integration time:
-
Permalink:
Krytos/fastapi-production-template@dec9c2eccd529194a65046895693d3563c7f401e -
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@dec9c2eccd529194a65046895693d3563c7f401e -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastapi_production_template-0.1.4-py3-none-any.whl.
File metadata
- Download URL: fastapi_production_template-0.1.4-py3-none-any.whl
- Upload date:
- Size: 17.6 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 |
4c9fe756fbd97be46807ff591ce28ab94b525708be686507eadba675cf9b8ffc
|
|
| MD5 |
4cd3ef4d7e282ceb80657a05b35fb8c9
|
|
| BLAKE2b-256 |
718b5722f6146162de1563dde2d2da212b0762fd284beac2c676f13486c8ef2a
|
Provenance
The following attestation bundles were made for fastapi_production_template-0.1.4-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.4-py3-none-any.whl -
Subject digest:
4c9fe756fbd97be46807ff591ce28ab94b525708be686507eadba675cf9b8ffc - Sigstore transparency entry: 1217509479
- Sigstore integration time:
-
Permalink:
Krytos/fastapi-production-template@dec9c2eccd529194a65046895693d3563c7f401e -
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@dec9c2eccd529194a65046895693d3563c7f401e -
Trigger Event:
push
-
Statement type: