https://github.com/longaodai/fastapi_codebase
🚀 FastAPI clean architecture boilerplate with Repository Pattern, Redis integration, Dockerized setup, and production-ready project structure.
https://github.com/longaodai/fastapi_codebase
boilerplate clean-architecture-fastapi codebase fastap-docker fastapi fastapi-codebase fastapi-repository python
Last synced: 2 months ago
JSON representation
🚀 FastAPI clean architecture boilerplate with Repository Pattern, Redis integration, Dockerized setup, and production-ready project structure.
- Host: GitHub
- URL: https://github.com/longaodai/fastapi_codebase
- Owner: longaodai
- Created: 2025-09-21T12:36:28.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-09-25T13:37:03.000Z (6 months ago)
- Last Synced: 2025-09-25T15:35:27.819Z (6 months ago)
- Topics: boilerplate, clean-architecture-fastapi, codebase, fastap-docker, fastapi, fastapi-codebase, fastapi-repository, python
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI Codebase
This repository provides a production-ready FastAPI codebase following Repository Pattern principles.
It includes centralized exception handling, modular API versioning, Redis integration, and Docker support for seamless deployment.
Perfect as a scalable starting point for building modern backend services with Python.
## Tech Stack
- **FastAPI** - Modern web framework
- **SQLAlchemy** - ORM
- **Alembic** - Database migration tool
- **MySQL** - Database
- **Pydantic** - Data validation
- **Docker** - Containerization
## Project Structure
```
fastapi_codebase/
├── app/
│ ├── api/
│ │ └── v1/
│ │ └── coupon.py
│ ├── models/
│ │ └── coupon.py
│ ├── repositories/
│ │ └── coupon_repository.py
│ ├── schemas/
│ │ └── coupon.py
│ └── services/
│ └── coupon_service.py
├── core/
│ ├── config.py
│ ├── dependence.py
│ ├── response.py
│ └── database.py
├── main.py
├── requirements.txt
├── Dockerfile
├── docker-compose.yml
└── .env
```
## Installation & Setup
### With Docker (Recommended)
```bash
# Clone repository
git clone https://github.com/longaodai/fastapi_codebase.git
cd fastapi_codebase
# Run with Docker Compose
docker-compose up -d
# API will be available at http://localhost:8000
```
### Local Installation
```bash
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Setup environment variables
cp .env.example .env
# Edit .env with your database configuration
# Run migrations
alembic upgrade head
# Start development server
uvicorn main:app --reload
```
## Database Migration
```bash
# Create new migration
alembic revision -m "create coupons table"
# Apply migrations
alembic upgrade head
# Rollback migration
alembic downgrade -1
```
## API Documentation
After running the application, visit:
- **Swagger UI**: http://localhost:8000/docs
- **ReDoc**: http://localhost:8000/redoc
## Environment Configuration
Create a `.env` file by copy from .env.example