# Wundklar

Wound documentation for home-care nurses in Germany, built as a care-service Organization on top of the template.

Wundklar is the clinical product this repository ships. A nurse photographs the
wound with the app's own camera, does a structured T.I.M.E. assessment, follows
progress over time, runs the dressing plan, and sends a PDF/A report via KIM or
an encrypted link so the prescribing doctor can issue the next supply order.
The complete product package — Vision Board, PRD, flows, stories, ARD, screens
and tokens — lives under
[`docs/wundklar`](https://github.com/CarlosZiegler/wundklare/blob/main/docs/wundklar/HANDOFF.md).

The product rules that outrank every "how to code" convention are set in the
PRD and the ARD; every deviation from them is a dated
[decision record](/docs/adr).

## Shape [#shape]

A care service is a Better Auth Organization with the extra row
`care_service` and five care roles (owner/admin as PDL,
`wound_expert`, `nurse`, `aide`); `member` is read as `nurse`
([ADR-0015](/docs/adr/0015-care-service-roles-on-better-auth-organizations)).
Every clinical procedure, sync handler, key delivery, object path and job
runs through one authorization boundary that checks assurance, AVV,
[access state](/docs/features/wundklar-access-states), device, role and
patient scope
([ADR-0031](/docs/adr/0031-one-clinical-authorization-boundary)).

Clinical records are insert-only; a correction is a new version with a reason
([ADR-0028](/docs/adr/0028-immutable-clinical-records-and-privilege-matrix)).
Photos are born encrypted on the device under an envelope hierarchy
(KEK → ODK + OIK → per-object DEKs,
[ADR-0017](/docs/adr/0017-client-side-envelope-encryption-and-key-hierarchy))
and intimate full frames stay under a separate key opened only with a logged
reason
([ADR-0025](/docs/adr/0025-opaque-object-keys-and-staged-clinical-objects)).

## Where features live [#where-features-live]

- Mobile (bedside, offline-first):
  [`apps/mobile/src/app`](https://github.com/CarlosZiegler/wundklare/blob/main/apps/mobile/README.md)
  routes, `apps/mobile/src/features/<feature>/` folders, `platform/vault`
  and `platform/local-store` behind the interfaces of
  [ADR-0026](/docs/adr/0026-native-only-capabilities-behind-interfaces).
- Desktop (PDL cockpit, doctor portal):
  [`apps/web/src/routes/_auth/`](https://github.com/CarlosZiegler/wundklare/blob/main/apps/web/src/routes/__root.tsx)
  and the public [`r.$linkId`](https://github.com/CarlosZiegler/wundklare/blob/main/apps/web/src/routes/r.$linkId.tsx)
  portal.
- API and jobs:
  [`packages/api/src/features/`](https://github.com/CarlosZiegler/wundklare/blob/main/packages/api/src/features/sync/sync.service.ts)
  with the fixed feature shape of [ADR-0011](/docs/adr/0011-backend-feature-shape).
- Shared domain and copy guard:
  [`packages/clinical`](https://github.com/CarlosZiegler/wundklare/blob/main/packages/clinical/package.json);
  crypto:
  [`packages/crypto`](https://github.com/CarlosZiegler/wundklare/blob/main/packages/crypto/package.json);
  PDF/A engine:
  [`packages/report`](https://github.com/CarlosZiegler/wundklare/blob/main/packages/report/package.json);
  tokens:
  [`packages/tokens`](https://github.com/CarlosZiegler/wundklare/blob/main/packages/tokens/package.json).

## Guides [#guides]

- [Local harness](/docs/features/wundklar-harness) — one command per slot
  boots Postgres, MinIO, the API and Expo web with a demo seed.
- [Sync protocol](/docs/features/wundklar-sync) — the envelope, the ledger
  and the per-kind resolution rules.
- [Clinical trail](/docs/features/wundklar-trail) — the hash-chained,
  same-transaction trail and its daily verification.
- [Share links](/docs/features/wundklar-share-links) — the zero-knowledge
  path from the device to the doctor's browser.
- [Reports](/docs/features/wundklar-reports) — the PDF/A model, KIM
  delivery and the server-built reports.
- [MD and Art. 15 exports](/docs/features/wundklar-exports) — the audit
  package engine with checkpointed resume.
- [Access states](/docs/features/wundklar-access-states) — tariff, trial,
  read-only, cancellation and the active-wound grace.

## Status [#status]

The run-time state of v1 and the pending native and real-KIM items are tracked
in
[`docs/STATUS.md`](https://github.com/CarlosZiegler/wundklare/blob/main/docs/STATUS.md).
Deviations from the template conventions are listed in the decision records
0015–0033 of the [ADR index](/docs/adr).

