# venkataraamvg/h2s-dosimeter architecture

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

## Overview

This prototype estimates a Cu-PAN strip’s reaction stage from an image and displays a provisional H₂S value; it is explicitly not a validated safety detector. The main workflow validates an uploaded image, extracts color features, matches Array 2’s CIELAB values to reference stages, then maps the selected stage to a provisional exposure result. The repository also has a Flask/API and browser-based analysis path, plus reference-dataset creation. The HTML template, configuration, and reference-data source were not sampled, so their detailed wiring is limited to what the tree and sampled callers support.

Main entry points: [`server.py`](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/server.py) (Flask Web API), [`app.py`](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/app.py) (Streamlit Dashboard), [`data/processed/h2s_dataset.csv`](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/data/processed/h2s_dataset.csv) (Feature Dataset), [`build_dataset.py`](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/build_dataset.py) (Reference Builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_streamlit["Streamlit Dashboard<br/>[app.py]"]
  node_flask["Flask Web API<br/>[server.py]"]
  node_webui["Browser UI<br/>[index.html]"]
  node_clientcv["Client CV<br/>[cv.js]"]
end

subgraph group_analysis["Image Analysis"]
  node_validation["Image Validation<br/>[preprocessing.py]"]
  node_features["ROI Features"]
  node_matching["Stage Matching<br/>[color_matching.py]"]
end

subgraph group_references["Reference Data"]
  node_builder["Reference Builder<br/>[build_dataset.py]"]
  node_referenceimages[("Stage Crops")]
  node_dataset[("Feature Dataset<br/>[h2s_dataset.csv]")]
  node_browserrefs["Browser References<br/>[reference_data.js]"]
end

subgraph group_results["Stage Results"]
  node_calibration["Provisional Mapping<br/>[config.py]"]
  node_result["Exposure Display"]
end

node_user(("Image Uploader"))
node_sampleimages[("Sample Image Source")]

node_user -->|"uploads image"| node_streamlit
node_streamlit -->|"validates image"| node_validation
node_streamlit -->|"extracts features"| node_features
node_streamlit -->|"matches stage"| node_matching
node_streamlit -->|"loads references"| node_dataset
node_streamlit -->|"looks up value"| node_calibration
node_streamlit -->|"displays result"| node_result
node_user -->|"uses browser"| node_webui
node_webui -->|"runs analysis"| node_clientcv
node_clientcv -->|"reads stages"| node_browserrefs
node_user -->|"posts image"| node_flask
node_flask -->|"validates image"| node_validation
node_flask -->|"extracts features"| node_features
node_flask -->|"matches stage"| node_matching
node_flask -->|"loads references"| node_dataset
node_flask -->|"looks up value"| node_calibration
node_flask -->|"returns result"| node_result
node_builder -->|"writes crops"| node_referenceimages
node_builder -->|"writes features"| node_dataset
node_flask -->|"reads sample"| node_sampleimages

click node_streamlit "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/app.py"
click node_flask "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/server.py"
click node_webui "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/templates/index.html"
click node_clientcv "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/static/cv.js"
click node_validation "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/src/preprocessing.py"
click node_features "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/src/feature_extraction.py"
click node_matching "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/src/color_matching.py"
click node_builder "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/build_dataset.py"
click node_referenceimages "https://github.com/venkataraamvg/h2s-dosimeter/tree/main/data/cropped"
click node_dataset "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/data/processed/h2s_dataset.csv"
click node_browserrefs "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/static/reference_data.js"
click node_calibration "https://github.com/venkataraamvg/h2s-dosimeter/blob/main/src/config.py"
click node_sampleimages "https://github.com/venkataraamvg/h2s-dosimeter/tree/main/data/cropped"

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_streamlit,node_flask,node_webui,node_clientcv toneBlue
class node_validation,node_features,node_matching,node_sampleimages toneAmber
class node_builder,node_referenceimages,node_dataset,node_browserrefs toneMint
class node_calibration,node_result toneRose
class node_user toneIndigo
```

## Components

### User Interfaces

- [Streamlit Dashboard](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/app.py): `app.py`
- [Flask Web API](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/server.py): `server.py`
- [Browser UI](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/templates/index.html): `templates/index.html`
- [Client CV](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/static/cv.js): `static/cv.js`

### Image Analysis

- [Image Validation](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/src/preprocessing.py): `src/preprocessing.py`
- [ROI Features](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/src/feature_extraction.py): `src/feature_extraction.py`
- [Stage Matching](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/src/color_matching.py): `src/color_matching.py`

### Reference Data

- [Reference Builder](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/build_dataset.py): `build_dataset.py`
- [Stage Crops](https://github.com/venkataraamvg/h2s-dosimeter/tree/main/data/cropped): `data/cropped`
- [Feature Dataset](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/data/processed/h2s_dataset.csv): `data/processed/h2s_dataset.csv`
- [Browser References](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/static/reference_data.js): `static/reference_data.js`

### Stage Results

- [Provisional Mapping](https://github.com/venkataraamvg/h2s-dosimeter/blob/main/src/config.py): `src/config.py`
- **Exposure Display**

### Other components

- **Image Uploader**
- [Sample Image Source](https://github.com/venkataraamvg/h2s-dosimeter/tree/main/data/cropped): `data/cropped`

## Connections

- Image Uploader → Streamlit Dashboard: uploads image
- Streamlit Dashboard → Image Validation: validates image
- Streamlit Dashboard → ROI Features: extracts features
- Streamlit Dashboard → Stage Matching: matches stage
- Streamlit Dashboard → Feature Dataset: loads references
- Streamlit Dashboard → Provisional Mapping: looks up value
- Streamlit Dashboard → Exposure Display: displays result
- Image Uploader → Browser UI: uses browser
- Browser UI → Client CV: runs analysis
- Client CV → Browser References: reads stages
- Image Uploader → Flask Web API: posts image
- Flask Web API → Image Validation: validates image
- Flask Web API → ROI Features: extracts features
- Flask Web API → Stage Matching: matches stage
- Flask Web API → Feature Dataset: loads references
- Flask Web API → Provisional Mapping: looks up value
- Flask Web API → Exposure Display: returns result
- Reference Builder → Stage Crops: writes crops
- Reference Builder → Feature Dataset: writes features
- Flask Web API → Sample Image Source: reads sample
