FastAPI scaffold with health endpoint, structured logging, env-driven config, pytest suite, ruff/mypy, and GitHub Actions CI.
- Python 3.12 (3.11 supported)
- FastAPI 0.115, Uvicorn
- Pydantic v2 + pydantic-settings
- pytest + httpx
- Ruff (lint + format), mypy
- GitHub Actions CI, Dependabot
- Multi-stage Dockerfile (non-root user, healthcheck)
python-backend/
├── app/
│ ├── main.py
│ ├── core/
│ │ ├── config.py
│ │ └── logging.py
│ └── api/v1/
│ ├── router.py
│ └── endpoints/health.py
├── tests/test_health.py
├── .github/
│ ├── workflows/ci.yml
│ ├── ISSUE_TEMPLATE/
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── dependabot.yml
├── requirements.txt
├── requirements-dev.txt
├── pytest.ini
├── ruff.toml
├── .env.example
├── Dockerfile
├── CHANGELOG.md
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
└── SECURITY.md
git clone https://github.com/mohit-tanwar-dev/python-backend.git
cd python-backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements-dev.txt
cp .env.example .env # optional — defaults work
uvicorn app.main:app --reloadEndpoints:
GET /— service infoGET /health— health checkGET /api/v1/health— versioned health checkGET /docs— Swagger UIGET /redoc— ReDoc
Docker:
docker build -t python-backend:latest .
docker run --rm -p 8000:8000 --env-file .env python-backend:latestSettings loaded from environment variables or .env. All have defaults.
| Variable | Default | Description |
|---|---|---|
APP_NAME |
python-backend |
Service name |
APP_ENV |
local |
local / dev / prod |
APP_DEBUG |
true |
Verbose logs and error details |
APP_HOST |
0.0.0.0 |
Bind host |
APP_PORT |
8000 |
Bind port |
APP_LOG_LEVEL |
INFO |
DEBUG / INFO / WARNING / ERROR |
pytest -v
ruff check .
ruff format --check .
mypy app testsCI runs all of the above on Python 3.11 and 3.12.
See CONTRIBUTING.md. Fork, branch from main, open a PR.
See CHANGELOG.md.
See SECURITY.md.
MIT — see LICENSE.