📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials FastAPI FastAPI Project Structure

FastAPI Project Structure

4 min read
Production FastAPI layout: routers, schemas, crud, models, services, alembic, tests, Dockerfile.

Production Structure

my_api/
├── app/
│   ├── main.py            # FastAPI app + lifespan
│   ├── config.py          # Pydantic BaseSettings
│   ├── dependencies.py    # get_db, get_current_user
│   ├── database.py        # Engine, SessionLocal, Base
│   ├── models/            # SQLAlchemy models
│   ├── schemas/           # Pydantic schemas
│   ├── crud/              # DB operations
│   ├── routers/           # APIRouter modules
│   └── services/          # Business logic
├── alembic/               # Migrations
├── tests/
├── Dockerfile
└── .env