# praveenyt872/h2s-dose-reader architecture

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

- Interactive diagram: https://gitdiagram.com/praveenyt872/h2s-dose-reader
- Repository: https://github.com/praveenyt872/h2s-dose-reader

## Overview

H2S Dose Reader is an offline, client-side tool for turning a photo of a colorimetric H2S dosimeter strip into a dose estimate and occupational exposure record. The main workflow captures or uploads an image, samples white, grey, and strip colors, corrects for lighting, estimates dose and displays a safety classification; users can save and export readings. The README documents demo-image generation and CSV reporting, while sampled script excerpts also indicate worker enrollment, face verification, and zone-time tracking. Those latter features are mapped cautiously because their full wiring was not sampled.

Main entry points: [`script.js`](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js) (Capture and workflow), [`index.html`](https://github.com/praveenyt872/h2s-dose-reader/blob/main/index.html) (Reader interface), [`sw.js`](https://github.com/praveenyt872/h2s-dose-reader/blob/main/sw.js) (Offline cache), [`calibration.js`](https://github.com/praveenyt872/h2s-dose-reader/blob/main/calibration.js) (Dose calibration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_measurement["Strip measurement"]
  node_interface["Reader interface<br/>[index.html]"]
  node_reader["Capture and workflow<br/>[script.js]"]
  node_camera["Device camera"]
  node_pixel["Color sampling<br/>[script.js]"]
  node_correction["Lighting correction<br/>[script.js]"]
  node_demo["Demo image<br/>[script.js]"]
end

subgraph group_exposure["Exposure assessment"]
  node_dose["Dose calibration<br/>[calibration.js]"]
  node_twa["TWA calculation<br/>[calibration.js]"]
  node_classification["Safety classification<br/>[calibration.js]"]
  node_records[("Reading records<br/>[script.js]")]
  node_dashboard["Dashboard and CSV<br/>[script.js]"]
end

subgraph group_workforce["Worker tracking"]
  node_identity["Face enrollment and verification<br/>[script.js]"]
  node_zone["Zone-time sessions<br/>[script.js]"]
  node_browserstore[("Browser local storage")]
end

subgraph group_offline["Offline app"]
  node_serviceworker["Offline cache<br/>[sw.js]"]
  node_assetcache[("Cached app assets")]
end

node_worker(("Worker"))
node_admin(("Administrator"))

node_worker -->|"uses"| node_interface
node_admin -->|"uses"| node_interface
node_interface -->|"dispatches"| node_reader
node_reader -.->|"captures"| node_camera
node_reader -->|"samples image"| node_pixel
node_pixel -->|"provides colors"| node_correction
node_reader -->|"generates sample"| node_demo
node_reader -->|"gets dose"| node_dose
node_reader -->|"calculates TWA"| node_twa
node_reader -->|"determines status"| node_classification
node_reader -->|"saves reading"| node_records
node_records -->|"persists"| node_browserstore
node_dashboard -->|"reads and exports"| node_records
node_interface -->|"opens"| node_dashboard
node_reader -->|"handles verification"| node_identity
node_reader -->|"tracks zone time"| node_zone
node_identity -->|"stores enrollment"| node_browserstore
node_zone -->|"stores sessions"| node_browserstore
node_serviceworker -->|"caches assets"| node_assetcache
node_worker -->|"loads offline app"| node_serviceworker

click node_interface "https://github.com/praveenyt872/h2s-dose-reader/blob/main/index.html"
click node_reader "https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js"
click node_pixel "https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js"
click node_correction "https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js"
click node_demo "https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js"
click node_dose "https://github.com/praveenyt872/h2s-dose-reader/blob/main/calibration.js"
click node_twa "https://github.com/praveenyt872/h2s-dose-reader/blob/main/calibration.js"
click node_classification "https://github.com/praveenyt872/h2s-dose-reader/blob/main/calibration.js"
click node_records "https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js"
click node_dashboard "https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js"
click node_identity "https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js"
click node_zone "https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js"
click node_serviceworker "https://github.com/praveenyt872/h2s-dose-reader/blob/main/sw.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_interface,node_reader,node_camera,node_pixel,node_correction,node_demo toneBlue
class node_dose,node_twa,node_classification,node_records,node_dashboard toneAmber
class node_identity,node_zone,node_browserstore toneMint
class node_serviceworker,node_assetcache,node_worker toneRose
class node_admin toneIndigo
```

## Components

### Strip measurement

- [Reader interface](https://github.com/praveenyt872/h2s-dose-reader/blob/main/index.html): `index.html`
- [Capture and workflow](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js): `script.js`
- **Device camera**
- [Color sampling](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js): `script.js`
- [Lighting correction](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js): `script.js`
- [Demo image](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js): `script.js`

### Exposure assessment

- [Dose calibration](https://github.com/praveenyt872/h2s-dose-reader/blob/main/calibration.js): `calibration.js`
- [TWA calculation](https://github.com/praveenyt872/h2s-dose-reader/blob/main/calibration.js): `calibration.js`
- [Safety classification](https://github.com/praveenyt872/h2s-dose-reader/blob/main/calibration.js): `calibration.js`
- [Reading records](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js): `script.js`
- [Dashboard and CSV](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js): `script.js`

### Worker tracking

- [Face enrollment and verification](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js): `script.js`
- [Zone-time sessions](https://github.com/praveenyt872/h2s-dose-reader/blob/main/script.js): `script.js`
- **Browser local storage**

### Offline app

- [Offline cache](https://github.com/praveenyt872/h2s-dose-reader/blob/main/sw.js): `sw.js`
- **Cached app assets**

### Other components

- **Worker**
- **Administrator**

## Connections

- Worker → Reader interface: uses
- Administrator → Reader interface: uses
- Reader interface → Capture and workflow: dispatches
- Capture and workflow → Device camera: captures
- Capture and workflow → Color sampling: samples image
- Color sampling → Lighting correction: provides colors
- Capture and workflow → Demo image: generates sample
- Capture and workflow → Dose calibration: gets dose
- Capture and workflow → TWA calculation: calculates TWA
- Capture and workflow → Safety classification: determines status
- Capture and workflow → Reading records: saves reading
- Reading records → Browser local storage: persists
- Dashboard and CSV → Reading records: reads and exports
- Reader interface → Dashboard and CSV: opens
- Capture and workflow → Face enrollment and verification: handles verification
- Capture and workflow → Zone-time sessions: tracks zone time
- Face enrollment and verification → Browser local storage: stores enrollment
- Zone-time sessions → Browser local storage: stores sessions
- Offline cache → Cached app assets: caches assets
- Worker → Offline cache: loads offline app
