A production-ready, high-performance architectural foundation for FastAPI applications.
This isn't just a "Hello World" example. It is a deeply thought-out structure incorporating Clean Architecture, RBAC (Role-Based Access Control), Redis-backed Session Management, and Async SQLAlchemy.
It focuses on Security-First principles, using Argon2 for hashing, JWT rotation, and strict context management.
- Modern Auth: JWT-based authentication with Refresh Token rotation.
- RBAC System: Fine-grained Role-Based Access Control (Users -> Roles -> Permissions).
- Redis Integration: Fast session storage and response caching using
fastapi-cache2. - State Management: Uses Python
ContextVarsto access User/Request state globally without "Prop Drilling." - Rate Limiting: Built-in protection via
slowapi. - Database: Async PostgreSQL integration with
SQLAlchemy 2.0andAlembicmigrations. - Developer Experience: Fully typed with Pydantic V2 and basic logging.
This project uses uv, the ultra-fast Python package manager. for local https development you can use mkcert
First, install uv if you haven't already, then set up the environment:
# Clone the repository
git clone https://github.com/Jas-creator-31/fastapi-starter-template
cd fastapi-starter-template
# Create a virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -r requirements.txt