finds.dev

testdrivenio/fastapi-sqlmodel-alembic

Sample FastAPI project that uses async SQLAlchemy, SQLModel, Postgres, Alembic, and Docker.

View on GitHub

★ 562PythonMITupdated Aug 2023

// the take

A minimal starter showing how to wire FastAPI with async SQLAlchemy, SQLModel, Alembic migrations, and Docker Compose. It's a tutorial companion repo for a testdriven.io blog post, not a production template. Good for developers who want a working skeleton before reading the full article.

Async SQLAlchemy setup is done correctly — using `AsyncSession` and `create_async_engine` rather than bolting async onto a sync engine. Alembic is properly configured with `run_migrations_online` using the async engine pattern, which trips people up. Docker Compose wires Postgres and the app together cleanly with a single build step. SQLModel's dual-use models (ORM + Pydantic validation) are demonstrated without overcomplicating the example.

Last touched August 2023 — SQLModel and FastAPI have both moved significantly since then, and this predates FastAPI's `Annotated` dependency injection style and SQLModel 0.0.14+ changes. The project is a single-file app with one model; there is no project structure guidance for anything beyond toy scale. No tests whatsoever, which is ironic given the testdriven.io branding. Three duplicate migration files in versions/ suggest the repo itself was developed sloppily.

We read the README, the directory tree and a key source file in June 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
562
Forks
93
Language
Python
License
MIT
Last commit
26 Aug 2023

// nearby

If fastapi-sqlmodel-alembic isn't quite it.

All repos →