https://github.com/ahmadalsharef994/fastapi-postgres-boilerplate
Production-Ready Starter Template, FastAPI + PostgreSQL boilerplate with Docker, GitHub Actions, and clean architecture.
https://github.com/ahmadalsharef994/fastapi-postgres-boilerplate
api backend boilerplate docker fastapi guthub-actions postgres python template
Last synced: 2 months ago
JSON representation
Production-Ready Starter Template, FastAPI + PostgreSQL boilerplate with Docker, GitHub Actions, and clean architecture.
- Host: GitHub
- URL: https://github.com/ahmadalsharef994/fastapi-postgres-boilerplate
- Owner: ahmadalsharef994
- Created: 2025-04-13T11:31:56.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-13T18:48:05.000Z (about 1 year ago)
- Last Synced: 2025-04-13T19:44:40.915Z (about 1 year ago)
- Topics: api, backend, boilerplate, docker, fastapi, guthub-actions, postgres, python, template
- Language: Python
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ FastAPI + PostgreSQL Boilerplate
A **production-ready starter template** for building FastAPI applications with PostgreSQL โ clean architecture, Docker Compose setup, and GitHub Actions CI included out of the box.
---
## โจ What's Included
- โ
**FastAPI** with async route handlers
- โ
**SQLAlchemy 2.0** ORM with PostgreSQL
- โ
**Alembic** for database migrations
- โ
**Docker + Docker Compose** โ one command to start everything
- โ
**GitHub Actions CI** โ runs tests on every push
- โ
**Dependency injection** โ clean, testable service layer
- โ
**Pydantic v2** request/response validation
- โ
**Auto-generated Swagger UI** at `/docs`
---
## ๐ Quick Start
```bash
git clone https://github.com/ahmadalsharef994/fastapi-postgres-boilerplate.git
cd fastapi-postgres-boilerplate
cd infra/docker
docker-compose up --build
```
API: `http://localhost:8000`
Swagger: `http://localhost:8000/docs`
### Without Docker
```bash
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
# Set up DB
alembic upgrade head
uvicorn app.main:app --reload
```
---
## ๐ Structure
```
app/
โโโ main.py # FastAPI app entry point
โโโ db/
โ โโโ base.py # SQLAlchemy base + session
โ โโโ models.py # ORM models
โโโ routes/ # API route handlers
โโโ schemas/ # Pydantic schemas
โโโ services/ # Business logic layer
โโโ dependencies.py # DI container
infra/
โโโ docker/
โโโ docker-compose.yml
.github/
โโโ workflows/ci.yml # GitHub Actions
```
---
## โ๏ธ Environment Variables
```env
DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/dbname
SECRET_KEY=your-secret-key
DEBUG=true
```
---
## ๐งช Testing
```bash
pytest tests/ -v --cov=app
```
---
## ๐ License
MIT โ Start building faster ๐ก