# codesbyrohit/dastak architecture

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

- Interactive diagram: https://gitdiagram.com/codesbyrohit/dastak
- Repository: https://github.com/codesbyrohit/dastak

## Overview

Dastak’s primary workflow is a community health worker completing a protocol-driven visit on a head-worn display: the app presents one question at a time, records answers, derives referral flags, and retains visit state on the device. Separate planner and review pages provide deterministic support, with optional AI limited to nonclinical ordering or aggregate descriptions. The graph reflects documented flows and sampled API dependencies; page-to-module connections are based on the README, since those page implementations were not excerpted.

Main entry points: [`api/_lib/plan.js`](https://github.com/codesbyrohit/dastak/blob/main/api/_lib/plan.js) (Plan endpoint), [`public/js/glasses-app.js`](https://github.com/codesbyrohit/dastak/blob/main/public/js/glasses-app.js) (Visit app), [`api/_lib/review.js`](https://github.com/codesbyrohit/dastak/blob/main/api/_lib/review.js) (Review endpoint), [`public/js/engine.js`](https://github.com/codesbyrohit/dastak/blob/main/public/js/engine.js) (Protocol interpreter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_visit["Wearable visit"]
  node_wearable["Visit app<br/>[glasses-app.js]"]
  node_engine["Protocol interpreter<br/>[engine.js]"]
  node_visitstore[("Device visit state<br/>[store.js]")]
  node_record["Visit records<br/>[record-page.js]"]
end

subgraph group_content["Protocol content"]
  node_protocols["Protocol definitions"]
  node_registry["Bundled registry<br/>[registry.js]"]
end

subgraph group_support["Planning and review"]
  node_plannerpage["Planner page<br/>[plan-page.js]"]
  node_planner["Deterministic planner<br/>[planner.js]"]
  node_roster["Household roster<br/>[roster.json]"]
  node_reviewpage["Review page<br/>[review-page.js]"]
end

subgraph group_api["API services"]
  node_planapi["Plan endpoint<br/>[plan.js]"]
  node_reviewapi["Review endpoint<br/>[review.js]"]
  node_validation["Request validation<br/>[validate.js]"]
  node_http["HTTP guards<br/>[http.js]"]
  node_aiclient["Optional AI client<br/>[ai.js]"]
  node_protocolapi["Protocol endpoint<br/>[protocol.js]"]
end

node_worker(("Health worker"))
node_provider{{"AI provider"}}

node_worker -->|"answers questions"| node_wearable
node_wearable -->|"interprets protocol"| node_engine
node_wearable -->|"saves visit state"| node_visitstore
node_wearable -->|"loads bundled protocols"| node_registry
node_engine -->|"executes steps"| node_protocols
node_record -.->|"reads visit records"| node_visitstore
node_plannerpage -->|"requests ordering"| node_planapi
node_plannerpage -.->|"uses household list"| node_roster
node_planapi -->|"computes deterministic order"| node_planner
node_planapi -->|"loads demo roster"| node_registry
node_planapi -->|"validates roster"| node_validation
node_planapi -->|"requests optional ordering"| node_aiclient
node_reviewpage -->|"requests summary"| node_reviewapi
node_reviewapi -->|"validates visits"| node_validation
node_reviewapi -->|"requests optional description"| node_aiclient
node_aiclient -->|"sends AI request"| node_provider
node_protocolapi -->|"reads bundled protocol"| node_registry
node_protocolapi -->|"resolves protocol ID"| node_engine
node_planapi -->|"uses request guards"| node_http
node_reviewapi -->|"uses request guards"| node_http

click node_wearable "https://github.com/codesbyrohit/dastak/blob/main/public/js/glasses-app.js"
click node_engine "https://github.com/codesbyrohit/dastak/blob/main/public/js/engine.js"
click node_visitstore "https://github.com/codesbyrohit/dastak/blob/main/public/js/store.js"
click node_record "https://github.com/codesbyrohit/dastak/blob/main/public/js/record-page.js"
click node_protocols "https://github.com/codesbyrohit/dastak/tree/main/protocols"
click node_registry "https://github.com/codesbyrohit/dastak/blob/main/public/generated/registry.js"
click node_plannerpage "https://github.com/codesbyrohit/dastak/blob/main/public/js/plan-page.js"
click node_planner "https://github.com/codesbyrohit/dastak/blob/main/public/js/planner.js"
click node_roster "https://github.com/codesbyrohit/dastak/blob/main/data/roster.json"
click node_reviewpage "https://github.com/codesbyrohit/dastak/blob/main/public/js/review-page.js"
click node_planapi "https://github.com/codesbyrohit/dastak/blob/main/api/_lib/plan.js"
click node_reviewapi "https://github.com/codesbyrohit/dastak/blob/main/api/_lib/review.js"
click node_validation "https://github.com/codesbyrohit/dastak/blob/main/api/_lib/validate.js"
click node_http "https://github.com/codesbyrohit/dastak/blob/main/api/_lib/http.js"
click node_aiclient "https://github.com/codesbyrohit/dastak/blob/main/api/_lib/ai.js"
click node_protocolapi "https://github.com/codesbyrohit/dastak/blob/main/api/_lib/protocol.js"

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_wearable,node_engine,node_visitstore,node_record toneBlue
class node_protocols,node_registry toneAmber
class node_plannerpage,node_planner,node_roster,node_reviewpage toneMint
class node_planapi,node_reviewapi,node_validation,node_http,node_aiclient,node_protocolapi,node_worker toneRose
class node_provider toneIndigo
```

## Components

### Wearable visit

- [Visit app](https://github.com/codesbyrohit/dastak/blob/main/public/js/glasses-app.js): `public/js/glasses-app.js`
- [Protocol interpreter](https://github.com/codesbyrohit/dastak/blob/main/public/js/engine.js): `public/js/engine.js`
- [Device visit state](https://github.com/codesbyrohit/dastak/blob/main/public/js/store.js): `public/js/store.js`
- [Visit records](https://github.com/codesbyrohit/dastak/blob/main/public/js/record-page.js): `public/js/record-page.js`

### Protocol content

- [Protocol definitions](https://github.com/codesbyrohit/dastak/tree/main/protocols): `protocols`
- [Bundled registry](https://github.com/codesbyrohit/dastak/blob/main/public/generated/registry.js): `public/generated/registry.js`

### Planning and review

- [Planner page](https://github.com/codesbyrohit/dastak/blob/main/public/js/plan-page.js): `public/js/plan-page.js`
- [Deterministic planner](https://github.com/codesbyrohit/dastak/blob/main/public/js/planner.js): `public/js/planner.js`
- [Household roster](https://github.com/codesbyrohit/dastak/blob/main/data/roster.json): `data/roster.json`
- [Review page](https://github.com/codesbyrohit/dastak/blob/main/public/js/review-page.js): `public/js/review-page.js`

### API services

- [Plan endpoint](https://github.com/codesbyrohit/dastak/blob/main/api/_lib/plan.js): `api/_lib/plan.js`
- [Review endpoint](https://github.com/codesbyrohit/dastak/blob/main/api/_lib/review.js): `api/_lib/review.js`
- [Request validation](https://github.com/codesbyrohit/dastak/blob/main/api/_lib/validate.js): `api/_lib/validate.js`
- [HTTP guards](https://github.com/codesbyrohit/dastak/blob/main/api/_lib/http.js): `api/_lib/http.js`
- [Optional AI client](https://github.com/codesbyrohit/dastak/blob/main/api/_lib/ai.js): `api/_lib/ai.js`
- [Protocol endpoint](https://github.com/codesbyrohit/dastak/blob/main/api/_lib/protocol.js): `api/_lib/protocol.js`

### Other components

- **Health worker**
- **AI provider**

## Connections

- Health worker → Visit app: answers questions (evidence: `README.md`)
- Visit app → Protocol interpreter: interprets protocol (evidence: `README.md`)
- Visit app → Device visit state: saves visit state (evidence: `README.md`)
- Visit app → Bundled registry: loads bundled protocols (evidence: `README.md`)
- Protocol interpreter → Protocol definitions: executes steps (evidence: `README.md`)
- Visit records → Device visit state: reads visit records
- Planner page → Plan endpoint: requests ordering (evidence: `README.md`)
- Planner page → Household roster: uses household list
- Plan endpoint → Deterministic planner: computes deterministic order (evidence: `api/_lib/plan.js`)
- Plan endpoint → Bundled registry: loads demo roster (evidence: `api/_lib/plan.js`)
- Plan endpoint → Request validation: validates roster (evidence: `api/_lib/plan.js`)
- Plan endpoint → Optional AI client: requests optional ordering (evidence: `api/_lib/plan.js`)
- Review page → Review endpoint: requests summary (evidence: `README.md`)
- Review endpoint → Request validation: validates visits (evidence: `api/_lib/review.js`)
- Review endpoint → Optional AI client: requests optional description (evidence: `api/_lib/review.js`)
- Optional AI client → AI provider: sends AI request (evidence: `api/_lib/ai.js`)
- Protocol endpoint → Bundled registry: reads bundled protocol (evidence: `api/_lib/protocol.js`)
- Protocol endpoint → Protocol interpreter: resolves protocol ID (evidence: `api/_lib/protocol.js`)
- Plan endpoint → HTTP guards: uses request guards (evidence: `api/_lib/plan.js`)
- Review endpoint → HTTP guards: uses request guards (evidence: `api/_lib/review.js`)
