# phil27-gotchu/jaundice_detection architecture

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

- Interactive diagram: https://gitdiagram.com/phil27-gotchu/jaundice_detection
- Repository: https://github.com/phil27-gotchu/jaundice_detection

## Overview

Jaundice Monitor combines an ESP8266 reflectance probe with a dashboard/API, plus a Cloudflare deployment variant and logistic-regression screening. The main documented workflow is probe measurement and local logging, then HTTP upload, server-side reading handling, and browser dashboard rendering; inference enriches displayed readings. Python training and prediction modules form a separate model-development branch. Some links are documented rather than visible in sampled firmware, and the SQLite helper’s runtime use is not established by the excerpts.

Main entry points: [`firmware/jaundice_monitor.ino`](https://github.com/phil27-gotchu/jaundice_detection/blob/main/firmware/jaundice_monitor.ino) (Probe Firmware), [`server/index.js`](https://github.com/phil27-gotchu/jaundice_detection/blob/main/server/index.js) (Local API), [`cloudflare/src/index.ts`](https://github.com/phil27-gotchu/jaundice_detection/blob/main/cloudflare/src/index.ts) (Cloudflare API), [`shared/dashboard.js`](https://github.com/phil27-gotchu/jaundice_detection/blob/main/shared/dashboard.js) (Dashboard Renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_probe["Probe Firmware"]
  node_firmware["Probe Firmware"]
end

subgraph group_services["Ingest Services"]
  node_localapi["Local API<br/>[index.js]"]
  node_cloudworker["Cloudflare API<br/>[index.ts]"]
  node_kv[("Readings KV")]
end

subgraph group_dashboard["Dashboard"]
  node_localtemplate["Dashboard Template<br/>[index.html]"]
  node_styles["Dashboard Styles<br/>[styles.css]"]
  node_renderer["Dashboard Renderer<br/>[dashboard.js]"]
end

subgraph group_ml["Screening Model"]
  node_predictor["JS Predictor<br/>[mlPredictor.js]"]
  node_modeljson["Trained Model<br/>[trained_model.json]"]
end

subgraph group_training["Model Development"]
  node_dataset["Synthetic Dataset"]
  node_trainer["Model Training"]
  node_pythonpredict["Python Predictor<br/>[predict.py]"]
  node_logistic["Logistic Regression"]
  node_forest["Random Forest<br/>[random_forest.py]"]
end

node_operator(("Operator"))
node_sensor["RGB Probe"]
node_oled["OLED Display"]
node_sdcard[("SD Card Log")]
node_browser(("Browser"))

node_operator -->|"presses button"| node_firmware
node_firmware -->|"measures RGB"| node_sensor
node_firmware -->|"shows results"| node_oled
node_firmware -->|"appends readings"| node_sdcard
node_firmware -->|"POSTs readings"| node_localapi
node_browser -->|"polls dashboard"| node_localapi
node_localapi -->|"renders page"| node_renderer
node_localapi -->|"predicts risk"| node_predictor
node_cloudworker -->|"renders page"| node_renderer
node_cloudworker -->|"reads and writes"| node_kv
node_cloudworker -->|"fetches template"| node_localtemplate
node_renderer -->|"predicts readings"| node_predictor
node_trainer -->|"loads data"| node_dataset
node_trainer -->|"exports parameters"| node_modeljson
node_predictor -->|"loads model"| node_modeljson

click node_firmware "https://github.com/phil27-gotchu/jaundice_detection/blob/main/firmware/jaundice_monitor.ino"
click node_localapi "https://github.com/phil27-gotchu/jaundice_detection/blob/main/server/index.js"
click node_cloudworker "https://github.com/phil27-gotchu/jaundice_detection/blob/main/cloudflare/src/index.ts"
click node_localtemplate "https://github.com/phil27-gotchu/jaundice_detection/blob/main/cloudflare/public/index.html"
click node_styles "https://github.com/phil27-gotchu/jaundice_detection/blob/main/cloudflare/public/styles.css"
click node_renderer "https://github.com/phil27-gotchu/jaundice_detection/blob/main/shared/dashboard.js"
click node_predictor "https://github.com/phil27-gotchu/jaundice_detection/blob/main/shared/mlPredictor.js"
click node_modeljson "https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/trained_model.json"
click node_dataset "https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/data/synthetic_neonatal_jaundice_dataset.csv"
click node_trainer "https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/train_and_export.py"
click node_pythonpredict "https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/predict.py"
click node_logistic "https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/logistic_regression.py"
click node_forest "https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/random_forest.py"

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_firmware,node_browser toneBlue
class node_localapi,node_cloudworker,node_kv,node_sdcard toneAmber
class node_localtemplate,node_styles,node_renderer toneMint
class node_predictor,node_modeljson toneRose
class node_dataset,node_trainer,node_pythonpredict,node_logistic,node_forest,node_operator,node_sensor,node_oled toneIndigo
```

## Components

### Probe Firmware

- [Probe Firmware](https://github.com/phil27-gotchu/jaundice_detection/blob/main/firmware/jaundice_monitor.ino): `firmware/jaundice_monitor.ino`

### Ingest Services

- [Local API](https://github.com/phil27-gotchu/jaundice_detection/blob/main/server/index.js): `server/index.js`
- [Cloudflare API](https://github.com/phil27-gotchu/jaundice_detection/blob/main/cloudflare/src/index.ts): `cloudflare/src/index.ts`
- **Readings KV**

### Dashboard

- [Dashboard Template](https://github.com/phil27-gotchu/jaundice_detection/blob/main/cloudflare/public/index.html): `cloudflare/public/index.html`
- [Dashboard Styles](https://github.com/phil27-gotchu/jaundice_detection/blob/main/cloudflare/public/styles.css): `cloudflare/public/styles.css`
- [Dashboard Renderer](https://github.com/phil27-gotchu/jaundice_detection/blob/main/shared/dashboard.js): `shared/dashboard.js`

### Screening Model

- [JS Predictor](https://github.com/phil27-gotchu/jaundice_detection/blob/main/shared/mlPredictor.js): `shared/mlPredictor.js`
- [Trained Model](https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/trained_model.json): `ml/model/trained_model.json`

### Model Development

- [Synthetic Dataset](https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/data/synthetic_neonatal_jaundice_dataset.csv): `ml/data/synthetic_neonatal_jaundice_dataset.csv`
- [Model Training](https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/train_and_export.py): `ml/model/train_and_export.py`
- [Python Predictor](https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/predict.py): `ml/model/predict.py`
- [Logistic Regression](https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/logistic_regression.py): `ml/model/logistic_regression.py`
- [Random Forest](https://github.com/phil27-gotchu/jaundice_detection/blob/main/ml/model/random_forest.py): `ml/model/random_forest.py`

### Other components

- **Operator**
- **RGB Probe**
- **OLED Display**
- **SD Card Log**
- **Browser**

## Connections

- Operator → Probe Firmware: presses button (evidence: `README.md`)
- Probe Firmware → RGB Probe: measures RGB (evidence: `README.md`)
- Probe Firmware → OLED Display: shows results (evidence: `README.md`)
- Probe Firmware → SD Card Log: appends readings (evidence: `README.md`)
- Probe Firmware → Local API: POSTs readings (evidence: `README.md`)
- Browser → Local API: polls dashboard (evidence: `README.md`)
- Local API → Dashboard Renderer: renders page (evidence: `server/index.js`)
- Local API → JS Predictor: predicts risk (evidence: `server/index.js`)
- Cloudflare API → Dashboard Renderer: renders page (evidence: `cloudflare/src/index.ts`)
- Cloudflare API → Readings KV: reads and writes (evidence: `cloudflare/src/index.ts`)
- Cloudflare API → Dashboard Template: fetches template (evidence: `cloudflare/src/index.ts`)
- Dashboard Renderer → JS Predictor: predicts readings (evidence: `shared/dashboard.js`)
- Model Training → Synthetic Dataset: loads data (evidence: `ml/model/train_and_export.py`)
- Model Training → Trained Model: exports parameters (evidence: `ml/model/train_and_export.py`)
- JS Predictor → Trained Model: loads model (evidence: `shared/mlPredictor.js`)
