Deploy FastAPI - PostgreSQL
A comprehensive FastAPI and PostgreSQL template.
Just deployed
/var/lib/postgresql/data
Fullstack-FastAPI
Just deployed
Overview
The most complete FastAPI + PostgreSQL template on Railway — fully async, production-ready, and built with modern Python best practices. Skip weeks of boilerplate and start building your API in minutes.
Whether you're prototyping a side project or scaffolding a production service, this template gives you everything you need out of the box: async database access, authenticated API docs, structured project layout, and one-click deployment.
Why This Template?
-
Fully async from top to bottom: Every endpoint, CRUD operation, and database call is non-blocking — no thread pool bottlenecks, no mixed sync/async confusion. Just clean, fast async Python.
-
SQLAlchemy 2.0 + PostgreSQL: Modern ORM with
select()queries,async_sessionmaker, and native UUID support. Auto-creates tables on startup, disposes connections on shutdown — zero manual setup. -
Authenticated API docs:
/docsand/redocare protected behind session-based login using a pure ASGI middleware (noBaseHTTPMiddlewareoverhead). Your API documentation stays private until you're ready to share. -
Production-grade performance: ORJSONResponse for fast serialization,
uvloop+httptoolsfor maximum throughput, GZIP compression, and a tuned thread pool (100 threads) for mixed workloads. -
Modern Python tooling: Managed with
uvandpyproject.toml— fast, reproducible installs with no dependency conflicts. Python 3.12, Pydantic v2, and cleansrc/project layout. -
Ready to extend: Clean separation between API endpoints, service layer, models, and schemas. Add new resources by following the existing
messagespattern — no guesswork needed.
What's Included
- FastAPI with async CRUD endpoints (Create, Read, Update, Delete)
- PostgreSQL with SQLAlchemy 2.0 async engine
- Pydantic v2 request/response validation
- Session-based authentication for API docs
- Environment-driven configuration (
.env.exampleprovided) - Docker multi-stage build
- Async test suite with pytest
- Locust load testing configuration
Quick Start
- Click Deploy to provision your FastAPI app + PostgreSQL database
- Set
USER_NAMEandPASSWORDenvironment variables for API doc access - Visit your deployment URL — your API is live
Learn More
Template Content
Fullstack-FastAPI
yuting1214/Fullstack-FastAPIPASSWORD
Password for accessing OpenAPI document.
USER_NAME
User name for accessing OpenAPI document.