# ckwan/note_loop architecture

> Architecture diagram of the GitHub repository ckwan/note_loop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ckwan/note_loop
- Repository: https://github.com/ckwan/note_loop

## Overview

NoteLoop is a therapist-facing SOAP progress-note application. A therapist selects a scheduled session, drafts a note from rough notes, edits or requests wording suggestions, reviews and compares the text, then signs; signing locks the note and starts claim processing. The README also documents a parallel pre-sign review workflow and batch resubmission. Those capabilities are represented from documentation where implementation excerpts were unavailable; no review-specific source file appears in the supplied tree. The review and integrations are therefore shown with documented, dashed links where source evidence is absent.

Main entry points: [`web/components/NoteWorkspace.tsx`](https://github.com/ckwan/note_loop/blob/main/web/components/NoteWorkspace.tsx) (Note workspace), [`backend/app/routes.py`](https://github.com/ckwan/note_loop/blob/main/backend/app/routes.py) (FastAPI routes), [`backend/app/services/notes.py`](https://github.com/ckwan/note_loop/blob/main/backend/app/services/notes.py) (Note service), [`backend/app/llm.py`](https://github.com/ckwan/note_loop/blob/main/backend/app/llm.py) (LLM provider and validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Therapist workspace"]
  node_schedule["Session schedule<br/>[ScheduleList.tsx]"]
  node_workspace["Note workspace<br/>[NoteWorkspace.tsx]"]
  node_editor["SOAP editor<br/>[NoteEditor.tsx]"]
  node_compare["Draft comparison<br/>[DiffView.tsx]"]
  node_auditui["Audit trail view<br/>[AuditTrail.tsx]"]
  node_claimui["Claim status view<br/>[ClaimStatus.tsx]"]
  node_status["Note status badge<br/>[StatusBadge.tsx]"]
  node_api_client["Web API client<br/>[api.ts]"]
end

subgraph group_api["API and note services"]
  node_api["FastAPI routes<br/>[routes.py]"]
  node_notes["Note service<br/>[notes.py]"]
  node_llm["LLM provider and validation<br/>[llm.py]"]
  node_schemas["Request and note schemas<br/>[schemas.py]"]
  node_signing["Idempotent signing<br/>[idempotency.py]"]
  node_ratelimit["Request rate limits<br/>[ratelimit.py]"]
  node_review["Pre-sign review"]
end

subgraph group_data["Persistent state"]
  node_redis[("Redis controls<br/>[redis_client.py]")]
  node_postgres[("Postgres records<br/>[models.py]")]
end

subgraph group_claims["Claim workflows"]
  node_temporal["Temporal workflows<br/>[workflows.py]"]
  node_starter["Workflow starter<br/>[starter.py]"]
  node_activities["Claim activities<br/>[activities.py]"]
  node_worker["Workflow worker<br/>[worker.py]"]
end

subgraph group_integrations["External services"]
  node_payer["Simulated payer"]
  node_llm_service["LLM service"]
end

node_therapist(("Therapist"))

node_therapist -->|"opens sessions"| node_schedule
node_schedule -.->|"loads schedule"| node_api_client
node_workspace -->|"requests note actions"| node_api_client
node_workspace -->|"renders"| node_editor
node_workspace -->|"renders"| node_compare
node_workspace -->|"renders"| node_auditui
node_workspace -->|"renders"| node_claimui
node_workspace -->|"renders"| node_status
node_api_client -.->|"sends API requests"| node_api
node_api -->|"delegates note actions"| node_notes
node_api -->|"runs sign once"| node_signing
node_api -->|"checks request limits"| node_ratelimit
node_ratelimit -->|"uses counters"| node_redis
node_notes -->|"requests and parses text"| node_llm
node_llm -->|"validates SOAP reply"| node_schemas
node_llm -.->|"calls model"| node_llm_service
node_notes -.->|"reads and writes notes"| node_postgres
node_signing -->|"performs sign transaction"| node_notes
node_therapist -.->|"reviews proposed fixes"| node_review
node_api -.->|"runs pre-sign review"| node_review
node_review -.->|"requests reviewers and fixes"| node_llm
node_review -.->|"saves checkpoints"| node_postgres
node_api -->|"starts signed or batch run"| node_starter
node_starter -->|"starts workflow"| node_temporal
node_worker -->|"registers workflows"| node_temporal
node_temporal -->|"executes activities"| node_activities
node_activities -->|"updates claims and audit"| node_postgres
node_activities -->|"submits claim"| node_payer
node_temporal -->|"fetches failed claims"| node_activities

click node_schedule "https://github.com/ckwan/note_loop/blob/main/web/components/ScheduleList.tsx"
click node_workspace "https://github.com/ckwan/note_loop/blob/main/web/components/NoteWorkspace.tsx"
click node_editor "https://github.com/ckwan/note_loop/blob/main/web/components/NoteEditor.tsx"
click node_compare "https://github.com/ckwan/note_loop/blob/main/web/components/DiffView.tsx"
click node_auditui "https://github.com/ckwan/note_loop/blob/main/web/components/AuditTrail.tsx"
click node_claimui "https://github.com/ckwan/note_loop/blob/main/web/components/ClaimStatus.tsx"
click node_status "https://github.com/ckwan/note_loop/blob/main/web/components/StatusBadge.tsx"
click node_api_client "https://github.com/ckwan/note_loop/blob/main/web/lib/api.ts"
click node_api "https://github.com/ckwan/note_loop/blob/main/backend/app/routes.py"
click node_notes "https://github.com/ckwan/note_loop/blob/main/backend/app/services/notes.py"
click node_llm "https://github.com/ckwan/note_loop/blob/main/backend/app/llm.py"
click node_schemas "https://github.com/ckwan/note_loop/blob/main/backend/app/schemas.py"
click node_signing "https://github.com/ckwan/note_loop/blob/main/backend/app/idempotency.py"
click node_redis "https://github.com/ckwan/note_loop/blob/main/backend/app/redis_client.py"
click node_ratelimit "https://github.com/ckwan/note_loop/blob/main/backend/app/ratelimit.py"
click node_postgres "https://github.com/ckwan/note_loop/blob/main/backend/app/models.py"
click node_review "https://github.com/ckwan/note_loop/tree/main/backend/app"
click node_temporal "https://github.com/ckwan/note_loop/blob/main/backend/app/workflows/workflows.py"
click node_starter "https://github.com/ckwan/note_loop/blob/main/backend/app/workflows/starter.py"
click node_activities "https://github.com/ckwan/note_loop/blob/main/backend/app/workflows/activities.py"
click node_worker "https://github.com/ckwan/note_loop/blob/main/backend/app/worker.py"

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_schedule,node_workspace,node_editor,node_compare,node_auditui,node_claimui,node_status,node_api_client toneBlue
class node_api,node_notes,node_llm,node_schemas,node_signing,node_ratelimit,node_review toneAmber
class node_redis,node_postgres,node_therapist toneMint
class node_temporal,node_starter,node_activities,node_worker toneRose
class node_payer,node_llm_service toneIndigo
```

## Components

### Therapist workspace

- [Session schedule](https://github.com/ckwan/note_loop/blob/main/web/components/ScheduleList.tsx): `web/components/ScheduleList.tsx`
- [Note workspace](https://github.com/ckwan/note_loop/blob/main/web/components/NoteWorkspace.tsx): `web/components/NoteWorkspace.tsx`
- [SOAP editor](https://github.com/ckwan/note_loop/blob/main/web/components/NoteEditor.tsx): `web/components/NoteEditor.tsx`
- [Draft comparison](https://github.com/ckwan/note_loop/blob/main/web/components/DiffView.tsx): `web/components/DiffView.tsx`
- [Audit trail view](https://github.com/ckwan/note_loop/blob/main/web/components/AuditTrail.tsx): `web/components/AuditTrail.tsx`
- [Claim status view](https://github.com/ckwan/note_loop/blob/main/web/components/ClaimStatus.tsx): `web/components/ClaimStatus.tsx`
- [Note status badge](https://github.com/ckwan/note_loop/blob/main/web/components/StatusBadge.tsx): `web/components/StatusBadge.tsx`
- [Web API client](https://github.com/ckwan/note_loop/blob/main/web/lib/api.ts): `web/lib/api.ts`

### API and note services

- [FastAPI routes](https://github.com/ckwan/note_loop/blob/main/backend/app/routes.py): `backend/app/routes.py`
- [Note service](https://github.com/ckwan/note_loop/blob/main/backend/app/services/notes.py): `backend/app/services/notes.py`
- [LLM provider and validation](https://github.com/ckwan/note_loop/blob/main/backend/app/llm.py): `backend/app/llm.py`
- [Request and note schemas](https://github.com/ckwan/note_loop/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [Idempotent signing](https://github.com/ckwan/note_loop/blob/main/backend/app/idempotency.py): `backend/app/idempotency.py`
- [Request rate limits](https://github.com/ckwan/note_loop/blob/main/backend/app/ratelimit.py): `backend/app/ratelimit.py`
- [Pre-sign review](https://github.com/ckwan/note_loop/tree/main/backend/app): `backend/app`

### Persistent state

- [Redis controls](https://github.com/ckwan/note_loop/blob/main/backend/app/redis_client.py): `backend/app/redis_client.py`
- [Postgres records](https://github.com/ckwan/note_loop/blob/main/backend/app/models.py): `backend/app/models.py`

### Claim workflows

- [Temporal workflows](https://github.com/ckwan/note_loop/blob/main/backend/app/workflows/workflows.py): `backend/app/workflows/workflows.py`
- [Workflow starter](https://github.com/ckwan/note_loop/blob/main/backend/app/workflows/starter.py): `backend/app/workflows/starter.py`
- [Claim activities](https://github.com/ckwan/note_loop/blob/main/backend/app/workflows/activities.py): `backend/app/workflows/activities.py`
- [Workflow worker](https://github.com/ckwan/note_loop/blob/main/backend/app/worker.py): `backend/app/worker.py`

### External services

- **Simulated payer**
- **LLM service**

### Other components

- **Therapist**

## Connections

- Therapist → Session schedule: opens sessions (evidence: `README.md`)
- Session schedule → Web API client: loads schedule
- Note workspace → Web API client: requests note actions (evidence: `web/components/NoteWorkspace.tsx`)
- Note workspace → SOAP editor: renders (evidence: `web/components/NoteWorkspace.tsx`)
- Note workspace → Draft comparison: renders (evidence: `web/components/NoteWorkspace.tsx`)
- Note workspace → Audit trail view: renders (evidence: `web/components/NoteWorkspace.tsx`)
- Note workspace → Claim status view: renders (evidence: `web/components/NoteWorkspace.tsx`)
- Note workspace → Note status badge: renders (evidence: `web/components/NoteWorkspace.tsx`)
- Web API client → FastAPI routes: sends API requests
- FastAPI routes → Note service: delegates note actions (evidence: `backend/app/routes.py`)
- FastAPI routes → Idempotent signing: runs sign once (evidence: `backend/app/routes.py`)
- FastAPI routes → Request rate limits: checks request limits (evidence: `backend/app/routes.py`)
- Request rate limits → Redis controls: uses counters (evidence: `backend/app/routes.py`)
- Note service → LLM provider and validation: requests and parses text (evidence: `backend/app/services/notes.py`)
- LLM provider and validation → Request and note schemas: validates SOAP reply (evidence: `backend/app/llm.py`)
- LLM provider and validation → LLM service: calls model
- Note service → Postgres records: reads and writes notes (evidence: `backend/app/services/notes.py`)
- Idempotent signing → Note service: performs sign transaction (evidence: `backend/app/idempotency.py`)
- Therapist → Pre-sign review: reviews proposed fixes (evidence: `README.md`)
- FastAPI routes → Pre-sign review: runs pre-sign review (evidence: `README.md`)
- Pre-sign review → LLM provider and validation: requests reviewers and fixes (evidence: `README.md`)
- Pre-sign review → Postgres records: saves checkpoints (evidence: `README.md`)
- FastAPI routes → Workflow starter: starts signed or batch run (evidence: `backend/app/routes.py`)
- Workflow starter → Temporal workflows: starts workflow (evidence: `backend/app/workflows/starter.py`)
- Workflow worker → Temporal workflows: registers workflows (evidence: `backend/app/worker.py`)
- Temporal workflows → Claim activities: executes activities (evidence: `backend/app/workflows/workflows.py`)
- Claim activities → Postgres records: updates claims and audit (evidence: `backend/app/workflows/activities.py`)
- Claim activities → Simulated payer: submits claim (evidence: `backend/app/workflows/activities.py`)
- Temporal workflows → Claim activities: fetches failed claims (evidence: `backend/app/workflows/workflows.py`)
