# ayanatiach/h2s_detector architecture

> Architecture diagram of the GitHub repository ayanatiach/h2s_detector, 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/ayanatiach/h2s_detector
- Repository: https://github.com/ayanatiach/h2s_detector

## Overview

H₂S Detector is a Flutter app for reading colorimetric dosimeter strips and monitoring worker exposure. The documented workflow runs from camera capture and lighting validation through on-device color analysis, exposure classification, result review, and saving; synchronization uploads readings or queues them offline. The tree also indicates dashboard, facility-map, and team-safety features. The supplied source excerpts are native platform boilerplate, so implementation-level wiring beyond the README workflow is uncertain; those links are omitted.

Main entry points: [`lib/features/shell/main_shell.dart`](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/shell/main_shell.dart) (Main shell), [`lib/features/scanner/scanner_screen.dart`](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/scanner/scanner_screen.dart) (Dosimeter scanner), [`lib/core/vision/cielab_engine.dart`](https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/cielab_engine.dart) (Color analysis), [`lib/features/sync/supabase_service.dart`](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/sync/supabase_service.dart) (Supabase sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and analysis"]
  node_scanner["Dosimeter scanner"]
  node_camera["Camera provider"]
  node_lighting["Lighting analysis"]
  node_vision["Color analysis<br/>[cielab_engine.dart]"]
  node_extractor["Color extraction"]
  node_delta["Delta E calculation"]
  node_baseline["Baseline settings"]
  node_thresholds["Exposure thresholds"]
  node_scanstate["Scan state<br/>[scan_provider.dart]"]
  node_result["Scan result"]
end

subgraph group_records["Readings and sync"]
  node_reading["Reading history"]
  node_syncstate["Sync state<br/>[sync_provider.dart]"]
  node_queue[("Offline queue")]
  node_syncservice["Supabase sync"]
end

subgraph group_monitoring["Safety monitoring"]
  node_dashboard["Safety dashboard"]
  node_chart["Exposure timeline"]
  node_gasgraph["Gas detector graph"]
  node_map["Facility map<br/>[facility_map.dart]"]
  node_mapstate["Map telemetry"]
  node_team["Team safety roster"]
end

subgraph group_application["App experience"]
  node_shell["Main shell<br/>[main_shell.dart]"]
end

node_worker(("Worker"))
node_supabase["Supabase"]

node_worker -->|"opens"| node_shell
node_shell -->|"navigates to"| node_scanner
node_scanner -->|"captures frame"| node_camera
node_scanner -->|"checks lighting"| node_lighting
node_scanner -->|"submits image"| node_vision
node_vision -->|"extracts pixels"| node_extractor
node_vision -->|"reads baseline"| node_baseline
node_vision -->|"computes color shift"| node_delta
node_vision -->|"classifies exposure"| node_thresholds
node_scanner -->|"updates scan"| node_scanstate
node_scanstate -->|"provides result"| node_result
node_result -->|"saves reading"| node_reading
node_reading -->|"updates sync"| node_syncstate
node_syncstate -->|"dispatches sync"| node_syncservice
node_syncservice -->|"queues offline"| node_queue
node_syncservice -->|"uploads reading"| node_supabase
node_queue -->|"flushes queued"| node_syncservice
node_syncservice -->|"flushes to"| node_supabase
node_shell -->|"navigates to"| node_dashboard
node_dashboard -->|"displays readings"| node_reading
node_dashboard -->|"shows timeline"| node_chart
node_shell -->|"navigates to"| node_gasgraph
node_shell -->|"navigates to"| node_map
node_map -->|"reads telemetry"| node_mapstate
node_shell -->|"navigates to"| node_team

click node_shell "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/shell/main_shell.dart"
click node_scanner "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/scanner/scanner_screen.dart"
click node_camera "https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/camera_provider.dart"
click node_lighting "https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/lighting_analyzer.dart"
click node_vision "https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/cielab_engine.dart"
click node_extractor "https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/color_extractor.dart"
click node_delta "https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/delta_e_calculator.dart"
click node_baseline "https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/baseline_provider.dart"
click node_thresholds "https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/constants/exposure_thresholds.dart"
click node_scanstate "https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/scan_provider.dart"
click node_result "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/scanner/scan_result_screen.dart"
click node_reading "https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/readings_provider.dart"
click node_syncstate "https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/sync_provider.dart"
click node_queue "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/sync/offline_queue_service.dart"
click node_syncservice "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/sync/supabase_service.dart"
click node_dashboard "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/dashboard/dashboard_screen.dart"
click node_chart "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/dashboard/exposure_chart_card.dart"
click node_gasgraph "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/dashboard/views/gas_detector_graph_screen.dart"
click node_map "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/map/views/facility_map.dart"
click node_mapstate "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/map/providers/facility_map_provider.dart"
click node_team "https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/team/views/team_safety_screen.dart"

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_scanner,node_camera,node_lighting,node_vision,node_extractor,node_delta,node_baseline,node_thresholds,node_scanstate,node_result toneBlue
class node_reading,node_syncstate,node_queue,node_syncservice toneAmber
class node_dashboard,node_chart,node_gasgraph,node_map,node_mapstate,node_team toneMint
class node_shell,node_worker toneRose
class node_supabase toneIndigo
```

## Components

### Capture and analysis

- [Dosimeter scanner](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/scanner/scanner_screen.dart): `lib/features/scanner/scanner_screen.dart`
- [Camera provider](https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/camera_provider.dart): `lib/providers/camera_provider.dart`
- [Lighting analysis](https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/lighting_analyzer.dart): `lib/core/vision/lighting_analyzer.dart`
- [Color analysis](https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/cielab_engine.dart): `lib/core/vision/cielab_engine.dart`
- [Color extraction](https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/color_extractor.dart): `lib/core/vision/color_extractor.dart`
- [Delta E calculation](https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/vision/delta_e_calculator.dart): `lib/core/vision/delta_e_calculator.dart`
- [Baseline settings](https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/baseline_provider.dart): `lib/providers/baseline_provider.dart`
- [Exposure thresholds](https://github.com/ayanatiach/h2s_detector/blob/main/lib/core/constants/exposure_thresholds.dart): `lib/core/constants/exposure_thresholds.dart`
- [Scan state](https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/scan_provider.dart): `lib/providers/scan_provider.dart`
- [Scan result](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/scanner/scan_result_screen.dart): `lib/features/scanner/scan_result_screen.dart`

### Readings and sync

- [Reading history](https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/readings_provider.dart): `lib/providers/readings_provider.dart`
- [Sync state](https://github.com/ayanatiach/h2s_detector/blob/main/lib/providers/sync_provider.dart): `lib/providers/sync_provider.dart`
- [Offline queue](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/sync/offline_queue_service.dart): `lib/features/sync/offline_queue_service.dart`
- [Supabase sync](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/sync/supabase_service.dart): `lib/features/sync/supabase_service.dart`

### Safety monitoring

- [Safety dashboard](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/dashboard/dashboard_screen.dart): `lib/features/dashboard/dashboard_screen.dart`
- [Exposure timeline](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/dashboard/exposure_chart_card.dart): `lib/features/dashboard/exposure_chart_card.dart`
- [Gas detector graph](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/dashboard/views/gas_detector_graph_screen.dart): `lib/features/dashboard/views/gas_detector_graph_screen.dart`
- [Facility map](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/map/views/facility_map.dart): `lib/features/map/views/facility_map.dart`
- [Map telemetry](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/map/providers/facility_map_provider.dart): `lib/features/map/providers/facility_map_provider.dart`
- [Team safety roster](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/team/views/team_safety_screen.dart): `lib/features/team/views/team_safety_screen.dart`

### App experience

- [Main shell](https://github.com/ayanatiach/h2s_detector/blob/main/lib/features/shell/main_shell.dart): `lib/features/shell/main_shell.dart`

### Other components

- **Worker**
- **Supabase**

## Connections

- Worker → Main shell: opens
- Main shell → Dosimeter scanner: navigates to
- Dosimeter scanner → Camera provider: captures frame
- Dosimeter scanner → Lighting analysis: checks lighting
- Dosimeter scanner → Color analysis: submits image
- Color analysis → Color extraction: extracts pixels
- Color analysis → Baseline settings: reads baseline
- Color analysis → Delta E calculation: computes color shift
- Color analysis → Exposure thresholds: classifies exposure
- Dosimeter scanner → Scan state: updates scan
- Scan state → Scan result: provides result
- Scan result → Reading history: saves reading
- Reading history → Sync state: updates sync
- Sync state → Supabase sync: dispatches sync
- Supabase sync → Offline queue: queues offline
- Supabase sync → Supabase: uploads reading
- Offline queue → Supabase sync: flushes queued
- Supabase sync → Supabase: flushes to
- Main shell → Safety dashboard: navigates to
- Safety dashboard → Reading history: displays readings
- Safety dashboard → Exposure timeline: shows timeline
- Main shell → Gas detector graph: navigates to
- Main shell → Facility map: navigates to
- Facility map → Map telemetry: reads telemetry
- Main shell → Team safety roster: navigates to
