# qwertypoiuy9/sih-120-final architecture

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

- Interactive diagram: https://gitdiagram.com/qwertypoiuy9/sih-120-final
- Repository: https://github.com/qwertypoiuy9/sih-120-final

## Overview

Baghewala Digital Twin is a demonstration well-operations application: users inspect simulated well conditions, explore physics-derived views and insights, and run CSS, pump, simulation, or optimization what-ifs. The frontend routes role-based workflows and receives state through REST polling or WebSocket streaming; the FastAPI backend advances an in-process digital-twin state using thermal, viscosity, wellbore, rod, dynamometer, and surface models. Reports and alerts are demo outputs, not field-system integrations. Connections follow the README and shown imports/calls; unsampled page implementations are represented by their existing page paths.

Main entry points: [`frontend/src/App.tsx`](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/App.tsx) (App routing), [`backend/main.py`](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/main.py) (Twin state runtime), [`frontend/src/services/api.ts`](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/services/api.ts) (REST client), [`frontend/src/store/digitalTwinStore.ts`](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/digitalTwinStore.ts) (Twin state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Operator interface"]
  node_app["App routing<br/>[App.tsx]"]
  node_well_views["Well views"]
  node_live_data["Live data<br/>[LiveData.tsx]"]
  node_css_control["CSS control<br/>[CSSControl.tsx]"]
  node_login["Login<br/>[LoginPage.tsx]"]
  node_supervisor["Supervisor dashboard"]
  node_reports["Reports<br/>[Reports.tsx]"]
  node_header["Header<br/>[Header.tsx]"]
  node_user_panel["User management"]
  node_translations["Translations<br/>[i18n.ts]"]
end

subgraph group_state["Frontend state and access"]
  node_api_client["REST client<br/>[api.ts]"]
  node_websocket["WebSocket client<br/>[websocket.ts]"]
  node_twin_store["Twin state"]
  node_auth_store["Auth state<br/>[authStore.ts]"]
  node_notifications["Notifications"]
  node_sidebar_store["Sidebar state<br/>[sidebarStore.ts]"]
  node_user_store["User state"]
end

subgraph group_backend["Simulation backend"]
  node_backend_api["FastAPI endpoints<br/>[main.py]"]
  node_twin_runtime["Twin state runtime<br/>[main.py]"]
  node_database[("Relational database setup<br/>[__init__.py]")]
  node_well_records["Well records<br/>[well.py]"]
end

subgraph group_physics["Physics models"]
  node_thermal["Thermal decline<br/>[thermal_model.py]"]
  node_viscosity["Viscosity<br/>[viscosity_model.py]"]
  node_wellbore_model["Wellbore profiles<br/>[wellbore_model.py]"]
  node_rod_dynamics["Rod dynamics<br/>[rod_dynamics.py]"]
  node_dynamometer["Dynamometer"]
  node_rod_float["Rod-float detection"]
  node_surface["Surface estimates<br/>[surface_model.py]"]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_app
node_app -->|"routes to"| node_well_views
node_app -->|"routes to"| node_live_data
node_app -->|"routes to"| node_css_control
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_supervisor
node_app -->|"updates"| node_twin_store
node_app -->|"polls"| node_api_client
node_well_views -->|"reads"| node_twin_store
node_live_data -->|"reads"| node_twin_store
node_css_control -->|"submits what-if"| node_api_client
node_login -->|"sets session"| node_auth_store
node_login -->|"uses"| node_user_store
node_supervisor -->|"renders"| node_user_panel
node_supervisor -->|"reads"| node_auth_store
node_reports -->|"fetches snapshot"| node_api_client
node_reports -->|"reads"| node_twin_store
node_header -->|"reads"| node_twin_store
node_header -->|"reads"| node_notifications
node_header -->|"reads"| node_auth_store
node_header -->|"uses"| node_translations
node_user_panel -->|"uses"| node_user_store
node_operator -.->|"requests data"| node_api_client
node_api_client -->|"calls REST"| node_backend_api
node_websocket -.->|"streams telemetry"| node_backend_api
node_backend_api -->|"serves state"| node_twin_runtime
node_twin_runtime -->|"advances"| node_thermal
node_twin_runtime -->|"calculates"| node_viscosity
node_twin_runtime -->|"calculates"| node_wellbore_model
node_twin_runtime -->|"calculates"| node_rod_dynamics
node_twin_runtime -->|"calculates"| node_dynamometer
node_twin_runtime -->|"estimates risk"| node_rod_float
node_twin_runtime -->|"calculates"| node_surface
node_well_records -->|"uses base"| node_database

click node_app "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/App.tsx"
click node_well_views "https://github.com/qwertypoiuy9/sih-120-final/tree/main/frontend/src/pages"
click node_live_data "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/LiveData.tsx"
click node_css_control "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/CSSControl.tsx"
click node_login "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/LoginPage.tsx"
click node_supervisor "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/SupervisorDashboard.tsx"
click node_reports "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/Reports.tsx"
click node_header "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/components/Header.tsx"
click node_user_panel "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/components/UserManagementPanel.tsx"
click node_translations "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/i18n.ts"
click node_api_client "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/services/api.ts"
click node_websocket "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/services/websocket.ts"
click node_twin_store "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/digitalTwinStore.ts"
click node_auth_store "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/authStore.ts"
click node_notifications "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/notificationStore.ts"
click node_sidebar_store "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/sidebarStore.ts"
click node_user_store "https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/userManagementStore.ts"
click node_backend_api "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/main.py"
click node_twin_runtime "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/main.py"
click node_database "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/database/__init__.py"
click node_well_records "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/models/well.py"
click node_thermal "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/thermal_model.py"
click node_viscosity "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/viscosity_model.py"
click node_wellbore_model "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/wellbore_model.py"
click node_rod_dynamics "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/rod_dynamics.py"
click node_dynamometer "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/dynamometer_model.py"
click node_rod_float "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/rod_float_detector.py"
click node_surface "https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/surface_model.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_well_views,node_live_data,node_css_control,node_login,node_supervisor,node_reports,node_header,node_user_panel,node_translations toneBlue
class node_api_client,node_websocket,node_twin_store,node_auth_store,node_notifications,node_sidebar_store,node_user_store toneAmber
class node_backend_api,node_twin_runtime,node_database,node_well_records toneMint
class node_thermal,node_viscosity,node_wellbore_model,node_rod_dynamics,node_dynamometer,node_rod_float,node_surface toneRose
class node_operator toneIndigo
```

## Components

### Operator interface

- [App routing](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Well views](https://github.com/qwertypoiuy9/sih-120-final/tree/main/frontend/src/pages): `frontend/src/pages`
- [Live data](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/LiveData.tsx): `frontend/src/pages/LiveData.tsx`
- [CSS control](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/CSSControl.tsx): `frontend/src/pages/CSSControl.tsx`
- [Login](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/LoginPage.tsx): `frontend/src/pages/LoginPage.tsx`
- [Supervisor dashboard](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/SupervisorDashboard.tsx): `frontend/src/pages/SupervisorDashboard.tsx`
- [Reports](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/pages/Reports.tsx): `frontend/src/pages/Reports.tsx`
- [Header](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/components/Header.tsx): `frontend/src/components/Header.tsx`
- [User management](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/components/UserManagementPanel.tsx): `frontend/src/components/UserManagementPanel.tsx`
- [Translations](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/i18n.ts): `frontend/src/i18n.ts`

### Frontend state and access

- [REST client](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [WebSocket client](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/services/websocket.ts): `frontend/src/services/websocket.ts`
- [Twin state](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/digitalTwinStore.ts): `frontend/src/store/digitalTwinStore.ts`
- [Auth state](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/authStore.ts): `frontend/src/store/authStore.ts`
- [Notifications](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/notificationStore.ts): `frontend/src/store/notificationStore.ts`
- [Sidebar state](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/sidebarStore.ts): `frontend/src/store/sidebarStore.ts`
- [User state](https://github.com/qwertypoiuy9/sih-120-final/blob/main/frontend/src/store/userManagementStore.ts): `frontend/src/store/userManagementStore.ts`

### Simulation backend

- [FastAPI endpoints](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/main.py): `backend/main.py`
- [Twin state runtime](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/main.py): `backend/main.py`
- [Relational database setup](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/database/__init__.py): `backend/app/database/__init__.py`
- [Well records](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/models/well.py): `backend/app/models/well.py`

### Physics models

- [Thermal decline](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/thermal_model.py): `backend/app/physics/thermal_model.py`
- [Viscosity](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/viscosity_model.py): `backend/app/physics/viscosity_model.py`
- [Wellbore profiles](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/wellbore_model.py): `backend/app/physics/wellbore_model.py`
- [Rod dynamics](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/rod_dynamics.py): `backend/app/physics/rod_dynamics.py`
- [Dynamometer](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/dynamometer_model.py): `backend/app/physics/dynamometer_model.py`
- [Rod-float detection](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/rod_float_detector.py): `backend/app/physics/rod_float_detector.py`
- [Surface estimates](https://github.com/qwertypoiuy9/sih-120-final/blob/main/backend/app/physics/surface_model.py): `backend/app/physics/surface_model.py`

### Other components

- **Operator**

## Connections

- Operator → App routing: uses (evidence: `README.md`)
- App routing → Well views: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Live data: routes to (evidence: `frontend/src/App.tsx`)
- App routing → CSS control: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Login: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Supervisor dashboard: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Twin state: updates (evidence: `frontend/src/App.tsx`)
- App routing → REST client: polls (evidence: `frontend/src/App.tsx`)
- Well views → Twin state: reads (evidence: `frontend/src/pages/AIInsights.tsx`)
- Live data → Twin state: reads (evidence: `frontend/src/pages/LiveData.tsx`)
- CSS control → REST client: submits what-if (evidence: `frontend/src/pages/CSSControl.tsx`)
- Login → Auth state: sets session (evidence: `frontend/src/pages/LoginPage.tsx`)
- Login → User state: uses (evidence: `frontend/src/pages/LoginPage.tsx`)
- Supervisor dashboard → User management: renders (evidence: `frontend/src/pages/SupervisorDashboard.tsx`)
- Supervisor dashboard → Auth state: reads (evidence: `frontend/src/pages/SupervisorDashboard.tsx`)
- Reports → REST client: fetches snapshot (evidence: `frontend/src/pages/Reports.tsx`)
- Reports → Twin state: reads (evidence: `frontend/src/pages/Reports.tsx`)
- Header → Twin state: reads (evidence: `frontend/src/components/Header.tsx`)
- Header → Notifications: reads (evidence: `frontend/src/components/Header.tsx`)
- Header → Auth state: reads (evidence: `frontend/src/components/Header.tsx`)
- Header → Translations: uses (evidence: `frontend/src/components/Header.tsx`)
- User management → User state: uses (evidence: `frontend/src/components/UserManagementPanel.tsx`)
- Operator → REST client: requests data (evidence: `README.md`)
- REST client → FastAPI endpoints: calls REST (evidence: `frontend/src/services/api.ts`)
- WebSocket client → FastAPI endpoints: streams telemetry (evidence: `README.md`)
- FastAPI endpoints → Twin state runtime: serves state (evidence: `backend/main.py`)
- Twin state runtime → Thermal decline: advances (evidence: `README.md`)
- Twin state runtime → Viscosity: calculates (evidence: `README.md`)
- Twin state runtime → Wellbore profiles: calculates (evidence: `README.md`)
- Twin state runtime → Rod dynamics: calculates (evidence: `README.md`)
- Twin state runtime → Dynamometer: calculates (evidence: `README.md`)
- Twin state runtime → Rod-float detection: estimates risk (evidence: `backend/main.py`)
- Twin state runtime → Surface estimates: calculates (evidence: `README.md`)
- Well records → Relational database setup: uses base (evidence: `backend/app/models/well.py`)
