Guidance for the Kayman backend. See the repo-root CLAUDE.md for cross-cutting context (toolchain, one-time setup, docker, end-to-end request flow).
- Python 3.12
- FastAPI
- SQLModel / SQLAlchemy
- Alembic
- PostgreSQL
- Managed with
uv
Run from the repo root. For the complete list of available tasks and their usage, see .agents/rules/tasks.md. Those are the only tasks that exist: don't invent task names or usages.
Run a single test: cd backend && uv run pytest kayman/tests/path/to/test_x.py::test_name.
Layered FastAPI app:
main.py: app factory. Mounts all routers under/api, then mounts the built frontend (backend/static→ symlink tofrontend/dist) as an SPA fallback at/.core/:config.py(pydantic-settings, readsinstance/*.envviamise.*.toml) anddb.py(engine/session).routers/: HTTP layer.routers/__init__.pyregisters every router and its OpenAPI tag. Each file exports<name>_routerand atagdict.crud/: SQL persistence (one module per aggregate: account, currency, event, event_entry, transaction).logics/: business logic that composes multiple CRUD calls (account, event, transaction).schemas/: SQLModel table models AND pydantic request/response models in the same modules. Seeschemas/README.mdfor the dbdiagram link, and.agents/rules/backend/schemas.mdfor theBase/table/Create/Read/Updateclass conventions.schemas/api_models.pyholds shared API wrappers.openapi.py+util.py: customoperationIdgeneration and aKustomJSONResponseusingsimplejsonfor Decimal-safe encoding. Decimals are first-class throughout (high-precision currency).tests/usesfactory-boy(seetests/factories/) andconftest.pyfixtures.test:backendinjects a dummyPOSTGRES_PASSWORDso settings instantiates without a running DB.
Migrations live in backend/alembic/. Always add a migration for schema changes (uv run alembic revision --autogenerate -m "...", then review the generated file before committing).
- All Python tooling must be prefixed with
uv run(e.g.uv run pytest,uv run alembic ...,uv run mypy ...). Thebackend/scripts/*andmisetasks already do this. - mypy runs in
strictmode (excludesalembicandkayman/tests). - Ruff is configured in
pyproject.toml; pre-commit runsruff --fix+ruff-formaton every commit.