// the find
teamhide/fastapi-boilerplate
FastAPI boilerplate for real world production
A FastAPI project template wired up with async SQLAlchemy, Alembic, Redis caching, Celery, and a hexagonal architecture layout. It's aimed at teams who want a non-trivial starting point rather than the usual 'main.py with one endpoint' boilerplate. The architecture opinion is strong — ports-and-adapters all the way down.
The session/transaction handling is genuinely thoughtful: a context-var-based session that threads through requests without passing it explicitly, and the `@Transactional()` decorator that handles commits so endpoint code never calls `session.commit()` directly. The `asyncio.gather()` caveat in the README (use `session_factory`, not the global session) shows the author actually ran into this problem rather than just copying SQLAlchemy docs. The cache layer is clean — prefix/tag invalidation, pluggable backend and key builder, all as decorators. Test coverage spans middlewares, permissions, repository adapters, and service layer with real separation between unit and integration tests.
The hexagonal structure looks correct on paper but creates a 6-folder-deep path (`app/user/adapter/input/api/v1/user.py`) for a single CRUD endpoint — it will slow down any developer who isn't already sold on ports-and-adapters before they open the repo. The `CurrentUser` implementation decodes the JWT in middleware and stashes it on `request.user`, which means there's no dependency injection path for auth — you can't swap it per-route or test it without mocking the request object. Celery is listed as a feature but the task directory is empty (`celery_task/tasks/__init__.py` only), so you're wiring up a broker for nothing out of the box. There's no rate limiting, no request ID propagation, and no structured logging — things that are typically the first things you add in a real production service.