Frontend Contracts
The backend KnowledgeApp.Contracts project and generated OpenAPI document are the source of truth for HTTP DTOs, request models, response models, and error envelopes. The generated TypeScript file is committed so contract changes are visible in reviews.
Frontend contract types live in:
apps/desktop/src/shared/contracts/generated.tsfor rawopenapi-typescriptoutput.apps/desktop/src/shared/contracts/index.tsfor public schema and operation helpers.apps/desktop/src/entities/*/model/types.tsfor compatibility aliases and UI-only models.apps/desktop/src/shared/api/*.tsfor typed API slices.
Rules:
- Manual HTTP DTO mirrors are prohibited. Use
Schema,OperationQuery,OperationPath,OperationJsonBody, orOperationData. - Entity modules may preserve existing public names through aliases to
@shared/contracts. - UI-only state such as drafts, form state, loading state, filter chips, and view models remains local.
- Frontend API calls must go through named API slices such as
documentsApi,chatsApi,notesApi, orsettingsApi. - Frontend code must not import backend projects or Domain entities.
- Shared API slices must not import entities.
- Pages should not call API slices directly. Feature hooks own API orchestration and pages only compose feature public APIs.
- LocalApi error envelopes should be surfaced through
ApiErrorand shared error UI.
Run task -t .config/task/Taskfile.yml api:generate after changing backend contracts or endpoint metadata. The task writes its temporary OpenAPI document to artifacts/openapi/frontend/local-api-v1.json, then regenerates generated.ts. CI runs the same cross-platform command through check:api-contracts and fails when the committed TypeScript contracts have drift.