Loading repository data…
Loading repository data…
sodipto / repository
A batteries-included FastAPI starter template for building scalable, production-ready APIs
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 batteries-included FastAPI starter template for building scalable, production-ready APIs
Stop reinventing the wheel. Start building features that matter.
Features • Quick Start • Documentation • Contributing
Building a production-ready API from scratch is time-consuming. You need authentication, authorization, database setup, caching, background jobs, email services, logging, and more—before writing a single line of business logic.
This boilerplate gives you all of that out of the box, so you can focus on what makes your application unique.
| Category | Features |
|---|---|
| 🔐 Authentication | JWT access/refresh tokens, email verification, password reset |
| 🛡️ Authorization | Role-based access control (RBAC) with granular permissions |
| PostgreSQL & SQL Server support, async SQLAlchemy 2.0, Alembic migrations |
| ⚡ Caching | In-memory or Redis with automatic cache invalidation |
| Async SMTP with Jinja2 templates |
| 📋 Background Jobs | APScheduler for scheduled tasks |
| 📝 Audit Logging | Track all data changes with user context |
| 🚦 Rate Limiting | Per-endpoint configurable limits |
| 📁 File Storage | AWS S3 and MinIO support with presigned URLs |
| 📊 Logging | Structured logging with Seq integration |
| 🧪 Testing | pytest with async support, fixtures, and test utilities |
| 🐳 Docker | Production-ready Docker & Docker Compose setup |
| Layer | Technology |
|---|---|
| Framework | FastAPI with async/await |
| Database | PostgreSQL or SQL Server |
| ORM | SQLAlchemy 2.0 (async) |
| Migrations | Alembic |
| Authentication | python-jose (JWT) |
| Validation | Pydantic v2 |
| DI Container | dependency-injector |
| Caching | Redis / In-memory |
| aiosmtplib + Jinja2 | |
| Background Jobs | APScheduler |
| Testing | pytest + pytest-asyncio |
| Logging | Python logging + Seq |
1. Clone the repository
git clone https://github.com/sodipto/fastapi-starter-boilerplate.git
cd fastapi-starter-boilerplate
2. Create virtual environment
# Windows
python -m venv .venv
.venv\Scripts\activate
# Linux/macOS
python3 -m venv .venv
source .venv/bin/activate
3. Install dependencies
pip install -r requirements.txt
4. Configure environment
cp .env.development .env.development
Edit .env.development with your settings:
ENV=development
DATABASE_ENABLED=True
DATABASE_PROVIDER=postgresql
DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/your_database
SECRET_KEY=your-secret-key-min-32-characters
5. Run database migrations
alembic upgrade head
6. Start the server
uvicorn app.main:app --reload
7. Open API docs
Navigate to http://localhost:8000/docs
fastapi-starter-boilerplate/
├── app/
│ ├── api/
│ │ └── endpoints/
│ │ └── v1/ # Versioned API endpoints
│ │ ├── auth.py # Authentication routes
│ │ ├── user.py # User management
│ │ ├── role.py # Role management
│ │ └── ...
│ ├── core/
│ │ ├── config.py # Application settings
│ │ ├── container.py # Dependency injection container
│ │ ├── database/ # Database configuration & sessions
│ │ ├── middlewares/ # Custom middlewares
│ │ ├── rbac/ # Role-based access control
│ │ └── seeders/ # Database seeders
│ ├── models/ # SQLAlchemy ORM models
│ ├── repositories/ # Data access layer
│ ├── schema/ # Pydantic request/response schemas
│ │ ├── request/
│ │ └── response/
│ ├── services/ # Business logic layer
│ ├── jobs/ # Background job definitions
│ ├── templates/
│ │ └── emails/ # Jinja2 email templates
│ └── utils/ # Utility functions
├── alembic/ # Database migrations
├── docs/ # Extended documentation
├── tests/ # Test suite
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker image definition
├── .env.development # Development environment variables
├── .env.production # Production environment variables
├── .env.staging # Staging environment variables
└── requirements.txt # Python dependencies
| Method | Endpoint | Description |
|---|---|---|
POST | /api/v1/auth/signup | Register new user |
POST | /api/v1/auth/login | Authenticate user |
POST | /api/v1/auth/refresh-token | Refresh access token |
POST | /api/v1/auth/confirm-email | Confirm email address |
POST | /api/v1/auth/forgot-password | Request password reset |
POST | /api/v1/auth/reset-password | Reset password |
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/profile | Get current user profile |
PUT | /api/v1/profile | Update current user profile |
PUT | /api/v1/profile/password | Change password |
| Method | Endpoint | Description | Permission |
|---|---|---|---|
GET | /api/v1/users | Search users with pagination | users.search |
POST | /api/v1/users | Create new user | users.create |
GET | /api/v1/users/{id} | Get user by ID | users.view |
PUT | /api/v1/users/{id} | Update user | users.update |
DELETE | /api/v1/users/{id} | Delete user | users.delete |
GET | /api/v1/users/{id}/roles | Get user roles | users.view |
PATCH | /api/v1/users/{id}/status | Update user status | users.update |
| Method | Endpoint | Description | Permission |
|---|---|---|---|
GET | /api/v1/roles/permissions | Get all available permissions | — |
GET | /api/v1/roles/search | Search roles with pagination | roles.search |
POST | /api/v1/roles | Create new role | roles.create |
GET | /api/v1/roles/{id} | Get role by ID | roles.view |
PUT | /api/v1/roles/{id} | Update role | roles.update |
DELETE | /api/v1/roles/{id} | Delete role | roles.delete |
📖 See Swagger UI at
/docsfor complete API documentation.
| Variable | Description | Default |
|---|---|---|
ENV | Environment (development, production) | development |
SECRET_KEY | JWT signing key (min 32 chars) | Required |
DATABASE_URL | Database connection string | Required |
DATABASE_PROVIDER | postgresql or mssql | postgresql |
DATABASE_ENABLED | Enable database connection | False |
| Variable | Description | Default |
|---|---|---|
ACCESS_TOKEN_EXPIRE_MINUTES | Access token TTL | 15 |
REFRESH_TOKEN_EXPIRE_DAYS | Refresh token TTL | 7 |
REQUIRE_EMAIL_CONFIRMED_ACCOUNT | Require email verification | True |
| Variable | Description | Default |
|---|---|---|
CACHE_TYPE | memory or redis | memory |
REDIS_URL | Redis connection string | redis://localhost:6379 |
RATE_LIMIT_ENABLED | Enable rate limiting | True |
RATE_LIMIT_REQUESTS | Max requests per window | 100 |
| Variable | Description | Default |
|---|---|---|
MAIL_HOST | SMTP server | smtp.gmail.com |
MAIL_PORT | SMTP port | 587 |
MAIL_USERNAME | SMTP username | Required |
MAIL_PASSWORD | SMTP password | Required |
MAIL_FROM_EMAIL | Sender email | Required |
| Variable | Description | Default |
|---|---|---|
STORAGE_PROVIDER | aws or minio | aws |
S3_BUCKET_NAME | S3 bucket name | — |
MINIO_ENDPOINT | MinIO server URL | — |
| Variable | Description | Default |
|---|---|---|
LOG_LEVEL | Logging level | INFO |
SEQ_ENABLED | Enable Seq logging | False |
AUDIT_ENABLED | Enable audit logging | True |
📄 See
.env.developmentfor the complete list of configuration options.
# Start all services (app, PostgreSQL, Redis)
docker-compose up -d
# View logs
docker-compose logs -f app
# Stop services
docker-compose down
# Build image
docker build -t fastapi-boilerplate .
# Run container
docker run -p 8000:8000 --env-file .env.production fastapi-boilerplate
# Development server with hot reload
uvicorn app.main:app --reload
# Production server
uvicorn app.main:app --host 0.0.0.0 --port 8000
# Database migrations
alembic upgrade head # Apply all migrations
alembic revision --autogenerate -m "description" # Create migration
alembic downgrade -1 # Rollback last migration
alembic history # View migration history
| Topic | Description |
|---|---|
| Architecture | System design and patterns |
| REST API Conventions | API design standards |
| Authentication | JWT and security |
| Database | Multi-database setup |
| RBAC | Permissions and roles |
| Email Service | Email configuration |
| Cache | Caching strategies |
| Background Jobs | Scheduled tasks |
| Logging | Structured logging |
| Audit Logs | Change tracking |
| Testing | Test setup |
| Storage | File storage |
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')