Below is a production-ready FastAPI template similar to what many startups use.
It focuses
on clean architecture, scalability, and maintainability. If you build projects with this
structure, recruiters will recognize it as professional backend engineering practice.
1. Production Tech Stack
Common stack used by startups:
FastAPI – backend framework
PostgreSQL – relational database
Redis – caching / background jobs
Docker – containerization
Nginx – reverse proxy
Amazon Web Services – cloud hosting
2. Production Folder Structure
Startups usually separate API, business logic, and database layers.
fastapi-production-template
│
├── app
│ ├── api
│ │ └── routes
│ │ ├── [Link]
│ │ ├── [Link]
│ │ └── [Link]
│ │
│ ├── core
│ │ ├── [Link]
│ │ └── [Link]
│ │
│ ├── db
│ │ ├── [Link]
│ │ └── [Link]
│ │
│ ├── models
│ │ └── [Link]
│ │
│ ├── schemas
│ │ └── [Link]
│ │
│ ├── services
│ │ └── user_service.py
│ │
│ └── [Link]
│
├── tests
├── Dockerfile
├── [Link]
├── [Link]
└── [Link]
This separation is called layered architecture.
3. Example FastAPI Entry Point
app/[Link]
from fastapi import FastAPI
from [Link] import users
app = FastAPI(title="Production FastAPI")
app.include_router([Link])
@[Link]("/")
def root():
return {"message": "API running"}
4. Configuration Management
Environment variables handled centrally.
app/core/[Link]
from pydantic import BaseSettings
class Settings(BaseSettings):
DATABASE_URL: str
SECRET_KEY: str
settings = Settings()
5. Database Setup
Using SQLAlchemy with PostgreSQL.
app/db/[Link]
from sqlalchemy import create_engine
from [Link] import sessionmaker
from [Link] import settings
engine = create_engine(settings.DATABASE_URL)
SessionLocal = sessionmaker(
autocommit=False,
autoflush=False,
bind=engine
)
6. User Model Example
app/models/[Link]
from sqlalchemy import Column, Integer, String
from [Link] import Base
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
email = Column(String, unique=True)
password = Column(String)
7. API Route Example
app/api/routes/[Link]
from fastapi import APIRouter
router = APIRouter(prefix="/users")
@[Link]("/")
def get_users():
return {"users": []}
8. Docker Setup
Dockerfile
FROM python:3.11
WORKDIR /app
COPY [Link] .
RUN pip install -r [Link]
COPY ./app /app
CMD ["uvicorn","main:app","--host","[Link]","--port","8000"]
Run:
docker build -t fastapi-app .
docker run -p 8000:8000 fastapi-app
9. Docker Compose (Production)
Run API + database together.
version: "3"
services:
api:
build: .
ports:
- "8000:8000"
depends_on:
- db
db:
image: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: app
10. Production Deployment Architecture
Client
↓
Nginx
↓
FastAPI (Docker)
↓
Redis Cache
↓
PostgreSQL
11. Production Features Startups Expect
Add these to make the template industry-level:
JWT authentication
OAuth login
rate limiting
Redis caching
background workers
logging
monitoring
Tools often added:
Celery for background jobs
Prometheus + Grafana monitoring
GitHub Actions for CI/CD
12. What Makes This Template Valuable
This structure demonstrates:
✔ clean architecture
✔ scalable backend design
✔ microservice-ready structure
✔ production deployment readiness
These are exactly the skills expected in mid-level backend engineers.
💡 Tip for your GitHub:
Create a repository like:
fastapi-production-template
Then build multiple projects using this template.
Recruiters immediately see professional engineering practices.