# harisudhan005/mineguard-ai architecture

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

- Interactive diagram: https://gitdiagram.com/harisudhan005/mineguard-ai
- Repository: https://github.com/harisudhan005/mineguard-ai

## Overview

MineGuard AI is presented as an open-pit mine safety dashboard combining sensor readings and slope-image crack analysis into a risk assessment, with alerts, weather context, and an AI assistant. The documented workflow is to upload sensor CSV data and an image, view the analysis on the dashboard, and optionally ask the assistant about it. The repository also contains a YOLO-labeled mine-crack dataset and several historical UI/backend snapshots. The main backend excerpt confirms upload analysis, weather lookup, vision inference, and Ollama chat; other UI capabilities are documented but not all implementation details are shown.

Main entry points: [`app.py`](https://github.com/harisudhan005/mineguard-ai/blob/main/app.py) (Flask analysis API), [`script.js`](https://github.com/harisudhan005/mineguard-ai/blob/main/script.js) (Dashboard UI), [`Snapshot/postchatbot/script.js`](https://github.com/harisudhan005/mineguard-ai/blob/main/Snapshot/postchatbot/script.js) (Assistant UI), [`Mine-crack-datasets-1`](https://github.com/harisudhan005/mineguard-ai/tree/main/Mine-crack-datasets-1) (Labeled crack dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Dashboard experience"]
  node_dashboard["Dashboard UI<br/>[script.js]"]
  node_alerts["Alert management<br/>[script.js]"]
  node_assistant_ui["Assistant UI<br/>[script.js]"]
end

subgraph group_analysis["Risk analysis"]
  node_backend["Flask analysis API<br/>[app.py]"]
  node_numerical["Sensor risk model<br/>[app.py]"]
  node_crack_detection["Crack detection<br/>[app.py]"]
  node_weather_context["Weather context<br/>[app.py]"]
  node_response_enrichment["Risk response enrichment<br/>[app.py]"]
end

subgraph group_inputs["Analysis inputs"]
  node_training_data["Labeled crack dataset"]
  node_dataset_config["Dataset configuration<br/>[data.yaml]"]
  node_sensor_upload["Sensor CSV upload"]
  node_slope_image["Slope image upload"]
end

subgraph group_integrations["External services"]
  node_weather_api["WeatherAPI"]
  node_yolo["Ultralytics YOLO"]
  node_ollama["Ollama Phi-3"]
end

node_user(("Mine operator"))

node_user -->|"uses"| node_dashboard
node_user -->|"uploads CSV"| node_sensor_upload
node_user -->|"uploads image"| node_slope_image
node_dashboard -.->|"requests analysis"| node_backend
node_backend -->|"reads CSV"| node_sensor_upload
node_backend -->|"saves image"| node_slope_image
node_backend -->|"predicts risk"| node_numerical
node_backend -->|"infers cracks"| node_crack_detection
node_crack_detection -->|"runs inference"| node_yolo
node_backend -->|"fetches weather"| node_weather_context
node_weather_context -->|"requests conditions"| node_weather_api
node_backend -.->|"builds response"| node_response_enrichment
node_backend -.->|"returns risk data"| node_dashboard
node_dashboard -.->|"updates alerts"| node_alerts
node_user -->|"asks questions"| node_assistant_ui
node_assistant_ui -.->|"sends question"| node_backend
node_backend -->|"posts chat prompt"| node_ollama
node_backend -.->|"returns reply"| node_assistant_ui
node_training_data -.->|"configured by"| node_dataset_config

click node_dashboard "https://github.com/harisudhan005/mineguard-ai/blob/main/script.js"
click node_alerts "https://github.com/harisudhan005/mineguard-ai/blob/main/Snapshot/postAlertUi/script.js"
click node_assistant_ui "https://github.com/harisudhan005/mineguard-ai/blob/main/Snapshot/postchatbot/script.js"
click node_backend "https://github.com/harisudhan005/mineguard-ai/blob/main/app.py"
click node_numerical "https://github.com/harisudhan005/mineguard-ai/blob/main/app.py"
click node_crack_detection "https://github.com/harisudhan005/mineguard-ai/blob/main/app.py"
click node_weather_context "https://github.com/harisudhan005/mineguard-ai/blob/main/app.py"
click node_response_enrichment "https://github.com/harisudhan005/mineguard-ai/blob/main/app.py"
click node_training_data "https://github.com/harisudhan005/mineguard-ai/tree/main/Mine-crack-datasets-1"
click node_dataset_config "https://github.com/harisudhan005/mineguard-ai/blob/main/Mine-crack-datasets-1/data.yaml"

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_dashboard,node_alerts,node_assistant_ui toneBlue
class node_backend,node_numerical,node_crack_detection,node_weather_context,node_response_enrichment toneAmber
class node_training_data,node_dataset_config,node_sensor_upload,node_slope_image toneMint
class node_weather_api,node_yolo,node_ollama toneRose
class node_user toneIndigo
```

## Components

### Dashboard experience

- [Dashboard UI](https://github.com/harisudhan005/mineguard-ai/blob/main/script.js): `script.js`
- [Alert management](https://github.com/harisudhan005/mineguard-ai/blob/main/Snapshot/postAlertUi/script.js): `Snapshot/postAlertUi/script.js`
- [Assistant UI](https://github.com/harisudhan005/mineguard-ai/blob/main/Snapshot/postchatbot/script.js): `Snapshot/postchatbot/script.js`

### Risk analysis

- [Flask analysis API](https://github.com/harisudhan005/mineguard-ai/blob/main/app.py): `app.py`
- [Sensor risk model](https://github.com/harisudhan005/mineguard-ai/blob/main/app.py): `app.py`
- [Crack detection](https://github.com/harisudhan005/mineguard-ai/blob/main/app.py): `app.py`
- [Weather context](https://github.com/harisudhan005/mineguard-ai/blob/main/app.py): `app.py`
- [Risk response enrichment](https://github.com/harisudhan005/mineguard-ai/blob/main/app.py): `app.py`

### Analysis inputs

- [Labeled crack dataset](https://github.com/harisudhan005/mineguard-ai/tree/main/Mine-crack-datasets-1): `Mine-crack-datasets-1`
- [Dataset configuration](https://github.com/harisudhan005/mineguard-ai/blob/main/Mine-crack-datasets-1/data.yaml): `Mine-crack-datasets-1/data.yaml`
- **Sensor CSV upload**
- **Slope image upload**

### External services

- **WeatherAPI**
- **Ultralytics YOLO**
- **Ollama Phi-3**

### Other components

- **Mine operator**

## Connections

- Mine operator → Dashboard UI: uses
- Mine operator → Sensor CSV upload: uploads CSV
- Mine operator → Slope image upload: uploads image
- Dashboard UI → Flask analysis API: requests analysis
- Flask analysis API → Sensor CSV upload: reads CSV (evidence: `app.py`)
- Flask analysis API → Slope image upload: saves image (evidence: `app.py`)
- Flask analysis API → Sensor risk model: predicts risk (evidence: `app.py`)
- Flask analysis API → Crack detection: infers cracks (evidence: `app.py`)
- Crack detection → Ultralytics YOLO: runs inference (evidence: `app.py`)
- Flask analysis API → Weather context: fetches weather (evidence: `app.py`)
- Weather context → WeatherAPI: requests conditions (evidence: `app.py`)
- Flask analysis API → Risk response enrichment: builds response (evidence: `app.py`)
- Flask analysis API → Dashboard UI: returns risk data
- Dashboard UI → Alert management: updates alerts
- Mine operator → Assistant UI: asks questions
- Assistant UI → Flask analysis API: sends question
- Flask analysis API → Ollama Phi-3: posts chat prompt (evidence: `app.py`)
- Flask analysis API → Assistant UI: returns reply
- Labeled crack dataset → Dataset configuration: configured by
