# kltsai/next-is-you architecture

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

- Interactive diagram: https://gitdiagram.com/kltsai/next-is-you
- Repository: https://github.com/kltsai/next-is-you

## Overview

Next is you is a private, self-hosted hospital-queue watcher: an owner drafts a visit in the browser, the Worker stores it, scheduled checks read a hospital queue, and a reminder may be sent to invited LINE recipients when the patient is near. The README says real reads and sends remain held pending the owner’s pilot. The graph preserves setup, clinic-schedule validation, hospital adapters, queue interpretation, persistence, recipient controls, and notification decisions. Some backend connections are dashed because excerpts show module roles or imports, not the actual invoking code.

Main entry points: [`src/worker.py`](https://github.com/kltsai/next-is-you/blob/main/src/worker.py) (HTTP application), [`frontend/src/main.ts`](https://github.com/kltsai/next-is-you/blob/main/frontend/src/main.ts) (Organizer UI), [`src/next_is_you/scheduler.py`](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/scheduler.py) (Scheduled checks), [`src/next_is_you/hospital_registry.py`](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/hospital_registry.py) (Hospital registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_owner["Owner experience"]
  node_web["Organizer UI<br/>[main.ts]"]
  node_setup["Visit setup<br/>[setup-form.js]"]
  node_visitview["Visit projection"]
  node_visitpoll["Visit polling<br/>[visits-poller.js]"]
  node_consent["Recipient consent"]
end

subgraph group_service["Worker service"]
  node_api["Organizer API<br/>[organizer-api.js]"]
  node_worker["HTTP application<br/>[worker.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_scheduler["Scheduled checks<br/>[scheduler.py]"]
  node_persistence[("Visit persistence<br/>[persistence.py]")]
end

subgraph group_hospital["Hospital reading"]
  node_registry["Hospital registry"]
  node_schedulecheck["Schedule validation<br/>[schedule_check.py]"]
  node_readerworker["Schedule reader Worker"]
  node_readerclient["Reader adapter"]
  node_ntuh["NTUH queue reader<br/>[ntuh_reader.py]"]
  node_domain["Queue domain<br/>[domain.py]"]
end

subgraph group_notifications["Reminder delivery"]
  node_decision["Reminder decisions"]
  node_sendgate["Send gate<br/>[send_gate.py]"]
  node_paused["Send hold state<br/>[paused_service.py]"]
  node_line["LINE messaging<br/>[line_messaging.py]"]
  node_recipients["Recipient lifecycle"]
end

node_owner(("Owner"))

node_owner -->|"uses"| node_web
node_web -->|"renders"| node_setup
node_web -->|"calls"| node_api
node_api -.->|"requests"| node_worker
node_worker -.->|"authenticates"| node_auth
node_worker -.->|"stores visits"| node_persistence
node_worker -.->|"manages recipients"| node_recipients
node_worker -.->|"starts monitoring"| node_sendgate
node_scheduler -.->|"dispatches reads"| node_registry
node_registry -->|"delegates reads"| node_ntuh
node_registry -->|"provides schedule reader"| node_readerworker
node_readerclient -->|"calls RPC"| node_readerworker
node_schedulecheck -.->|"uses adapter"| node_readerclient
node_ntuh -.->|"returns observations"| node_domain
node_scheduler -.->|"loads visit state"| node_persistence
node_scheduler -.->|"evaluates reminders"| node_decision
node_scheduler -.->|"requests sends"| node_sendgate
node_sendgate -->|"checks hold"| node_paused
node_sendgate -.->|"sends messages"| node_line
node_web -->|"projects visits"| node_visitview
node_web -.->|"refreshes visits"| node_visitpoll
node_web -.->|"offers controls"| node_consent
node_worker -.->|"runs scheduled checks"| node_scheduler
node_scheduler -.->|"requests clinic schedule"| node_readerclient
node_worker -.->|"serves hospital capabilities"| node_registry

click node_web "https://github.com/kltsai/next-is-you/blob/main/frontend/src/main.ts"
click node_setup "https://github.com/kltsai/next-is-you/blob/main/frontend/src/setup-form.js"
click node_visitview "https://github.com/kltsai/next-is-you/blob/main/frontend/src/dashboard-projection.js"
click node_visitpoll "https://github.com/kltsai/next-is-you/blob/main/frontend/src/visits-poller.js"
click node_consent "https://github.com/kltsai/next-is-you/blob/main/frontend/src/recipient-consent.ts"
click node_api "https://github.com/kltsai/next-is-you/blob/main/frontend/src/organizer-api.js"
click node_worker "https://github.com/kltsai/next-is-you/blob/main/src/worker.py"
click node_auth "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/auth.py"
click node_registry "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/hospital_registry.py"
click node_schedulecheck "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/schedule_check.py"
click node_readerworker "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/schedule_reader_worker.py"
click node_readerclient "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/schedule_reader_client.py"
click node_ntuh "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/ntuh_reader.py"
click node_domain "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/domain.py"
click node_scheduler "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/scheduler.py"
click node_persistence "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/persistence.py"
click node_decision "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/reminder_decision.py"
click node_sendgate "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/send_gate.py"
click node_paused "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/paused_service.py"
click node_line "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/line_messaging.py"
click node_recipients "https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/recipient_lifecycle.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_web,node_setup,node_visitview,node_visitpoll,node_consent toneBlue
class node_api,node_worker,node_auth,node_scheduler,node_persistence toneAmber
class node_registry,node_schedulecheck,node_readerworker,node_readerclient,node_ntuh,node_domain toneMint
class node_decision,node_sendgate,node_paused,node_line,node_recipients toneRose
class node_owner toneIndigo
```

## Components

### Owner experience

- [Organizer UI](https://github.com/kltsai/next-is-you/blob/main/frontend/src/main.ts): `frontend/src/main.ts`
- [Visit setup](https://github.com/kltsai/next-is-you/blob/main/frontend/src/setup-form.js): `frontend/src/setup-form.js`
- [Visit projection](https://github.com/kltsai/next-is-you/blob/main/frontend/src/dashboard-projection.js): `frontend/src/dashboard-projection.js`
- [Visit polling](https://github.com/kltsai/next-is-you/blob/main/frontend/src/visits-poller.js): `frontend/src/visits-poller.js`
- [Recipient consent](https://github.com/kltsai/next-is-you/blob/main/frontend/src/recipient-consent.ts): `frontend/src/recipient-consent.ts`

### Worker service

- [Organizer API](https://github.com/kltsai/next-is-you/blob/main/frontend/src/organizer-api.js): `frontend/src/organizer-api.js`
- [HTTP application](https://github.com/kltsai/next-is-you/blob/main/src/worker.py): `src/worker.py`
- [Authentication](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/auth.py): `src/next_is_you/auth.py`
- [Scheduled checks](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/scheduler.py): `src/next_is_you/scheduler.py`
- [Visit persistence](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/persistence.py): `src/next_is_you/persistence.py`

### Hospital reading

- [Hospital registry](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/hospital_registry.py): `src/next_is_you/hospital_registry.py`
- [Schedule validation](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/schedule_check.py): `src/next_is_you/schedule_check.py`
- [Schedule reader Worker](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/schedule_reader_worker.py): `src/next_is_you/schedule_reader_worker.py`
- [Reader adapter](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/schedule_reader_client.py): `src/next_is_you/schedule_reader_client.py`
- [NTUH queue reader](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/ntuh_reader.py): `src/next_is_you/ntuh_reader.py`
- [Queue domain](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/domain.py): `src/next_is_you/domain.py`

### Reminder delivery

- [Reminder decisions](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/reminder_decision.py): `src/next_is_you/reminder_decision.py`
- [Send gate](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/send_gate.py): `src/next_is_you/send_gate.py`
- [Send hold state](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/paused_service.py): `src/next_is_you/paused_service.py`
- [LINE messaging](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/line_messaging.py): `src/next_is_you/line_messaging.py`
- [Recipient lifecycle](https://github.com/kltsai/next-is-you/blob/main/src/next_is_you/recipient_lifecycle.py): `src/next_is_you/recipient_lifecycle.py`

### Other components

- **Owner**

## Connections

- Owner → Organizer UI: uses (evidence: `README.md`)
- Organizer UI → Visit setup: renders (evidence: `frontend/src/main.ts`)
- Organizer UI → Organizer API: calls (evidence: `frontend/src/main.ts`)
- Organizer API → HTTP application: requests
- HTTP application → Authentication: authenticates (evidence: `src/worker.py`)
- HTTP application → Visit persistence: stores visits (evidence: `src/worker.py`)
- HTTP application → Recipient lifecycle: manages recipients
- HTTP application → Send gate: starts monitoring (evidence: `src/worker.py`)
- Scheduled checks → Hospital registry: dispatches reads (evidence: `src/next_is_you/scheduler.py`)
- Hospital registry → NTUH queue reader: delegates reads (evidence: `src/next_is_you/hospital_registry.py`)
- Hospital registry → Schedule reader Worker: provides schedule reader (evidence: `src/next_is_you/schedule_reader_worker.py`)
- Reader adapter → Schedule reader Worker: calls RPC (evidence: `src/next_is_you/schedule_reader_client.py`)
- Schedule validation → Reader adapter: uses adapter
- NTUH queue reader → Queue domain: returns observations (evidence: `src/next_is_you/ntuh_reader.py`)
- Scheduled checks → Visit persistence: loads visit state (evidence: `src/next_is_you/scheduler.py`)
- Scheduled checks → Reminder decisions: evaluates reminders (evidence: `src/next_is_you/scheduler.py`)
- Scheduled checks → Send gate: requests sends (evidence: `src/next_is_you/send_gate.py`)
- Send gate → Send hold state: checks hold (evidence: `src/next_is_you/paused_service.py`)
- Send gate → LINE messaging: sends messages (evidence: `src/next_is_you/send_gate.py`)
- Organizer UI → Visit projection: projects visits (evidence: `frontend/src/main.ts`)
- Organizer UI → Visit polling: refreshes visits (evidence: `frontend/src/main.ts`)
- Organizer UI → Recipient consent: offers controls
- HTTP application → Scheduled checks: runs scheduled checks
- Scheduled checks → Reader adapter: requests clinic schedule
- HTTP application → Hospital registry: serves hospital capabilities (evidence: `src/worker.py`)
