# yodsakornsamanrad-dev/closely-dr-ie-buu architecture

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

- Interactive diagram: https://gitdiagram.com/yodsakornsamanrad-dev/closely-dr-ie-buu
- Repository: https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu

## Overview

Closely DR. is a workshop-oriented OPD journey application with patient and staff views. The patient flow presents registration, screening, queue waiting, consultation, medicine delivery or pickup, and follow-up; staff manage queues and clinical-stage outcomes while reviewing floor activity and journey metrics. The browser transport supports local and shared-server modes, with YAML-based reference data and export/import. Connections reflect README documentation and the supplied source index; unsampled implementation details are not inferred.

Main entry points: [`js/app/main.js`](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/main.js) (Patient app), [`js/transport.js`](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/transport.js) (Mode transport), [`js/staff/main.js`](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/staff/main.js) (Staff dashboard), [`js/app/map3d.js`](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/map3d.js) (Patient map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient journey"]
  node_patient_app["Patient app<br/>[main.js]"]
  node_patient_context["App context<br/>[ctx.js]"]
  node_current_stage["Current status<br/>[now.js]"]
  node_journey_tabs["Journey tabs<br/>[tabs.js]"]
  node_patient_map["Patient map<br/>[map3d.js]"]
end

subgraph group_logic["OPD logic"]
  node_business_core["Visit actions<br/>[core.js]"]
  node_queue_logic["Queue logic<br/>[queue.js]"]
  node_floor_routes["Floor routing<br/>[floor.js]"]
  node_timeline["Stage timing<br/>[timeline.js]"]
  node_crowd_model["Crowd replay<br/>[crowd.js]"]
  node_isometric["Isometric renderer<br/>[iso3d.js]"]
end

subgraph group_staff["Staff and analysis"]
  node_staff_dashboard["Staff dashboard<br/>[main.js]"]
  node_staff_floor["Staff floor view<br/>[floor.js]"]
  node_value_stream["Value stream<br/>[valuestream.js]"]
end

subgraph group_sync["Data and sync"]
  node_transport["Mode transport<br/>[transport.js]"]
  node_reference_data["Reference YAML<br/>[data.js]"]
  node_usage_log["YAML log tools<br/>[usage-log.js]"]
  node_local_storage[("Browser storage")]
  node_server["Node API and SSE<br/>[server.mjs]"]
  node_shared_state[("Shared state YAML")]
end

node_patient_actor(("Patient"))
node_staff_actor(("Staff"))

node_patient_actor -->|"uses"| node_patient_app
node_patient_app -->|"reads context"| node_patient_context
node_patient_app -->|"renders"| node_current_stage
node_patient_app -->|"renders"| node_journey_tabs
node_patient_app -->|"starts map"| node_patient_map
node_patient_app -->|"sends actions"| node_transport
node_patient_app -->|"uses actions"| node_business_core
node_current_stage -->|"calculates wait"| node_queue_logic
node_current_stage -->|"shows timings"| node_timeline
node_journey_tabs -->|"requests routes"| node_floor_routes
node_journey_tabs -->|"renders map"| node_patient_map
node_patient_map -->|"gets crowd"| node_crowd_model
node_patient_map -->|"draws scene"| node_isometric
node_staff_actor -->|"manages visits"| node_staff_dashboard
node_staff_dashboard -->|"opens floor view"| node_staff_floor
node_staff_dashboard -->|"views metrics"| node_value_stream
node_staff_dashboard -->|"updates and exports"| node_transport
node_staff_floor -->|"gets replay"| node_crowd_model
node_staff_floor -->|"renders floor"| node_isometric
node_transport -->|"loads config"| node_reference_data
node_transport -->|"creates actions"| node_business_core
node_transport -->|"imports and exports"| node_usage_log
node_transport -->|"stores local state"| node_local_storage
node_transport -->|"calls API and SSE"| node_server
node_server -->|"persists state"| node_shared_state
node_business_core -->|"labels queues"| node_queue_logic
node_value_stream -->|"uses timing data"| node_timeline

click node_patient_app "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/main.js"
click node_patient_context "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/ctx.js"
click node_current_stage "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/now.js"
click node_journey_tabs "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/tabs.js"
click node_patient_map "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/map3d.js"
click node_business_core "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/core.js"
click node_queue_logic "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/queue.js"
click node_floor_routes "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/floor.js"
click node_timeline "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/timeline.js"
click node_crowd_model "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/crowd.js"
click node_isometric "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/iso3d.js"
click node_staff_dashboard "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/staff/main.js"
click node_staff_floor "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/staff/floor.js"
click node_value_stream "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/valuestream.js"
click node_transport "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/transport.js"
click node_reference_data "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/data.js"
click node_usage_log "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/usage-log.js"
click node_server "https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/server.mjs"

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_patient_app,node_patient_context,node_current_stage,node_journey_tabs,node_patient_map toneBlue
class node_business_core,node_queue_logic,node_floor_routes,node_timeline,node_crowd_model,node_isometric toneAmber
class node_staff_dashboard,node_staff_floor,node_value_stream toneMint
class node_transport,node_reference_data,node_usage_log,node_local_storage,node_server,node_shared_state toneRose
class node_patient_actor,node_staff_actor toneIndigo
```

## Components

### Patient journey

- [Patient app](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/main.js): `js/app/main.js`
- [App context](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/ctx.js): `js/app/ctx.js`
- [Current status](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/now.js): `js/app/now.js`
- [Journey tabs](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/tabs.js): `js/app/tabs.js`
- [Patient map](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/app/map3d.js): `js/app/map3d.js`

### OPD logic

- [Visit actions](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/core.js): `js/lib/core.js`
- [Queue logic](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/queue.js): `js/lib/queue.js`
- [Floor routing](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/floor.js): `js/lib/floor.js`
- [Stage timing](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/timeline.js): `js/lib/timeline.js`
- [Crowd replay](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/crowd.js): `js/lib/crowd.js`
- [Isometric renderer](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/iso3d.js): `js/lib/iso3d.js`

### Staff and analysis

- [Staff dashboard](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/staff/main.js): `js/staff/main.js`
- [Staff floor view](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/staff/floor.js): `js/staff/floor.js`
- [Value stream](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/valuestream.js): `js/lib/valuestream.js`

### Data and sync

- [Mode transport](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/transport.js): `js/transport.js`
- [Reference YAML](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/data.js): `js/lib/data.js`
- [YAML log tools](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/js/lib/usage-log.js): `js/lib/usage-log.js`
- **Browser storage**
- [Node API and SSE](https://github.com/yodsakornsamanrad-dev/closely-dr-ie-buu/blob/main/server.mjs): `server.mjs`
- **Shared state YAML**

### Other components

- **Patient**
- **Staff**

## Connections

- Patient → Patient app: uses (evidence: `README.md`)
- Patient app → App context: reads context (evidence: `js/app/main.js`)
- Patient app → Current status: renders (evidence: `js/app/main.js`)
- Patient app → Journey tabs: renders (evidence: `js/app/main.js`)
- Patient app → Patient map: starts map (evidence: `js/app/main.js`)
- Patient app → Mode transport: sends actions (evidence: `js/transport.js`)
- Patient app → Visit actions: uses actions (evidence: `README.md`)
- Current status → Queue logic: calculates wait (evidence: `js/app/now.js`)
- Current status → Stage timing: shows timings (evidence: `js/app/now.js`)
- Journey tabs → Floor routing: requests routes (evidence: `js/app/tabs.js`)
- Journey tabs → Patient map: renders map (evidence: `js/app/tabs.js`)
- Patient map → Crowd replay: gets crowd (evidence: `js/app/map3d.js`)
- Patient map → Isometric renderer: draws scene (evidence: `js/app/map3d.js`)
- Staff → Staff dashboard: manages visits (evidence: `README.md`)
- Staff dashboard → Staff floor view: opens floor view (evidence: `js/staff/main.js`)
- Staff dashboard → Value stream: views metrics (evidence: `js/staff/main.js`)
- Staff dashboard → Mode transport: updates and exports (evidence: `js/staff/main.js`)
- Staff floor view → Crowd replay: gets replay (evidence: `js/staff/floor.js`)
- Staff floor view → Isometric renderer: renders floor (evidence: `js/staff/floor.js`)
- Mode transport → Reference YAML: loads config (evidence: `js/transport.js`)
- Mode transport → Visit actions: creates actions (evidence: `js/transport.js`)
- Mode transport → YAML log tools: imports and exports (evidence: `js/transport.js`)
- Mode transport → Browser storage: stores local state (evidence: `README.md`)
- Mode transport → Node API and SSE: calls API and SSE (evidence: `js/transport.js`)
- Node API and SSE → Shared state YAML: persists state (evidence: `README.md`)
- Visit actions → Queue logic: labels queues (evidence: `js/lib/core.js`)
- Value stream → Stage timing: uses timing data (evidence: `js/lib/valuestream.js`)
