Skip to content

PurdueDM/fastapi-deploy-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Deploy Template

Production-ready FastAPI scaffold with Docker, PostgreSQL, and CI/CD — deploy in minutes.

Python FastAPI License

Features

  • FastAPI async REST API with Pydantic v2 validation
  • PostgreSQL persistence via SQLAlchemy 2.0 async engine
  • Multi-stage Docker build — final image < 120 MB
  • docker-compose one-command local stack (app + db)
  • GitHub Actions CI — lint (ruff), test (pytest), container build
  • Health endpoint with DB connectivity check
  • 12-Factor config via environment variables

Architecture

┌─────────────┐      ┌─────────────┐
│   Client     │─────▶│  FastAPI     │
└─────────────┘      │  (uvicorn)  │
                     └──────┬──────┘
                            │ async
                     ┌──────▼──────┐
                     │ PostgreSQL  │
                     │   (pg 16)   │
                     └─────────────┘

Quickstart

Docker (recommended)

git clone https://github.com/gridguard-ai/fastapi-deploy-template.git
cd fastapi-deploy-template
docker compose up --build
# API available at http://localhost:8000
# Docs at       http://localhost:8000/docs

Local

python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
export DATABASE_URL="postgresql+asyncpg://postgres:postgres@localhost:5432/app"
uvicorn app.main:app --reload

API Endpoints

Method Path Description
GET /health Liveness + DB check
POST /tasks Create a task
GET /tasks List all tasks
GET /tasks/{id} Get task by ID
PUT /tasks/{id} Update a task
DELETE /tasks/{id} Delete a task

Configuration

Variable Default Description
DATABASE_URL postgresql+asyncpg://postgres:postgres@db:5432/app Async DB connection string
APP_ENV production Environment name

License

MIT


Support This Project

If this helped you, consider supporting GridGuard's open-source work:

Ko-fi Gumroad GitHub Sponsors

Every tip fuels more free tools and templates.

About

Production-ready FastAPI scaffold with Docker, PostgreSQL, and GitHub Actions CI/CD

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors