# sheh0429/water-potability-system architecture

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

- Interactive diagram: https://gitdiagram.com/sheh0429/water-potability-system
- Repository: https://github.com/sheh0429/water-potability-system

## Overview

Sibu AquaML simulates local water readings, sends them to a prediction API, classifies water quality with a Random Forest model, and logs results for dashboard monitoring. The Streamlit dashboard also supports community anomaly reports. Model evaluation is a separate capability that scores the saved model against the supplied dataset. The source excerpts show the main calls and database operations; the Supabase service schema and unsampled model internals are not shown.

Main entry points: [`evaluate_model.py`](https://github.com/sheh0429/water-potability-system/blob/main/evaluate_model.py) (Model Evaluation), [`main.py`](https://github.com/sheh0429/water-potability-system/blob/main/main.py) (Prediction API), [`dashboard.py`](https://github.com/sheh0429/water-potability-system/blob/main/dashboard.py) (Live Dashboard), [`random_forest_sibu.pkl`](https://github.com/sheh0429/water-potability-system/blob/main/random_forest_sibu.pkl) (Random Forest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Reading Ingestion"]
  node_simulator["Sensor Simulator<br/>[simulator.py]"]
end

subgraph group_prediction["Prediction API"]
  node_api["Prediction API<br/>[main.py]"]
  node_model["Random Forest"]
end

subgraph group_monitoring["Monitoring Dashboard"]
  node_dashboard["Live Dashboard<br/>[dashboard.py]"]
  node_reports["Community Reports<br/>[dashboard.py]"]
end

subgraph group_evaluation["Model Evaluation"]
  node_evaluation["Model Evaluation<br/>[evaluate_model.py]"]
  node_dataset["Water Dataset"]
  node_metrics["Evaluation Visualizations<br/>[evaluate_model.py]"]
end

node_readings[("Water Readings")]
node_residents(("Permai Residents"))
node_supabase[("Supabase")]

node_simulator -->|"posts readings"| node_api
node_api -->|"predicts with"| node_model
node_api -->|"logs results"| node_readings
node_readings -->|"stored in"| node_supabase
node_dashboard -->|"queries readings"| node_supabase
node_dashboard -->|"renders telemetry"| node_readings
node_residents -->|"submit observations"| node_reports
node_reports -->|"inserts and queries"| node_supabase
node_evaluation -->|"loads model"| node_model
node_evaluation -->|"loads test data"| node_dataset
node_evaluation -->|"generates metrics"| node_metrics

click node_simulator "https://github.com/sheh0429/water-potability-system/blob/main/simulator.py"
click node_api "https://github.com/sheh0429/water-potability-system/blob/main/main.py"
click node_model "https://github.com/sheh0429/water-potability-system/blob/main/random_forest_sibu.pkl"
click node_dashboard "https://github.com/sheh0429/water-potability-system/blob/main/dashboard.py"
click node_reports "https://github.com/sheh0429/water-potability-system/blob/main/dashboard.py"
click node_evaluation "https://github.com/sheh0429/water-potability-system/blob/main/evaluate_model.py"
click node_dataset "https://github.com/sheh0429/water-potability-system/blob/main/sibu_water_dataset.csv"
click node_metrics "https://github.com/sheh0429/water-potability-system/blob/main/evaluate_model.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_simulator toneBlue
class node_api,node_model,node_readings,node_supabase toneAmber
class node_dashboard,node_reports toneMint
class node_evaluation,node_dataset,node_metrics toneRose
class node_residents toneIndigo
```

## Components

### Reading Ingestion

- [Sensor Simulator](https://github.com/sheh0429/water-potability-system/blob/main/simulator.py): `simulator.py`

### Prediction API

- [Prediction API](https://github.com/sheh0429/water-potability-system/blob/main/main.py): `main.py`
- [Random Forest](https://github.com/sheh0429/water-potability-system/blob/main/random_forest_sibu.pkl): `random_forest_sibu.pkl`

### Monitoring Dashboard

- [Live Dashboard](https://github.com/sheh0429/water-potability-system/blob/main/dashboard.py): `dashboard.py`
- [Community Reports](https://github.com/sheh0429/water-potability-system/blob/main/dashboard.py): `dashboard.py`

### Model Evaluation

- [Model Evaluation](https://github.com/sheh0429/water-potability-system/blob/main/evaluate_model.py): `evaluate_model.py`
- [Water Dataset](https://github.com/sheh0429/water-potability-system/blob/main/sibu_water_dataset.csv): `sibu_water_dataset.csv`
- [Evaluation Visualizations](https://github.com/sheh0429/water-potability-system/blob/main/evaluate_model.py): `evaluate_model.py`

### Other components

- **Water Readings**
- **Permai Residents**
- **Supabase**

## Connections

- Sensor Simulator → Prediction API: posts readings (evidence: `simulator.py`)
- Prediction API → Random Forest: predicts with (evidence: `main.py`)
- Prediction API → Water Readings: logs results (evidence: `main.py`)
- Water Readings → Supabase: stored in
- Live Dashboard → Supabase: queries readings (evidence: `dashboard.py`)
- Live Dashboard → Water Readings: renders telemetry (evidence: `dashboard.py`)
- Permai Residents → Community Reports: submit observations (evidence: `dashboard.py`)
- Community Reports → Supabase: inserts and queries (evidence: `dashboard.py`)
- Model Evaluation → Random Forest: loads model (evidence: `evaluate_model.py`)
- Model Evaluation → Water Dataset: loads test data (evidence: `evaluate_model.py`)
- Model Evaluation → Evaluation Visualizations: generates metrics (evidence: `evaluate_model.py`)
