# pratiktekale2005-max/manga-ai architecture

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

- Interactive diagram: https://gitdiagram.com/pratiktekale2005-max/manga-ai
- Repository: https://github.com/pratiktekale2005-max/manga-ai

## Overview

MOIL’s platform turns mine datasets into exploration, resource, risk, and production-planning decision support. The documented five-view journey runs from an executive dashboard through AI analysis and block inspection to consolidated risk review and reports; the broader product also covers satellite indices, geology, equipment, forecasting, optimization, scenarios, and recommendations. The map shows the central state service as the backend inference hub. Some domain pages and API routers were not excerpted, so their internal call paths are not asserted.

Main entry points: [`backend/app/services/state_service.py`](https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/services/state_service.py) (Mine State Service), [`frontend/src/App.jsx`](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/App.jsx) (Workflow Shell), [`backend/app/api`](https://github.com/pratiktekale2005-max/manga-ai/tree/main/backend/app/api) (Domain API Routers), [`frontend/src/services/api.js`](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/services/api.js) (API Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Mine Intelligence UI"]
  node_app["Workflow Shell<br/>[App.jsx]"]
  node_context["Mine Context<br/>[MineContext.jsx]"]
  node_api_client["API Client<br/>[api.js]"]
  node_dashboard["Executive Dashboard<br/>[Dashboard.jsx]"]
  node_analysis["AI Analysis Workflow"]
  node_block_explorer["Block Model Explorer"]
  node_risk_view["Risk Review"]
  node_reports_view["Reports View<br/>[Reports.jsx]"]
  node_domain_views["Domain Analysis Views"]
end

subgraph group_backend["API and Mine State"]
  node_fastapi["FastAPI Entrypoint<br/>[main.py]"]
  node_api_routes["Domain API Routers"]
  node_state["Mine State Service<br/>[state_service.py]"]
  node_database[("SQLite Database<br/>[database.py]")]
  node_config["Application Settings<br/>[config.py]"]
end

subgraph group_data["Mining Data Preparation"]
  node_demo_data["Mine Dataset Generator"]
  node_cleaner["Data Quality Cleaning<br/>[data_cleaner.py]"]
  node_satellite["Spectral Indices"]
end

subgraph group_models["Decision Engines"]
  node_grade["Grade Prediction<br/>[grade_predictor.py]"]
  node_spatial["Spatial Estimation"]
  node_blocks["Block Reserves<br/>[block_modeler.py]"]
  node_exploration["Exploration Priority"]
end

subgraph group_outputs["Planning and Reporting"]
  node_production["Production Forecast"]
  node_equipment["Equipment Intelligence"]
  node_anomaly["Anomaly Detection"]
  node_risk["Composite Risk<br/>[risk_engine.py]"]
  node_optimizer["Extraction Optimizer"]
  node_scenario["Scenario Simulator"]
  node_recommendations["Recommendations"]
end

node_engineer(("Mine Engineer"))

node_engineer -->|"uses"| node_app
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_analysis
node_app -->|"renders"| node_block_explorer
node_app -->|"renders"| node_risk_view
node_app -->|"renders"| node_reports_view
node_app -->|"provides mine state"| node_context
node_context -->|"requests mine data"| node_api_client
node_dashboard -->|"requests dashboard data"| node_api_client
node_analysis -->|"requests analysis"| node_api_client
node_block_explorer -->|"requests blocks"| node_api_client
node_reports_view -->|"requests reports"| node_api_client
node_api_client -->|"calls HTTP endpoints"| node_api_routes
node_fastapi -->|"registers routers"| node_api_routes
node_fastapi -->|"initializes service"| node_state
node_fastapi -->|"initializes database"| node_database
node_fastapi -->|"reads settings"| node_config
node_api_routes -->|"serves mine operations"| node_state
node_api_routes -->|"serves grade prediction"| node_state
node_api_routes -->|"builds report data"| node_state
node_state -->|"loads mine datasets"| node_demo_data
node_state -->|"cleans datasets"| node_cleaner
node_state -->|"computes indices"| node_satellite
node_state -->|"runs inference"| node_grade
node_state -->|"runs estimation"| node_spatial
node_state -->|"runs reserve model"| node_blocks
node_state -->|"ranks targets"| node_exploration
node_state -->|"runs forecasts"| node_production
node_state -->|"assesses fleet"| node_equipment
node_state -->|"detects anomalies"| node_anomaly
node_state -->|"computes risk"| node_risk
node_state -->|"plans extraction"| node_optimizer
node_state -->|"simulates scenarios"| node_scenario
node_state -->|"generates advice"| node_recommendations
node_api_routes -.->|"supports domain analysis"| node_domain_views
node_state -.->|"persists selected state"| node_database

click node_app "https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/App.jsx"
click node_context "https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/context/MineContext.jsx"
click node_api_client "https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/services/api.js"
click node_dashboard "https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/Dashboard.jsx"
click node_analysis "https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/AIAnalysisWorkflow.jsx"
click node_block_explorer "https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/BlockModelExplorer.jsx"
click node_risk_view "https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/RiskAnalysisConsolidated.jsx"
click node_reports_view "https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/Reports.jsx"
click node_domain_views "https://github.com/pratiktekale2005-max/manga-ai/tree/main/frontend/src/pages"
click node_fastapi "https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/main.py"
click node_api_routes "https://github.com/pratiktekale2005-max/manga-ai/tree/main/backend/app/api"
click node_state "https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/services/state_service.py"
click node_database "https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/core/database.py"
click node_config "https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/core/config.py"
click node_demo_data "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/data/generate_demo_data.py"
click node_cleaner "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/preprocessing/data_cleaner.py"
click node_satellite "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/satellite/spectral_indices.py"
click node_grade "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/grade_predictor.py"
click node_spatial "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/spatial_interpolator.py"
click node_blocks "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/block_modeler.py"
click node_exploration "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/exploration_prioritizer.py"
click node_production "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/production_forecaster.py"
click node_equipment "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/equipment_analyzer.py"
click node_anomaly "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/anomaly_detector.py"
click node_risk "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/risk_engine.py"
click node_optimizer "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/production_optimizer.py"
click node_scenario "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/scenario_simulator.py"
click node_recommendations "https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/recommendations_engine.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_context,node_api_client,node_dashboard,node_analysis,node_block_explorer,node_risk_view,node_reports_view,node_domain_views toneBlue
class node_fastapi,node_api_routes,node_state,node_database,node_config toneAmber
class node_demo_data,node_cleaner,node_satellite toneMint
class node_grade,node_spatial,node_blocks,node_exploration toneRose
class node_production,node_equipment,node_anomaly,node_risk,node_optimizer,node_scenario,node_recommendations,node_engineer toneIndigo
```

## Components

### Mine Intelligence UI

- [Workflow Shell](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Mine Context](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/context/MineContext.jsx): `frontend/src/context/MineContext.jsx`
- [API Client](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Executive Dashboard](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [AI Analysis Workflow](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/AIAnalysisWorkflow.jsx): `frontend/src/pages/AIAnalysisWorkflow.jsx`
- [Block Model Explorer](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/BlockModelExplorer.jsx): `frontend/src/pages/BlockModelExplorer.jsx`
- [Risk Review](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/RiskAnalysisConsolidated.jsx): `frontend/src/pages/RiskAnalysisConsolidated.jsx`
- [Reports View](https://github.com/pratiktekale2005-max/manga-ai/blob/main/frontend/src/pages/Reports.jsx): `frontend/src/pages/Reports.jsx`
- [Domain Analysis Views](https://github.com/pratiktekale2005-max/manga-ai/tree/main/frontend/src/pages): `frontend/src/pages`

### API and Mine State

- [FastAPI Entrypoint](https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Domain API Routers](https://github.com/pratiktekale2005-max/manga-ai/tree/main/backend/app/api): `backend/app/api`
- [Mine State Service](https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/services/state_service.py): `backend/app/services/state_service.py`
- [SQLite Database](https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Application Settings](https://github.com/pratiktekale2005-max/manga-ai/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### Mining Data Preparation

- [Mine Dataset Generator](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/data/generate_demo_data.py): `ml/data/generate_demo_data.py`
- [Data Quality Cleaning](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/preprocessing/data_cleaner.py): `ml/preprocessing/data_cleaner.py`
- [Spectral Indices](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/satellite/spectral_indices.py): `ml/satellite/spectral_indices.py`

### Decision Engines

- [Grade Prediction](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/grade_predictor.py): `ml/models/grade_predictor.py`
- [Spatial Estimation](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/spatial_interpolator.py): `ml/models/spatial_interpolator.py`
- [Block Reserves](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/block_modeler.py): `ml/models/block_modeler.py`
- [Exploration Priority](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/exploration_prioritizer.py): `ml/models/exploration_prioritizer.py`

### Planning and Reporting

- [Production Forecast](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/production_forecaster.py): `ml/models/production_forecaster.py`
- [Equipment Intelligence](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/equipment_analyzer.py): `ml/models/equipment_analyzer.py`
- [Anomaly Detection](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/anomaly_detector.py): `ml/models/anomaly_detector.py`
- [Composite Risk](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/risk_engine.py): `ml/models/risk_engine.py`
- [Extraction Optimizer](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/production_optimizer.py): `ml/models/production_optimizer.py`
- [Scenario Simulator](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/scenario_simulator.py): `ml/models/scenario_simulator.py`
- [Recommendations](https://github.com/pratiktekale2005-max/manga-ai/blob/main/ml/models/recommendations_engine.py): `ml/models/recommendations_engine.py`

### Other components

- **Mine Engineer**

## Connections

- Mine Engineer → Workflow Shell: uses (evidence: `README.md`)
- Workflow Shell → Executive Dashboard: renders (evidence: `frontend/src/App.jsx`)
- Workflow Shell → AI Analysis Workflow: renders (evidence: `frontend/src/App.jsx`)
- Workflow Shell → Block Model Explorer: renders (evidence: `frontend/src/App.jsx`)
- Workflow Shell → Risk Review: renders (evidence: `frontend/src/App.jsx`)
- Workflow Shell → Reports View: renders (evidence: `frontend/src/App.jsx`)
- Workflow Shell → Mine Context: provides mine state (evidence: `frontend/src/App.jsx`)
- Mine Context → API Client: requests mine data (evidence: `frontend/src/context/MineContext.jsx`)
- Executive Dashboard → API Client: requests dashboard data (evidence: `frontend/src/pages/Dashboard.jsx`)
- AI Analysis Workflow → API Client: requests analysis (evidence: `frontend/src/pages/AIAnalysisWorkflow.jsx`)
- Block Model Explorer → API Client: requests blocks (evidence: `frontend/src/pages/BlockModelExplorer.jsx`)
- Reports View → API Client: requests reports (evidence: `frontend/src/pages/Reports.jsx`)
- API Client → Domain API Routers: calls HTTP endpoints (evidence: `frontend/src/services/api.js`)
- FastAPI Entrypoint → Domain API Routers: registers routers (evidence: `backend/app/main.py`)
- FastAPI Entrypoint → Mine State Service: initializes service (evidence: `backend/app/main.py`)
- FastAPI Entrypoint → SQLite Database: initializes database (evidence: `backend/app/main.py`)
- FastAPI Entrypoint → Application Settings: reads settings (evidence: `backend/app/main.py`)
- Domain API Routers → Mine State Service: serves mine operations (evidence: `backend/app/api/data.py`)
- Domain API Routers → Mine State Service: serves grade prediction (evidence: `backend/app/api/grade_prediction.py`)
- Domain API Routers → Mine State Service: builds report data (evidence: `backend/app/api/reports.py`)
- Mine State Service → Mine Dataset Generator: loads mine datasets (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Data Quality Cleaning: cleans datasets (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Spectral Indices: computes indices (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Grade Prediction: runs inference (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Spatial Estimation: runs estimation (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Block Reserves: runs reserve model (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Exploration Priority: ranks targets (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Production Forecast: runs forecasts (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Equipment Intelligence: assesses fleet (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Anomaly Detection: detects anomalies (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Composite Risk: computes risk (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Extraction Optimizer: plans extraction (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Scenario Simulator: simulates scenarios (evidence: `backend/app/services/state_service.py`)
- Mine State Service → Recommendations: generates advice (evidence: `backend/app/services/state_service.py`)
- Domain API Routers → Domain Analysis Views: supports domain analysis
- Mine State Service → SQLite Database: persists selected state
