Verificando autenticación…

Skip to main content

Golden Path: Backend Python FastAPI

Template for async FastAPI (Python 3.11+) services with hexagonal architecture, deployed on Cloud Run. It ships a reference Flights CRUD API that illustrates the patterns to extend when creating a new microservice.

Repository

GitLab: templates/template-python-cr

Detailed technical reference for the template: FastAPI Template.

Stack

ComponentValue
LanguagePython 3.11+
FrameworkFastAPI (async)
Dependency manageruv (recommended) or pip
ArchitectureHexagonal (domain / services / infrastructure)
PersistencePostgreSQL (SQLModel + SQLAlchemy async, asyncpg)
MigrationsAlembic (migrate.py) with seed data
RuntimeCloud Run
ObservabilityOpenTelemetry (opentelemetry-instrument)

Features

  • Automatic OpenAPI — interactive docs at /docs.
  • JWT authentication — Bearer token validation against Azure AD JWKS (aud, exp, iss).
  • Schema management — schema sync on startup + Alembic migrations.
  • Cloud Run readyDockerfile, ERB deploy templates, and CI via ANDES pipelines.

Reference API (Flights)

MethodPathAuth
GET/healthNo
POST/flightsJWT
GET/flightsJWT
GET/flights/{id}JWT
PATCH/flights/{id}JWT
DELETE/flights/{id}JWT

Local development requirements

  • Python 3.11+
  • PostgreSQL (local or remote)
  • uv or pip
  • Docker (optional, for container builds)
  • Azure AD app registration (for JWT-protected endpoints)
# Install dependencies and run
uv sync
uvicorn main:app --reload --host 0.0.0.0 --port 8080

Interactive documentation becomes available at http://localhost:8080/docs.