GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - modern-python/fastapi-sqlalchemy-template: Dockerized FastAPI + SQLAlchemy 2 + PostgreSQL app template with DI

BranchesTags
Open more actions menu

Latest commit

 

History

218 Commits
218 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
app
app
 
 
docs/agents
docs/agents
 
 
migrations
migrations
 
 
tests
tests
 
 
.copier-answers.yml
.copier-answers.yml
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
CLAUDE.md
CLAUDE.md
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
alembic.ini
alembic.ini
 
 
docker-compose.yml
docker-compose.yml
 
 
justfile
justfile
 
 
pyproject.toml
pyproject.toml
 
 
readme.md
readme.md
 
 
uv.lock
uv.lock
 
 

Repository files navigation

fastapi-sqlalchemy-template

Coverage CI License GitHub stars uv Ruff ty

Description

Dockerized FastAPI, SQLAlchemy 2 and PostgreSQL app template with DI.

Key features

  • tests on pytest with automatic rollback after each test case
  • IOC (Inversion of Control) container built on modern-di
  • Observability tools integration built on lite-bootstrap
  • Linting and formatting with ruff, type checking with ty
  • Alembic for DB migrations

Authentication is intentionally omitted: pick the scheme that fits your project and add it as a FastAPI dependency.

After git clone run

just --list

Tracing in production

Setting OPENTELEMETRY_ENDPOINT turns tracing on, and by default every request is traced. In a benchmark of GET /api/decks/{id}/, that cut throughput by about 40%. Sampling with the standard OpenTelemetry variables brings that down to about 20%:

OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.1

This keeps one trace in ten, and follows the caller's decision when a request arrives with a trace context. Errors still reach Sentry when SENTRY_DSN is set.

The template also turns off the ASGI send and receive spans (opentelemetry_exclude_spans in app/settings.py), so each request records its server span and database spans only. With every request traced, that raised throughput by 5 to 8% in the same benchmark. Remove the setting if you need those spans.

Links

  • License

If this project saves you time, consider giving it a star on GitHub.

Part of modern-python

Browse the full list of templates and libraries in modern-python; the org profile has the categorized index.

About

Dockerized FastAPI + SQLAlchemy 2 + PostgreSQL app template with DI

modern-python.org

Topics

advanced-alchemyalembicasyncioboilerplatedidockerfastapiioc-containerjustfilemodern-dipostgresqlpythonsqlalchemytemplate

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

219 stars

Watchers

3 watching

Forks

30 forks
Report repository

Sponsor this project

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.