# vinayak2006tech/sih-moil architecture

> Architecture diagram of the GitHub repository vinayak2006tech/sih-moil, 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/vinayak2006tech/sih-moil
- Repository: https://github.com/vinayak2006tech/sih-moil

## Overview

MOIL ReserveIQ combines a mine-intelligence dashboard with an authenticated API, persistent mine data, and an ML service. The user workflow runs from selecting a mine and viewing reserve, production, shortfall, and recommendation insights to uploading operational data or synchronizing satellite observations. The README documents the REST and ML-service boundaries; source excerpts show ingestion parsing and storage, plus frontend context/API usage. Several feature pages and backend controllers are indexed but not excerpted, so their internal calls are not expanded.

Main entry points: [`frontend/src/services/api.ts`](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/services/api.ts) (API client), [`frontend/src/App.tsx`](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/App.tsx) (App and navigation), [`ml-service/app/main.py`](https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/main.py) (ML service API), [`backend/src/controllers/ingestionController.ts`](https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/controllers/ingestionController.ts) (Ingestion handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["App and navigation<br/>[App.tsx]"]
  node_minecontext["Mine selection<br/>[MineContext.tsx]"]
  node_authcontext["User session<br/>[AuthContext.tsx]"]
  node_insights["Mine insights"]
  node_reserveview["Reserve mapping<br/>[ReserveMapPage.tsx]"]
  node_ingestionview["Data ingestion<br/>[IngestionPage.tsx]"]
  node_provenance["Source registry"]
  node_apiclient["API client<br/>[api.ts]"]
end

subgraph group_api["Backend API"]
  node_rest["REST endpoints"]
  node_ingestion["Ingestion handlers"]
  node_auth["Access control<br/>[auth.ts]"]
  node_mlclient["ML client<br/>[mlClient.ts]"]
end

subgraph group_data["Operational data"]
  node_store[("Mine data store<br/>[store.ts]")]
  node_csv["CSV parser<br/>[csvParser.ts]"]
  node_externaldata["Public and operational sources"]
end

subgraph group_ml["Intelligence services"]
  node_mlapi["ML service API<br/>[main.py]"]
  node_reserveengine["Reserve estimation"]
  node_shortfallengine["Shortfall prediction"]
  node_recommendations["Prescriptive actions"]
  node_satellite["Satellite processing"]
end

node_planner(("Mine user"))

node_planner -->|"uses"| node_app
node_app -->|"provides context"| node_minecontext
node_app -->|"provides session"| node_authcontext
node_app -->|"routes to"| node_insights
node_app -->|"routes to"| node_reserveview
node_minecontext -->|"fetches mines"| node_apiclient
node_authcontext -->|"requests auth"| node_apiclient
node_insights -.->|"requests insights"| node_apiclient
node_reserveview -->|"requests reserve data"| node_apiclient
node_ingestionview -.->|"uploads data"| node_apiclient
node_apiclient -->|"calls REST API"| node_rest
node_rest -->|"routes uploads"| node_ingestion
node_rest -->|"guards uploads"| node_auth
node_ingestion -->|"parses files"| node_csv
node_ingestion -->|"writes records"| node_store
node_ingestion -->|"uses ML client"| node_mlclient
node_mlclient -->|"sends HTTP requests"| node_mlapi
node_mlapi -->|"dispatches estimation"| node_reserveengine
node_mlapi -->|"dispatches prediction"| node_shortfallengine
node_mlapi -->|"dispatches actions"| node_recommendations
node_mlapi -->|"dispatches processing"| node_satellite
node_externaldata -.->|"supplies uploads"| node_ingestion

click node_app "https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/App.tsx"
click node_minecontext "https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/context/MineContext.tsx"
click node_authcontext "https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/context/AuthContext.tsx"
click node_insights "https://github.com/vinayak2006tech/sih-moil/tree/main/frontend/src/pages"
click node_reserveview "https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/pages/ReserveMapPage.tsx"
click node_ingestionview "https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/pages/IngestionPage.tsx"
click node_provenance "https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/pages/DataSourcesPage.tsx"
click node_apiclient "https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/services/api.ts"
click node_rest "https://github.com/vinayak2006tech/sih-moil/tree/main/backend/src/routes"
click node_ingestion "https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/controllers/ingestionController.ts"
click node_auth "https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/middleware/auth.ts"
click node_mlclient "https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/services/mlClient.ts"
click node_store "https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/services/store.ts"
click node_csv "https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/services/csvParser.ts"
click node_mlapi "https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/main.py"
click node_reserveengine "https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/services/reserve_estimation.py"
click node_shortfallengine "https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/services/shortfall_prediction.py"
click node_recommendations "https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/services/recommendation_engine.py"
click node_satellite "https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/services/satellite_processor.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_app,node_minecontext,node_authcontext,node_insights,node_reserveview,node_ingestionview,node_provenance,node_apiclient,node_planner toneBlue
class node_rest,node_ingestion,node_auth,node_mlclient toneAmber
class node_store,node_csv,node_externaldata toneMint
class node_mlapi,node_reserveengine,node_shortfallengine,node_recommendations,node_satellite toneRose
```

## Components

### Web application

- [App and navigation](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Mine selection](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/context/MineContext.tsx): `frontend/src/context/MineContext.tsx`
- [User session](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Mine insights](https://github.com/vinayak2006tech/sih-moil/tree/main/frontend/src/pages): `frontend/src/pages`
- [Reserve mapping](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/pages/ReserveMapPage.tsx): `frontend/src/pages/ReserveMapPage.tsx`
- [Data ingestion](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/pages/IngestionPage.tsx): `frontend/src/pages/IngestionPage.tsx`
- [Source registry](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/pages/DataSourcesPage.tsx): `frontend/src/pages/DataSourcesPage.tsx`
- [API client](https://github.com/vinayak2006tech/sih-moil/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### Backend API

- [REST endpoints](https://github.com/vinayak2006tech/sih-moil/tree/main/backend/src/routes): `backend/src/routes`
- [Ingestion handlers](https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/controllers/ingestionController.ts): `backend/src/controllers/ingestionController.ts`
- [Access control](https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`
- [ML client](https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/services/mlClient.ts): `backend/src/services/mlClient.ts`

### Operational data

- [Mine data store](https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/services/store.ts): `backend/src/services/store.ts`
- [CSV parser](https://github.com/vinayak2006tech/sih-moil/blob/main/backend/src/services/csvParser.ts): `backend/src/services/csvParser.ts`
- **Public and operational sources**

### Intelligence services

- [ML service API](https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/main.py): `ml-service/app/main.py`
- [Reserve estimation](https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/services/reserve_estimation.py): `ml-service/app/services/reserve_estimation.py`
- [Shortfall prediction](https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/services/shortfall_prediction.py): `ml-service/app/services/shortfall_prediction.py`
- [Prescriptive actions](https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/services/recommendation_engine.py): `ml-service/app/services/recommendation_engine.py`
- [Satellite processing](https://github.com/vinayak2006tech/sih-moil/blob/main/ml-service/app/services/satellite_processor.py): `ml-service/app/services/satellite_processor.py`

### Other components

- **Mine user**

## Connections

- Mine user → App and navigation: uses (evidence: `README.md`)
- App and navigation → Mine selection: provides context (evidence: `frontend/src/App.tsx`)
- App and navigation → User session: provides session (evidence: `frontend/src/App.tsx`)
- App and navigation → Mine insights: routes to (evidence: `frontend/src/App.tsx`)
- App and navigation → Reserve mapping: routes to (evidence: `frontend/src/App.tsx`)
- Mine selection → API client: fetches mines (evidence: `frontend/src/context/MineContext.tsx`)
- User session → API client: requests auth (evidence: `frontend/src/context/AuthContext.tsx`)
- Mine insights → API client: requests insights (evidence: `frontend/src/pages/IngestionPage.tsx`)
- Reserve mapping → API client: requests reserve data (evidence: `frontend/src/pages/ReserveMapPage.tsx`)
- Data ingestion → API client: uploads data (evidence: `frontend/src/pages/IngestionPage.tsx`)
- API client → REST endpoints: calls REST API (evidence: `README.md`)
- REST endpoints → Ingestion handlers: routes uploads (evidence: `backend/src/routes/ingestionRoutes.ts`)
- REST endpoints → Access control: guards uploads (evidence: `backend/src/routes/ingestionRoutes.ts`)
- Ingestion handlers → CSV parser: parses files (evidence: `backend/src/controllers/ingestionController.ts`)
- Ingestion handlers → Mine data store: writes records (evidence: `backend/src/controllers/ingestionController.ts`)
- Ingestion handlers → ML client: uses ML client (evidence: `backend/src/controllers/ingestionController.ts`)
- ML client → ML service API: sends HTTP requests (evidence: `README.md`)
- ML service API → Reserve estimation: dispatches estimation (evidence: `ml-service/app/main.py`)
- ML service API → Shortfall prediction: dispatches prediction (evidence: `ml-service/app/main.py`)
- ML service API → Prescriptive actions: dispatches actions (evidence: `ml-service/app/main.py`)
- ML service API → Satellite processing: dispatches processing (evidence: `ml-service/app/main.py`)
- Public and operational sources → Ingestion handlers: supplies uploads
