A FastAPI project scaffolded for growth: versioned API routes, centralized settings, and a test suite from day one.
app/
main.py # FastAPI app factory, middleware, top-level routes
core/
config.py # Settings (env-driven, cached)
api/
v1/
router.py # Aggregates all v1 endpoint routers
endpoints/
hello.py # GET /api/v1/hello
tests/
test_hello.py
docker/
Dockerfile # Production image
Dockerfile.dev # Development image (hot reload)
docker-compose.yml # Runs the production image
docker-compose.dev.yml # Runs the dev image with live reload
Add new features as a new module under app/api/v1/endpoints/, then register its router in app/api/v1/router.py. When a v2 is needed, add app/api/v1 alongside a new app/api/v2 and mount both in app/main.py.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
cp .env.example .envuvicorn app.main:app --reloadVisit http://127.0.0.1:8000/docs for the interactive API docs.
pytestThe project is fully containerized — see docker/README.md for details. All commands run from the project root.
Production:
docker compose -f docker/docker-compose.yml up --buildDevelopment (hot reload, mounts app/ and tests/):
docker compose -f docker/docker-compose.dev.yml up --buildBoth serve the API at http://localhost:8000 (docs at /docs, health check at /health). Requires a .env file at the project root (copy from .env.example).
To stop and remove containers:
docker compose -f docker/docker-compose.yml down