iam-abbas /
FastAPI-Production-Boilerplate
A scalable and production ready boilerplate for FastAPI
83/100 healthLoading repository data…
Akshat-Pandey16 / repository
A production-ready FastAPI boilerplate featuring async PostgreSQL, SQLAlchemy ORM, Alembic migrations, and comprehensive API documentation. Includes Docker support, environment-based configuration, CRUD operations, and professional project structure. Perfect foundation for building scalable REST APIs with modern Python practices.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A production-grade FastAPI starter, built around modern Python 3.13 idioms and the current best-of-breed toolchain.
Batteries included: async SQLAlchemy 2.0, Pydantic v2, structured logging, RFC 7807 errors, layered architecture, full test setup, multi-stage Docker, GitHub Actions, pre-commit, and
uvfor dependency management.
Annotated[..., Depends(...)] dependency idioms.Mapped[...] columns and asyncpg driver.pydantic-settings for environment-validated configuration.api → services → repositories → models — so business logic stays out of HTTP handlers./api/v1, ready to grow into without breaking clients.Selected from shared topics, language and repository description—not editorial ratings.
iam-abbas /
A scalable and production ready boilerplate for FastAPI
83/100 healthbakrianoo /
A production-ready FastAPI boilerplate application with a comprehensive set of features for modern web backend development.
69/100 healthakhil2308 /
/v2structlog, request IDs propagated via contextvars, JSON output in production.BaseRepository for CRUD plumbing, plus domain-specific repositories for richer queries.src/ layout, with auto-formatting hooks.uv for dependency resolution, locking, and a fast venv-less workflow.| Concern | Choice |
|---|---|
| Language | Python 3.13 |
| Web framework | FastAPI ≥ 0.115 |
| ASGI server | Uvicorn (standard) |
| ORM | SQLAlchemy 2.0 (async) |
| Database driver | asyncpg |
| Migrations | Alembic (async env) |
| Validation / settings | Pydantic v2 + pydantic-settings |
| Logging | structlog |
| Package manager | uv (replaces pip / poetry / pipenv) |
| Lint + format | Ruff |
| Type checker | mypy (strict mode) |
| Tests | pytest, pytest-asyncio, httpx |
| Container | Multi-stage Docker image on Python 3.13 |
fastapi-boilerplate/
├── .github/workflows/ci.yml # Lint, type check, test, Docker build
├── alembic/
│ ├── env.py # Async migration environment, src-aware
│ ├── script.py.mako # Modern Python 3.13 migration template
│ └── versions/ # Generated revision files
├── src/
│ └── app/
│ ├── main.py # FastAPI app factory + ASGI export
│ ├── api/
│ │ ├── deps.py # Reusable Annotated[Depends(...)] aliases
│ │ ├── router.py # Top-level /api router
│ │ └── v1/
│ │ ├── router.py # v1 sub-router aggregator
│ │ └── endpoints/ # health.py, users.py, …
│ ├── core/
│ │ ├── config.py # pydantic-settings Settings class
│ │ ├── logging.py # structlog configuration
│ │ ├── exceptions.py # AppException hierarchy
│ │ ├── exception_handlers.py # FastAPI handlers → ProblemDetail
│ │ ├── middleware.py # Request-id / access-log middleware
│ │ └── lifespan.py # Startup/shutdown lifecycle
│ ├── db/
│ │ ├── base.py # DeclarativeBase + naming convention
│ │ ├── mixins.py # TimestampMixin
│ │ └── session.py # Async engine + sessionmaker + get_session
│ ├── models/ # SQLAlchemy ORM models
│ ├── repositories/ # Data access (CRUD + queries)
│ ├── schemas/ # Pydantic v2 request/response models
│ └── services/ # Business logic
├── tests/
│ ├── conftest.py # AsyncClient + ephemeral DB fixtures
│ ├── unit/ # Fast, isolated tests
│ └── integration/ # End-to-end tests against the ASGI app
├── .env.example # Documented environment variables
├── .pre-commit-config.yaml
├── .python-version # 3.13
├── Dockerfile # Multi-stage build with uv
├── docker-compose.yml # API + Postgres with healthchecks
├── Makefile # Common developer commands
├── alembic.ini
├── pyproject.toml # Single source of truth for tooling
└── README.md
make setup.uv (any modern distro qualifies).git clone <your-repo-url>
cd fastapi-boilerplate
make setup # installs uv + Python 3.13, creates .env, starts Postgres, installs deps, runs migrations
make dev # auto-reload server on http://localhost:8000
make setup is idempotent — safe to re-run any time. Under the hood it composes these granular targets, each of which you can call on its own:
| Target | What it does |
|---|---|
setup-uv | Installs uv if missing, then pins Python 3.13 via uv python install 3.13. |
setup-env | Copies .env.example → .env if .env is absent. |
install | uv sync --all-extras — resolves and installs everything into .venv. |
setup-db | Starts the Postgres service via docker compose up -d db. |
wait-db | Polls pg_isready until the container is accepting connections. |
migrate | alembic upgrade head. |
reset | Destructive. Wipes the Postgres volume and re-runs setup. |
doctor | Prints versions of uv, Python, Docker, and Make — useful for bug reports. |
git clone <your-repo-url>
cd fastapi-boilerplate
# 1. uv + Python
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.13
# 2. Dependencies
uv sync --all-extras
# 3. Environment
cp .env.example .env
$EDITOR .env
# 4. Postgres (or point .env at an existing instance)
docker compose up -d db
# 5. Migrations + run
uv run alembic upgrade head
uv run uvicorn app.main:app --reload
The API is now live at http://localhost:8000:
docker compose up --build
This starts Postgres and the API with healthchecks. Migrations run automatically against the configured DB the first time you make migrate inside the container, or you can bake the call into a startup script.
All settings are validated at startup by Settings. See .env.example for the documented list. Highlights:
| Variable | Default | Purpose |
|---|---|---|
ENVIRONMENT | local | Switches docs/reload defaults |
DEBUG | false | FastAPI debug mode |
LOG_LEVEL / LOG_JSON | INFO / false | Structlog level + JSON renderer toggle |
API_PREFIX | /api | Mounts the versioned router prefix |
CORS_ORIGINS | (empty) | Comma-separated list, or * |
DB_* | local Postgres defaults | Async DSN, pool sizing, timeouts |
SECRET_KEY | change me | For future auth / signing |
REQUEST_ID_HEADER | X-Request-ID | Header copied into structured logs |
local / development → /docs and /redoc enabled, full SQL echo opt-in.production → docs disabled, JSON logs recommended, generic 500 messages.test → used by the pytest fixtures; auto-skips DB connectivity check at startup.make install # uv sync --all-extras
make dev # uvicorn with --reload
make check # ruff format + ruff lint + mypy
make test # pytest
make test-cov # pytest with coverage
uv run pre-commit install
uv run pre-commit run --all-files
Hooks run the same ruff, ruff format, and mypy that CI runs, so green locally ⇒ green in CI.
Alembic is preconfigured for async PostgreSQL and the src/ layout.
make makemigration MSG="add posts table" # autogenerate from models
make migrate # apply migrations
make downgrade # roll back one revision
make db-revision # show current head
Migration scripts are auto-formatted with ruff via the post_write_hooks in alembic.ini. Migration files in alembic/versions/ are not committed by default — set up your own policy for your team.
Tests run against an in-memory SQLite database via aiosqlite, so the suite is fast and hermetic.
make test
make test-cov
uv run pytest tests/unit -m unit # unit tests only
uv run pytest tests/integration -m integration
The client fixture builds the FastAPI app with dependency_overrides[get_session] pointing at the test session, and drives it through httpx.AsyncClient + asgi-lifespan — no real network, full lifespan events.
All tooling is configured in pyproject.toml:
E, W, F, I, B, C4, UP, N, ASYNC, S, SIM, RUF, PL, PT, RET, PTH, TCH, …) plus formatting.CI fails on any of: format drift, lint findings, type errors, or test failures.
The included Dockerfile is a multi-stage build:
uv image to resolve dependencies into a .venv directory.python:3.13-slim-bookworm, non-root user, healthcheck against /api/v1/health.The accompanying `docker-compos
🚀 Production-grade FastAPI template • JWT auth • Rate limiting • Async PostgreSQL & Redis • OpenTelemetry observability (Prometheus, Grafana, Tempo) • Alembic • Docker • Gunicorn + Uvicorn • Async Ready • RFC-Compliant API Responses • Enterprise Security Patterns
kumarsonu676 /
A scalable FastAPI project template with async SQLAlchemy, PostgreSQL, and repository pattern implementation. Features JWT authentication, comprehensive error handling, and follows best practices for building production-ready APIs. Includes modular architecture, dependency injection, Pydantic validation, and Alembic migrations.
68/100 healthsodipto /
A batteries-included FastAPI starter template for building scalable, production-ready APIs
59/100 healthchris83254 /
🚀 Build a production-ready FastAPI app with clean architecture, JWT authentication, and PostgreSQL/SQLite support for efficient development.
65/100 health