Geti Backend Development
For the full architecture reference (layered design, app/ layout, adding an endpoint end-to-end, library integration and job execution) read
application/backend/AGENTS.md.
Quick Start
- Work from
application/backend/. - Create or refresh the environment with
just venv --accelerator cpufor normal local work. - Switch to
cudaorxpuonly when the task depends on accelerator-specific behavior. - Start with
just lint, then run the narrowest relevant test target.
Workflow
- Keep the change inside the existing backend boundaries unless the task explicitly crosses into
library/orapplication/ui/. - Keep routers thin and move business logic into services or repositories that match the existing package structure.
- Generate a fresh OpenAPI spec when router or schema changes affect the API contract.
- Hand off to the $geti-openapi-sync skill after backend contract changes so the UI types stay aligned.
Architecture Reminders
- The request flow is layered:
app.api→app.services→app.repositories→app.db. Respect the import-linter contracts inpyproject.toml. - Keep
app.api.routersaboveapp.api.schemas, andapp.api.schemasaboveapp.api.dependencies. - Pydantic API schemas (
app/api/schemas/), domain models (app/models/), and SQLAlchemy ORM models (app/db/schema.py) are separate layers — never return raw ORM models from a router. - Schema changes require an Alembic migration under
app/alembic/versions/. - Long-running work (training, quantization, dataset import/export) runs
out-of-process via
app/core/jobs/and lazily-imported builders inapp/execution/; training calls into thegetitunelibrary. - Treat
run-server --cleanand_clean_dataas destructive helpers.
Verification
- Use
just lintfor Ruff, import-linter, and pyrefly checks. - Use
just test-unit -- tests/unit/...orjust test-unit -- -k <expr>for routine backend changes. - Use
just test-integration -- <pytest args>when the change crosses service, persistence, or API boundaries. - Use
just test-bdd -- <behave args>when behavior is covered by BDD specs. - Use
just gen-api-spec --output-path openapi-spec.jsonafter intentional API contract changes.
Coordination Notes
application/backenddepends on the local editable../../library. Validatelibrary/too when shared model or training behavior changes.- Prefer project
justtargets over custom shell commands so local work matches CI.