Lightweight Python project scaffold with:
- environment configuration via
pydantic-settings - SQLAlchemy database base/session wiring
- Docker-ready runtime image
- Python
3.12 pydantic/pydantic-settingssqlalchemy+psycopgalembic(dependency included)
.
├── app/
│ ├── constants/
│ ├── dependencies.py
│ ├── events/
│ ├── exceptions/
│ ├── models/
│ ├── schemas/
│ ├── services/
│ ├── tasks/
│ └── utils/
├── config/
│ ├── app.py
│ └── database.py
├── main.py
├── requirements.txt
└── Dockerfile
- Python 3.12+
pip- Docker (optional)
- PostgreSQL (if using
config/database.py)
-
Create a virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Configure environment:
cp .env.example .env
-
Run the app:
python main.py
Current .env.example contains:
APP_NAME=APP_NAME
APP_ENV=local
LOG_LEVEL=INFOconfig/database.py also expects these DB values:
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=app
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_SCHEMA=publicIf you plan to use DB utilities, add these variables to .env and define matching fields in config/app.py (Settings class).
Build image:
docker build -t python-boilerplate .Run container:
docker run --rm --env-file .env python-boilerplateThe container entrypoint runs:
python main.pymain.pyis currently empty; add your application entrypoint there.alembicis installed but migration config/files are not scaffolded yet.