← Back to all products
$39
FastAPI Starter Template
Production FastAPI project with auth, database, testing, Docker, CI/CD, and OpenAPI documentation.
DockerJSONTOMLMarkdownPythonYAMLFastAPIRedisPostgreSQL
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 19 files
fastapi-starter-template/
├── LICENSE
├── README.md
├── alembic/
│ └── env.py
├── app/
│ ├── api/
│ │ ├── deps.py
│ │ └── v1/
│ │ ├── auth.py
│ │ └── users.py
│ ├── config.py
│ ├── core/
│ │ ├── database.py
│ │ └── security.py
│ ├── main.py
│ ├── middleware/
│ │ └── rate_limit.py
│ ├── models/
│ │ ├── base.py
│ │ └── user.py
│ └── schemas/
│ └── user.py
├── docker/
│ ├── Dockerfile
│ └── docker-compose.yml
├── pyproject.toml
└── tests/
├── conftest.py
└── test_auth.py
📖 Documentation Preview README excerpt
FastAPI Starter Template
Production-ready FastAPI boilerplate with async SQLAlchemy, JWT auth, and Docker — ship your API in hours, not weeks.
[](https://www.python.org/downloads/)
[](https://fastapi.tiangolo.com)
[](LICENSE)
What You Get
- Async-first architecture — SQLAlchemy 2.0 async engine, async session management
- JWT authentication — Register, login, refresh tokens, role-based access control
- User management — Full CRUD with pagination, soft-delete, and admin routes
- Rate limiting — In-memory sliding window middleware (swap for Redis in production)
- Database migrations — Alembic with async support, auto-generate from models
- Docker ready — Multi-stage Dockerfile, docker-compose with PostgreSQL & Redis
- Test suite — AsyncClient fixtures, auth helpers, database isolation
- Clean project structure — Separation of concerns with dependency injection
File Tree
fastapi-starter-template/
├── app/
│ ├── main.py # FastAPI app entry point
│ ├── config.py # Pydantic settings from env vars
│ ├── models/
│ │ ├── base.py # SQLAlchemy Base + mixins
│ │ └── user.py # User model
│ ├── schemas/
│ │ └── user.py # Pydantic request/response schemas
│ ├── api/
│ │ ├── deps.py # Shared dependencies
│ │ └── v1/
│ │ ├── auth.py # Auth routes (register/login/refresh)
│ │ └── users.py # User CRUD routes
│ ├── core/
│ │ ├── security.py # JWT + password hashing
│ │ └── database.py # Async engine + session
│ └── middleware/
│ └── rate_limit.py # Rate limiting middleware
├── tests/
│ ├── conftest.py # Test fixtures
│ └── test_auth.py # Auth endpoint tests
├── docker/
│ ├── Dockerfile # Multi-stage build
│ └── docker-compose.yml # Full stack
├── alembic/
│ └── env.py # Async migration env
└── pyproject.toml # Project configuration
Getting Started
1. Clone and configure
cp .env.example .env
*... continues with setup instructions, usage examples, and more.*
📄 Code Sample .py preview
app/main.py"""
FastAPI Starter Template — Application Entry Point
Production-ready FastAPI application with lifespan management,
CORS configuration, global exception handling, and versioned routing.
"""
from __future__ import annotations
import logging
from contextlib import asynccontextmanager
from typing import AsyncIterator
from fastapi import FastAPI, Request, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from app.api.v1 import auth, users
from app.config import settings
from app.core.database import engine
from app.middleware.rate_limit import RateLimitMiddleware
logger = logging.getLogger(__name__)
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
"""Manage application startup and shutdown lifecycle."""
logger.info("Starting %s v%s", settings.APP_NAME, settings.APP_VERSION)
logger.info("Environment: %s", settings.ENVIRONMENT)
logger.info("Database: %s", settings.DATABASE_URL.split("@")[-1] if "@" in settings.DATABASE_URL else "configured")
yield
logger.info("Shutting down %s", settings.APP_NAME)
await engine.dispose()
logger.info("Database connections closed")
def create_app() -> FastAPI:
"""Create and configure the FastAPI application instance."""
app = FastAPI(