# yunmin311/anatomical-symptom-interface architecture

> Architecture diagram of the GitHub repository yunmin311/anatomical-symptom-interface, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yunmin311/anatomical-symptom-interface
- Repository: https://github.com/yunmin311/anatomical-symptom-interface

## Overview

The product turns a person's description of pain into a confirmed anatomical location, a region-specific interview, deterministic safety flags, and a longitudinal pre-visit record. The web session coordinates the user flow; the server exposes API operations and persists episodes. The README documents offline grounding with optional model-backed candidate suggestions. Some wiring is inferred only where explicitly documented; unsampled internals are represented by their exact enclosing paths.

Main entry points: [`packages/server/src/app.ts`](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/app.ts) (HTTP API), [`apps/web/src/App.tsx`](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/App.tsx) (Session interface), [`apps/web/src/state/session.ts`](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/state/session.ts) (Session state), [`packages/server/src/orchestrator/index.ts`](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/orchestrator/index.ts) (Localisation orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["Session interface<br/>[App.tsx]"]
  node_session["Session state<br/>[session.ts]"]
  node_bodymap["Body map<br/>[BodyMap.tsx]"]
  node_viewer["2D anatomy adapter<br/>[svg2d.ts]"]
  node_interviewui["Interview panel<br/>[InterviewPanel.tsx]"]
  node_safetyui["Safety banner<br/>[SafetyBanner.tsx]"]
  node_summaryui["Summary panel<br/>[SummaryPanel.tsx]"]
  node_historyui["History panel<br/>[HistoryPanel.tsx]"]
end

subgraph group_api["API and orchestration"]
  node_server["HTTP API<br/>[app.ts]"]
  node_orchestrator["Localisation orchestrator<br/>[index.ts]"]
end

subgraph group_domain["Clinical domain"]
  node_anatomy["Anatomy vocabulary<br/>[anatomy.ts]"]
  node_grounding["Text grounding<br/>[grounding.ts]"]
  node_interview["Interview engine<br/>[engine.ts]"]
  node_redflags["Safety rules<br/>[redflags.ts]"]
  node_summary["Summary generation<br/>[summary.ts]"]
  node_provenance["Field provenance<br/>[provenance.ts]"]
end

subgraph group_records["Local records"]
  node_store["Episode store<br/>[store.ts]"]
  node_sqlite[("Local SQLite<br/>[client.ts]")]
end

node_user(("Person"))
node_anthropic["Anthropic model"]

node_user -->|"describes symptoms"| node_app
node_app -->|"dispatches actions"| node_session
node_app -->|"renders map"| node_bodymap
node_app -->|"renders questions"| node_interviewui
node_app -->|"renders flags"| node_safetyui
node_app -->|"renders summary"| node_summaryui
node_app -->|"renders history"| node_historyui
node_bodymap -->|"issues commands"| node_viewer
node_session -->|"updates viewer"| node_viewer
node_session -->|"requests API"| node_server
node_session -->|"evaluates record"| node_redflags
node_session -->|"provides session state"| node_interviewui
node_interviewui -->|"selects questions"| node_interview
node_server -->|"localises text"| node_orchestrator
node_server -->|"grounds preview"| node_grounding
node_server -->|"reads and writes episodes"| node_store
node_server -->|"builds summary"| node_summary
node_server -->|"counts rules"| node_redflags
node_orchestrator -->|"runs offline grounding"| node_grounding
node_orchestrator -->|"validates candidates"| node_anatomy
node_orchestrator -.->|"requests suggestions"| node_anthropic
node_store -->|"reads and writes"| node_sqlite
node_interview -->|"resolves structures"| node_anatomy
node_summary -->|"uses field attribution"| node_provenance
node_redflags -->|"returns safety flags"| node_server
node_store -->|"returns episode data"| node_server

click node_app "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/App.tsx"
click node_session "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/state/session.ts"
click node_bodymap "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/anatomy/BodyMap.tsx"
click node_viewer "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/anatomy/svg2d.ts"
click node_interviewui "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/ui/InterviewPanel.tsx"
click node_safetyui "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/ui/SafetyBanner.tsx"
click node_summaryui "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/ui/SummaryPanel.tsx"
click node_historyui "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/ui/HistoryPanel.tsx"
click node_server "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/app.ts"
click node_orchestrator "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/orchestrator/index.ts"
click node_anatomy "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/anatomy.ts"
click node_grounding "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/grounding.ts"
click node_interview "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/interview/engine.ts"
click node_redflags "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/rules/redflags.ts"
click node_summary "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/summary.ts"
click node_provenance "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/provenance.ts"
click node_store "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/db/store.ts"
click node_sqlite "https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/db/client.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_session,node_bodymap,node_viewer,node_interviewui,node_safetyui,node_summaryui,node_historyui toneBlue
class node_server,node_orchestrator toneAmber
class node_anatomy,node_grounding,node_interview,node_redflags,node_summary,node_provenance toneMint
class node_store,node_sqlite toneRose
class node_user,node_anthropic toneIndigo
```

## Components

### Web experience

- [Session interface](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Session state](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/state/session.ts): `apps/web/src/state/session.ts`
- [Body map](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/anatomy/BodyMap.tsx): `apps/web/src/anatomy/BodyMap.tsx`
- [2D anatomy adapter](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/anatomy/svg2d.ts): `apps/web/src/anatomy/svg2d.ts`
- [Interview panel](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/ui/InterviewPanel.tsx): `apps/web/src/ui/InterviewPanel.tsx`
- [Safety banner](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/ui/SafetyBanner.tsx): `apps/web/src/ui/SafetyBanner.tsx`
- [Summary panel](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/ui/SummaryPanel.tsx): `apps/web/src/ui/SummaryPanel.tsx`
- [History panel](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/apps/web/src/ui/HistoryPanel.tsx): `apps/web/src/ui/HistoryPanel.tsx`

### API and orchestration

- [HTTP API](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/app.ts): `packages/server/src/app.ts`
- [Localisation orchestrator](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/orchestrator/index.ts): `packages/server/src/orchestrator/index.ts`

### Clinical domain

- [Anatomy vocabulary](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/anatomy.ts): `packages/shared/src/anatomy.ts`
- [Text grounding](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/grounding.ts): `packages/shared/src/grounding.ts`
- [Interview engine](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/interview/engine.ts): `packages/shared/src/interview/engine.ts`
- [Safety rules](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/rules/redflags.ts): `packages/shared/src/rules/redflags.ts`
- [Summary generation](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/summary.ts): `packages/shared/src/summary.ts`
- [Field provenance](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/shared/src/provenance.ts): `packages/shared/src/provenance.ts`

### Local records

- [Episode store](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/db/store.ts): `packages/server/src/db/store.ts`
- [Local SQLite](https://github.com/yunmin311/anatomical-symptom-interface/blob/main/packages/server/src/db/client.ts): `packages/server/src/db/client.ts`

### Other components

- **Person**
- **Anthropic model**

## Connections

- Person → Session interface: describes symptoms
- Session interface → Session state: dispatches actions
- Session interface → Body map: renders map
- Session interface → Interview panel: renders questions
- Session interface → Safety banner: renders flags
- Session interface → Summary panel: renders summary
- Session interface → History panel: renders history
- Body map → 2D anatomy adapter: issues commands
- Session state → 2D anatomy adapter: updates viewer
- Session state → HTTP API: requests API
- Session state → Safety rules: evaluates record
- Session state → Interview panel: provides session state
- Interview panel → Interview engine: selects questions
- HTTP API → Localisation orchestrator: localises text
- HTTP API → Text grounding: grounds preview
- HTTP API → Episode store: reads and writes episodes
- HTTP API → Summary generation: builds summary
- HTTP API → Safety rules: counts rules
- Localisation orchestrator → Text grounding: runs offline grounding
- Localisation orchestrator → Anatomy vocabulary: validates candidates
- Localisation orchestrator → Anthropic model: requests suggestions
- Episode store → Local SQLite: reads and writes
- Interview engine → Anatomy vocabulary: resolves structures
- Summary generation → Field provenance: uses field attribution
- Safety rules → HTTP API: returns safety flags
- Episode store → HTTP API: returns episode data
