- Source code:
src/— key packages:api/,handler/,models/,whatsapp/,utils/,config/. - Application entrypoint:
app/main.py(starts FastAPI, wiring DB, WhatsApp client). - Migrations:
migrations/withalembic.ini. - Tests are colocated with code:
src/**/test_*.py(e.g.,src/whatsapp/test_jid.py). - Extras:
notebooks/,data/.
- Install deps:
uv sync --all-extras --active(Python 3.13). - Lint/format:
ruff checkandruff format. - Type check:
pyright. - Run tests:
pytest -qorpytest --cov=src --cov-report=xml. - Run API locally:
uv run python app/main.py(reads.envin repo root). Alt:uvicorn app.main:app --reload. - Docker stack:
docker compose up -d(services:postgres,whatsapp,web-server).
- Python style: 4‑space indent, f-strings, type hints for public functions, absolute imports from
src(e.g.,from handler.router import Router). - Naming: modules/functions
snake_case; classesCamelCase; constantsUPPER_CASE. - Keep functions small and async-friendly where I/O is involved.
- Enforce with
ruff(style/format) andpyright(types) before committing.
- Frameworks:
pytest,pytest-asyncio,pytest-cov. - Test files:
test_*.pynext to modules (e.g.,src/handler/test_router.py). - Use
AsyncMock/fixtures (seesrc/test_utils/) and avoid real network/DB calls. - Coverage:
pytest --cov=src(XML written tocoverage.xml).
- Use Conventional Commits when possible:
feat:,fix:,chore:, etc. Example:fix: avoid quote reply loop. - PRs must include: clear description, linked issues, validation steps, and notes on DB migrations if applicable. Attach logs/screenshots where useful.
- Gating: ensure
ruff,pyright, andpytestpass locally.
- Secrets live in
.env(root). Required keys include:DB_URI,WHATSAPP_HOST,VOYAGE_API_KEY,ANTHROPIC_API_KEY,LOGFIRE_TOKEN. - DB migrations:
alembic upgrade head; create new migration withalembic revision --autogenerate -m "<msg>".