Production-ready Telegram Mini App template. Ships a Litestar REST API (served by Granian) and an aiogram 3 Telegram bot with shared PostgreSQL storage, Alembic migrations, Dishka DI, and Fluent i18n.
Requirements: Python 3.13+, uv, Docker, just (optional but recommended)
# For local development (API + bot)
cp config-example.yaml config.yaml
# For running tests (points to the test database)
cp config-example.yaml config-local.yamlEdit both files and set bot_token, admin_ids, bot_username, and auth.secret_key.
cp .env.example .env.env controls Docker Compose variables (application name, Postgres credentials, ports, API_WORKERS). The defaults in .env.example match config-example.yaml, so no changes are needed for a first run.
uv venv
uv syncpre-commit installHooks run ruff check --fix, ruff format, and a security-only ruff pass on every commit.
docker compose -f docker-compose-test.yml up -d
uv run pytest -n auto -ss -vv --maxfail=1
docker compose -f docker-compose-test.yml down -v
# or
just testCoverage threshold is 90%.
docker compose up -d
# or
just upuv run alembic upgrade headuv run granian src.presentation.api.app:create_app --factory --port 8080 --interface asgi --log --access-log --reload
# or
just apiListens on http://localhost:8080.
uv run python -m src.presentation.bot.main
# or
just botcp config-example.yaml config-prod.yaml
# Edit config-prod.yaml with production valuesdocker compose -f docker-compose.prod.yml up -dThis starts:
- Postgres (no exposed port)
- Alembic migration runner (one-shot, runs before app starts)
- Telegram bot
- API server (host port 8080)
docker compose -f docker-compose.prod.yml logs -fdocker compose -f docker-compose.prod.yml downuv run ruff format src tests
uv run ruff check src tests --fix
# or
just lintuv run ty check src/
# or
just ty