# prathameshhhhhhh/dam-project architecture

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

- Interactive diagram: https://gitdiagram.com/prathameshhhhhhh/dam-project
- Repository: https://github.com/prathameshhhhhhh/dam-project

## Overview

DAM MONITOR AI PRO is a dam telemetry and flood-risk monitoring platform. Sensor or simulated readings enter the Flask API, are classified by the ML predictor with a time-to-critical estimate, and are persisted with predictions and risk-triggered alerts; the dashboard presents live status, history, and emergency controls. Separate data-preparation and training modules produce the model artifact used for inference. The README documents alert and threshold APIs and dashboard features, but their route implementations and several frontend/API calls were not sampled, so uncertain wiring is omitted.

Main entry points: [`backend/app.py`](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/app.py) (Flask Application), [`js/api.js`](https://github.com/prathameshhhhhhh/dam-project/blob/main/js/api.js) (API Client), [`backend/routes/sensor.py`](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/sensor.py) (Sensor API), [`backend/database.py`](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/database.py) (Database Layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telemetry["Telemetry Data"]
  node_generator["Telemetry Generator<br/>[generate_data.py]"]
  node_cleaner["Data Preprocessor<br/>[preprocess.py]"]
  node_csv["Telemetry Dataset<br/>[dam_data.csv]"]
end

subgraph group_risk["Risk Modeling"]
  node_trainer["Model Trainer<br/>[train_model.py]"]
  node_model["Random Forest Model<br/>[model.pkl]"]
  node_predictor["Risk Predictor<br/>[predict.py]"]
end

subgraph group_service["API and Persistence"]
  node_flask["Flask Application<br/>[app.py]"]
  node_sensor_api["Sensor API<br/>[sensor.py]"]
  node_prediction_api["Prediction API<br/>[prediction.py]"]
  node_alerts_api["Alerts API<br/>[alerts.py]"]
  node_settings_api["Settings API<br/>[settings.py]"]
  node_db_layer["Database Layer<br/>[database.py]"]
  node_database[("Monitoring Database<br/>[dam_monitor.db]")]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard["Monitoring Dashboard<br/>[index.html]"]
  node_dashboard_logic["Dashboard Logic<br/>[app.js]"]
  node_api_client["API Client<br/>[api.js]"]
end

node_sensors(("Sensors / Simulator"))
node_operator(("Dam Operator"))

node_generator -->|"writes dataset"| node_csv
node_csv -->|"loads data"| node_cleaner
node_trainer -->|"uses preprocessing"| node_cleaner
node_trainer -->|"saves model"| node_model
node_predictor -->|"loads model"| node_model
node_flask -->|"registers route"| node_sensor_api
node_flask -->|"registers route"| node_prediction_api
node_flask -->|"registers route"| node_alerts_api
node_flask -->|"registers route"| node_settings_api
node_flask -->|"serves page"| node_dashboard
node_sensors -->|"posts telemetry"| node_sensor_api
node_sensor_api -->|"runs inference"| node_predictor
node_sensor_api -->|"saves and reads"| node_db_layer
node_prediction_api -->|"runs inference"| node_predictor
node_prediction_api -->|"reads latest"| node_db_layer
node_alerts_api -->|"alert operations"| node_db_layer
node_settings_api -->|"threshold operations"| node_db_layer
node_db_layer -->|"reads and writes"| node_database
node_operator -->|"uses dashboard"| node_dashboard
node_dashboard -->|"hosts interface"| node_dashboard_logic
node_dashboard_logic -->|"requests data"| node_api_client
node_api_client -->|"sends telemetry"| node_sensor_api
node_api_client -->|"requests prediction"| node_prediction_api
node_api_client -->|"alert requests"| node_alerts_api
node_api_client -->|"threshold requests"| node_settings_api

click node_generator "https://github.com/prathameshhhhhhh/dam-project/blob/main/data/generate_data.py"
click node_cleaner "https://github.com/prathameshhhhhhh/dam-project/blob/main/data/preprocess.py"
click node_csv "https://github.com/prathameshhhhhhh/dam-project/blob/main/data/dam_data.csv"
click node_trainer "https://github.com/prathameshhhhhhh/dam-project/blob/main/ml/train_model.py"
click node_model "https://github.com/prathameshhhhhhh/dam-project/blob/main/ml/model.pkl"
click node_predictor "https://github.com/prathameshhhhhhh/dam-project/blob/main/ml/predict.py"
click node_flask "https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/app.py"
click node_sensor_api "https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/sensor.py"
click node_prediction_api "https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/prediction.py"
click node_alerts_api "https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/alerts.py"
click node_settings_api "https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/settings.py"
click node_db_layer "https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/database.py"
click node_database "https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/dam_monitor.db"
click node_dashboard "https://github.com/prathameshhhhhhh/dam-project/blob/main/index.html"
click node_dashboard_logic "https://github.com/prathameshhhhhhh/dam-project/blob/main/js/app.js"
click node_api_client "https://github.com/prathameshhhhhhh/dam-project/blob/main/js/api.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_generator,node_cleaner,node_csv toneBlue
class node_trainer,node_model,node_predictor toneAmber
class node_flask,node_sensor_api,node_prediction_api,node_alerts_api,node_settings_api,node_db_layer,node_database toneMint
class node_dashboard,node_dashboard_logic,node_api_client toneRose
class node_sensors,node_operator toneIndigo
```

## Components

### Telemetry Data

- [Telemetry Generator](https://github.com/prathameshhhhhhh/dam-project/blob/main/data/generate_data.py): `data/generate_data.py`
- [Data Preprocessor](https://github.com/prathameshhhhhhh/dam-project/blob/main/data/preprocess.py): `data/preprocess.py`
- [Telemetry Dataset](https://github.com/prathameshhhhhhh/dam-project/blob/main/data/dam_data.csv): `data/dam_data.csv`

### Risk Modeling

- [Model Trainer](https://github.com/prathameshhhhhhh/dam-project/blob/main/ml/train_model.py): `ml/train_model.py`
- [Random Forest Model](https://github.com/prathameshhhhhhh/dam-project/blob/main/ml/model.pkl): `ml/model.pkl`
- [Risk Predictor](https://github.com/prathameshhhhhhh/dam-project/blob/main/ml/predict.py): `ml/predict.py`

### API and Persistence

- [Flask Application](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/app.py): `backend/app.py`
- [Sensor API](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/sensor.py): `backend/routes/sensor.py`
- [Prediction API](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/prediction.py): `backend/routes/prediction.py`
- [Alerts API](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/alerts.py): `backend/routes/alerts.py`
- [Settings API](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/routes/settings.py): `backend/routes/settings.py`
- [Database Layer](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/database.py): `backend/database.py`
- [Monitoring Database](https://github.com/prathameshhhhhhh/dam-project/blob/main/backend/dam_monitor.db): `backend/dam_monitor.db`

### Dashboard

- [Monitoring Dashboard](https://github.com/prathameshhhhhhh/dam-project/blob/main/index.html): `index.html`
- [Dashboard Logic](https://github.com/prathameshhhhhhh/dam-project/blob/main/js/app.js): `js/app.js`
- [API Client](https://github.com/prathameshhhhhhh/dam-project/blob/main/js/api.js): `js/api.js`

### Other components

- **Sensors / Simulator**
- **Dam Operator**

## Connections

- Telemetry Generator → Telemetry Dataset: writes dataset
- Telemetry Dataset → Data Preprocessor: loads data
- Model Trainer → Data Preprocessor: uses preprocessing
- Model Trainer → Random Forest Model: saves model
- Risk Predictor → Random Forest Model: loads model
- Flask Application → Sensor API: registers route
- Flask Application → Prediction API: registers route
- Flask Application → Alerts API: registers route
- Flask Application → Settings API: registers route
- Flask Application → Monitoring Dashboard: serves page
- Sensors / Simulator → Sensor API: posts telemetry
- Sensor API → Risk Predictor: runs inference
- Sensor API → Database Layer: saves and reads
- Prediction API → Risk Predictor: runs inference
- Prediction API → Database Layer: reads latest
- Alerts API → Database Layer: alert operations
- Settings API → Database Layer: threshold operations
- Database Layer → Monitoring Database: reads and writes
- Dam Operator → Monitoring Dashboard: uses dashboard
- Monitoring Dashboard → Dashboard Logic: hosts interface
- Dashboard Logic → API Client: requests data
- API Client → Sensor API: sends telemetry
- API Client → Prediction API: requests prediction
- API Client → Alerts API: alert requests
- API Client → Settings API: threshold requests
