# gauravpanjwani889/finalyearproject architecture

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

- Interactive diagram: https://gitdiagram.com/gauravpanjwani889/finalyearproject
- Repository: https://github.com/gauravpanjwani889/finalyearproject

## Overview

This is a Smart Grid stability and fault-diagnosis platform. Operators configure grid and protection parameters in the dashboard, submit a simulation, and receive Simulink-derived waveforms, electrical metrics, breaker telemetry, and ML fault diagnosis; they can also inspect past runs and model health. The graph includes the frontend, backend orchestration and analytics, the MATLAB/Simulink engine, and the ML diagnosis branch. Several feature modules are represented from the README and source index; their internal wiring is omitted where the excerpts do not establish it.

Main entry points: [`backend/routes.py`](https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/routes.py) (Simulation Routes), [`frontend/src/views`](https://github.com/gauravpanjwani889/finalyearproject/tree/main/frontend/src/views) (Monitoring Views), [`frontend/src/App.tsx`](https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/App.tsx) (Dashboard Shell), [`fault_ml/api_router.py`](https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/api_router.py) (ML API & Run Results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Operator Dashboard"]
  node_app["Dashboard Shell<br/>[App.tsx]"]
  node_controls["Grid Controls<br/>[ControlsView.tsx]"]
  node_views["Monitoring Views"]
  node_network["Network Schematic"]
  node_tripchart["Breaker Telemetry"]
  node_waveforms["Waveform Charts<br/>[WaveformChart.tsx]"]
  node_diagnostics["Diagnosis Card"]
  node_api_client["Typed API Client<br/>[api.ts]"]
end

subgraph group_api["Backend API"]
  node_backend_app["FastAPI Application<br/>[main.py]"]
  node_routes["Simulation Routes<br/>[routes.py]"]
  node_schemas["Request &amp; Result Schemas<br/>[models.py]"]
  node_run_store[("Run Result Store<br/>[routes.py]")]
end

subgraph group_simulation["Simulation &amp; Analytics"]
  node_runner["Simulation Runner<br/>[sim_runner.py]"]
  node_matlab_manager["MATLAB Session Manager<br/>[matlab_engine.py]"]
  node_simulink["Simulink Solver<br/>[main_model.slx]"]
  node_analytics["Electrical Analytics<br/>[analytics.py]"]
end

subgraph group_diagnosis["ML Diagnosis"]
  node_ml_router["ML API &amp; Run Results<br/>[api_router.py]"]
  node_predictor["Fault Predictor<br/>[ml_predict.py]"]
  node_ml_features["Signal Features<br/>[ml_features.py]"]
  node_ml_signals["Signal Preparation<br/>[ml_signals.py]"]
  node_training["Classifier Training<br/>[train.py]"]
end

node_operator(("Grid Operator"))
node_matlab["MATLAB Engine"]

node_operator -->|"configures"| node_controls
node_controls -->|"updates parameters"| node_app
node_app -->|"submits simulation"| node_api_client
node_api_client -->|"HTTP requests"| node_routes
node_backend_app -->|"mounts routes"| node_routes
node_backend_app -->|"mounts routes"| node_ml_router
node_routes -->|"validates &amp; returns"| node_schemas
node_routes -->|"runs simulation"| node_runner
node_runner -->|"uses session"| node_matlab_manager
node_matlab_manager -->|"starts session"| node_matlab
node_matlab -->|"executes model"| node_simulink
node_routes -->|"processes telemetry"| node_analytics
node_routes -->|"stores results"| node_run_store
node_routes -->|"stores run prediction"| node_ml_router
node_ml_router -->|"requests prediction"| node_predictor
node_predictor -->|"extracts features"| node_ml_features
node_predictor -->|"prepares signals"| node_ml_signals
node_training -->|"uses features"| node_ml_features
node_training -->|"uses signals"| node_ml_signals
node_app -->|"selects view"| node_views
node_views -->|"renders schematic"| node_network
node_views -->|"renders telemetry"| node_tripchart
node_views -->|"renders waveforms"| node_waveforms
node_views -->|"renders diagnosis"| node_diagnostics
node_api_client -->|"fetches run diagnosis"| node_ml_router
node_run_store -->|"returns run results"| node_app

click node_app "https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/App.tsx"
click node_controls "https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/views/ControlsView.tsx"
click node_views "https://github.com/gauravpanjwani889/finalyearproject/tree/main/frontend/src/views"
click node_network "https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/components/NetworkSchematic.tsx"
click node_tripchart "https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/components/TripBreakerChart.tsx"
click node_waveforms "https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/components/WaveformChart.tsx"
click node_diagnostics "https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/components/MlDiagnosisCard.tsx"
click node_api_client "https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/services/api.ts"
click node_backend_app "https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/main.py"
click node_routes "https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/routes.py"
click node_schemas "https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/models.py"
click node_run_store "https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/routes.py"
click node_runner "https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/sim_runner.py"
click node_matlab_manager "https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/matlab_engine.py"
click node_simulink "https://github.com/gauravpanjwani889/finalyearproject/blob/main/matlab/main_model.slx"
click node_analytics "https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/analytics.py"
click node_ml_router "https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/api_router.py"
click node_predictor "https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/ml_predict.py"
click node_ml_features "https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/ml_features.py"
click node_ml_signals "https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/ml_signals.py"
click node_training "https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/train.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_controls,node_views,node_network,node_tripchart,node_waveforms,node_diagnostics,node_api_client toneBlue
class node_backend_app,node_routes,node_schemas,node_run_store toneAmber
class node_runner,node_matlab_manager,node_simulink,node_analytics toneMint
class node_ml_router,node_predictor,node_ml_features,node_ml_signals,node_training toneRose
class node_operator,node_matlab toneIndigo
```

## Components

### Operator Dashboard

- [Dashboard Shell](https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Grid Controls](https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/views/ControlsView.tsx): `frontend/src/views/ControlsView.tsx`
- [Monitoring Views](https://github.com/gauravpanjwani889/finalyearproject/tree/main/frontend/src/views): `frontend/src/views`
- [Network Schematic](https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/components/NetworkSchematic.tsx): `frontend/src/components/NetworkSchematic.tsx`
- [Breaker Telemetry](https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/components/TripBreakerChart.tsx): `frontend/src/components/TripBreakerChart.tsx`
- [Waveform Charts](https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/components/WaveformChart.tsx): `frontend/src/components/WaveformChart.tsx`
- [Diagnosis Card](https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/components/MlDiagnosisCard.tsx): `frontend/src/components/MlDiagnosisCard.tsx`
- [Typed API Client](https://github.com/gauravpanjwani889/finalyearproject/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### Backend API

- [FastAPI Application](https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/main.py): `backend/main.py`
- [Simulation Routes](https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/routes.py): `backend/routes.py`
- [Request & Result Schemas](https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/models.py): `backend/models.py`
- [Run Result Store](https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/routes.py): `backend/routes.py`

### Simulation & Analytics

- [Simulation Runner](https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/sim_runner.py): `backend/sim_runner.py`
- [MATLAB Session Manager](https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/matlab_engine.py): `backend/matlab_engine.py`
- [Simulink Solver](https://github.com/gauravpanjwani889/finalyearproject/blob/main/matlab/main_model.slx): `matlab/main_model.slx`
- [Electrical Analytics](https://github.com/gauravpanjwani889/finalyearproject/blob/main/backend/analytics.py): `backend/analytics.py`

### ML Diagnosis

- [ML API & Run Results](https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/api_router.py): `fault_ml/api_router.py`
- [Fault Predictor](https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/ml_predict.py): `fault_ml/ml_predict.py`
- [Signal Features](https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/ml_features.py): `fault_ml/ml_features.py`
- [Signal Preparation](https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/ml_signals.py): `fault_ml/ml_signals.py`
- [Classifier Training](https://github.com/gauravpanjwani889/finalyearproject/blob/main/fault_ml/train.py): `fault_ml/train.py`

### Other components

- **Grid Operator**
- **MATLAB Engine**

## Connections

- Grid Operator → Grid Controls: configures (evidence: `frontend/src/views/ControlsView.tsx`)
- Grid Controls → Dashboard Shell: updates parameters (evidence: `frontend/src/App.tsx`)
- Dashboard Shell → Typed API Client: submits simulation (evidence: `frontend/src/App.tsx`)
- Typed API Client → Simulation Routes: HTTP requests (evidence: `frontend/src/services/api.ts`)
- FastAPI Application → Simulation Routes: mounts routes (evidence: `backend/main.py`)
- FastAPI Application → ML API & Run Results: mounts routes (evidence: `backend/main.py`)
- Simulation Routes → Request & Result Schemas: validates & returns (evidence: `backend/routes.py`)
- Simulation Routes → Simulation Runner: runs simulation (evidence: `backend/routes.py`)
- Simulation Runner → MATLAB Session Manager: uses session (evidence: `backend/sim_runner.py`)
- MATLAB Session Manager → MATLAB Engine: starts session (evidence: `backend/matlab_engine.py`)
- MATLAB Engine → Simulink Solver: executes model (evidence: `README.md`)
- Simulation Routes → Electrical Analytics: processes telemetry (evidence: `backend/routes.py`)
- Simulation Routes → Run Result Store: stores results (evidence: `backend/routes.py`)
- Simulation Routes → ML API & Run Results: stores run prediction (evidence: `backend/routes.py`)
- ML API & Run Results → Fault Predictor: requests prediction (evidence: `fault_ml/api_router.py`)
- Fault Predictor → Signal Features: extracts features (evidence: `fault_ml/ml_predict.py`)
- Fault Predictor → Signal Preparation: prepares signals (evidence: `fault_ml/ml_predict.py`)
- Classifier Training → Signal Features: uses features (evidence: `fault_ml/train.py`)
- Classifier Training → Signal Preparation: uses signals (evidence: `fault_ml/train.py`)
- Dashboard Shell → Monitoring Views: selects view (evidence: `frontend/src/App.tsx`)
- Monitoring Views → Network Schematic: renders schematic (evidence: `frontend/src/views/OverviewView.tsx`)
- Monitoring Views → Breaker Telemetry: renders telemetry (evidence: `frontend/src/views/OverviewView.tsx`)
- Monitoring Views → Waveform Charts: renders waveforms (evidence: `frontend/src/views/WaveformsView.tsx`)
- Monitoring Views → Diagnosis Card: renders diagnosis (evidence: `frontend/src/views/DiagnosticsView.tsx`)
- Typed API Client → ML API & Run Results: fetches run diagnosis (evidence: `frontend/src/services/api.ts`)
- Run Result Store → Dashboard Shell: returns run results
