A minimal — yet production-ready — FastAPI project template to kickstart your next API. Clean, async-first, and ready for real-world deployment.
This starter kit provides a lightweight, well-structured FastAPI template with common features you actually need in production: auth (login/register/refresh-token/me), rate limiting (middleware + decorator), CORS, structured logging with loguru, repository & service layers, dependency injection (FastAPI), Pydantic settings, JWT security, PostgreSQL (SQLAlchemy + Alembic), and fully asynchronous I/O.
Note: current repository state — there are no tests yet, the project uses ruff for linting, and pre-commit hooks are not configured yet. The project layout differs slightly from some templates; see the actual
treein the repo for exact structure.
Built to be opinionated but flexible — plug in other databases or caching layers later.
- Authentication: register, login, refresh token, /me endpoint
- Security: JWT-based auth, password hashing
- Rate limiting: middleware and decorator options
- CORS support and configurable settings
- Structured logging via loguru
- Repository & service pattern for clean separation of concerns
- Dependency Injection using FastAPI's
Depends - Config management with Pydantic Settings (
BaseSettings) - Async-first: SQLAlchemy (async), all endpoints and DB access are async
- Migrations: Alembic configured for async SQLAlchemy
- Database: PostgreSQL out of the box (easy to swap)
- Optional: Docker and
docker-composefor quick local/dev environments
git clone https://github.com/azizjon-aliev/fastapi-starter.git && cd fastapi-startercp .env.example .env
# edit .env (DB, secrets, etc.)docker compose up --build
# open http://0.0.0.0:8000/docs or /redoc# create venv (using uv tool in this repo)
uv venv; source .venv/bin/activate
uv sync # install deps
uv run alembic upgrade head
uv run uvicorn app.main:app --reload.
├── LICENSE
├── README.md
├── alembic.ini
├── app
│ ├── Dockerfile
│ ├── __init__.py
│ ├── api
│ │ ├── dependencies.py
│ │ ├── middlewares.py
│ │ └── v1
│ │ ├── auth_routes.py
│ │ └── user_routes.py
│ ├── core
│ │ └── config.py
│ ├── db
│ │ ├── migrations
│ │ │ ├── env.py
│ │ │ └── versions
│ │ │ └── a3285f904186_add_user_table.py
│ │ ├── models
│ │ │ └── user_model.py
│ │ └── session.py
│ ├── factories.py
│ ├── main.py
│ ├── repositories
│ │ └── user_repository.py
│ ├── schemas
│ │ └── auth_schema.py
│ ├── services
│ │ ├── auth_service.py
│ │ └── security_service.py
│ └── utils.py
├── docker-compose.yml
├── docs
├── logs
├── pyproject.toml
└── uv.lock
Tip: migrations are located under
app/db/migrations, Alembic config sits at project root (alembic.ini).
- Swagger UI:
/docs - Redoc:
/redoc
Both are enabled by default for local and containerized environments.
All runtime configuration is handled via environment variables using Pydantic BaseSettings. Keep secrets out of source control and use .env only for local/dev. In production prefer secret managers (Vault, AWS Secrets Manager, etc.).
Currently there are no tests shipped with the template. If you want, I can add:
- a basic
pytestsetup with unit tests for services/repositories - lightweight integration tests that spin up the app with
TestClientand a test DB - GitHub Actions workflow to run tests on PRs
Say which one you want and I’ll scaffold it.
- Linter: ruff (already in the project)
- No
pre-commitconfigured yet — recommended to add for consistent commits uv— local helper tool included in this repo (venv, run commands, sync deps)
This starter is designed to be modular. Planned generator options (coming soon):
- Database choices:
sqlite3|postgres|mysql|mongodb - Cache:
memory|redis|memcached - Auth providers: builtin JWT | OAuth (Google, GitHub)
- Task queue: none |
celery|dramatiq
When scaffolding a new project from the template, you'll be able to choose desired stacks and get a ready-to-run codebase.
- Interactive project generator (choose DB, cache, auth, etc.)
- Add optional Celery/RabbitMQ scaffolding
- More integration tests and CI workflows
- First-class support for multi-database templates
Contributions welcome! If you want to help:
- Fork the repo
- Create a feature branch
- Open a PR with a clear description
If you'd like, I can add pre-commit config, initial tests, or CI pipeline — tell me what to scaffold.
Maintained by Azizjon — PRs, issues, ideas are welcome.
Thanks goes to these wonderful people (emoji key):
Azizjon Aliev 💻 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!

