# manobalaji07/bhurakshak architecture

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

- Interactive diagram: https://gitdiagram.com/manobalaji07/bhurakshak
- Repository: https://github.com/manobalaji07/bhurakshak

## Overview

BhuRakshak is a mine-safety monitoring and decision-support application. Operators use the web dashboard to inspect node health, telemetry trends, analytics, alerts, notifications, and SMS controls; mine nodes submit telemetry to the backend. The backend exposes REST APIs, maintains node and alert state, evaluates ML signals, and can dispatch SMS alerts. The sampled code confirms alert processing, authentication, health timeouts, SMS dispatch, and WebSocket broadcasting; telemetry ingestion and several router-to-service links are represented only at the documented API boundary because their implementations were not sampled.

Main entry points: [`backend/app/main.py`](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/main.py) (FastAPI Application), [`frontend/src/App.tsx`](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/App.tsx) (Web Application), [`backend/app/api/auth.py`](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/auth.py) (Authentication API), [`backend/app/db/store.py`](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/db/store.py) (Application Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Operator Console"]
  node_web_app["Web Application<br/>[App.tsx]"]
  node_api_client["API Client<br/>[client.ts]"]
  node_dashboards["Dashboards<br/>[UserDashboard.tsx]"]
  node_admin_analytics["Analytics View<br/>[AdminAnalytics.tsx]"]
  node_node_detail["Node Detail<br/>[NodeDetail.tsx]"]
  node_admin_alerts["Alert Management<br/>[AdminAlerts.tsx]"]
  node_admin_sms["SMS Controls<br/>[AdminSms.tsx]"]
  node_notifications_ui["Notifications"]
end

subgraph group_api["Backend API"]
  node_backend_app["FastAPI Application<br/>[main.py]"]
  node_telemetry_api["Telemetry API<br/>[telemetry.py]"]
  node_nodes_api["Nodes API<br/>[nodes.py]"]
  node_analytics_api["Analytics API<br/>[analytics.py]"]
  node_alerts_api["Alerts API<br/>[alerts.py]"]
  node_notifications_api["Notifications API<br/>[notifications.py]"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_sms_api["SMS API<br/>[sms.py]"]
end

subgraph group_monitoring["Monitoring and Decisions"]
  node_ml_inference["ML Inference<br/>[inference.py]"]
  node_feature_extractor["Feature Extraction"]
  node_alert_service["Alert Decisions<br/>[alert_service.py]"]
  node_health_service["Node Health"]
  node_kinematic_service["Kinematic Trends"]
  node_sms_service["SMS Dispatch<br/>[sms_service.py]"]
  node_ws_manager["WebSocket Broadcast<br/>[manager.py]"]
end

subgraph group_state["State and Identity"]
  node_db_store[("Application Store<br/>[store.py]")]
  node_mongo_store[("Mongo User Store")]
  node_jwt["JWT Authentication<br/>[jwt.py]"]
end

node_operator(("Mine Operator"))
node_mine_nodes(("Mine Sensor Nodes"))
node_sms_provider["SMS Gateway"]

node_operator -->|"uses"| node_web_app
node_web_app -->|"requests data"| node_api_client
node_web_app -->|"routes to"| node_dashboards
node_web_app -->|"routes to"| node_admin_analytics
node_web_app -->|"routes to"| node_node_detail
node_web_app -->|"routes to"| node_admin_alerts
node_web_app -->|"routes to"| node_admin_sms
node_web_app -->|"renders"| node_notifications_ui
node_api_client -->|"HTTP requests"| node_backend_app
node_backend_app -->|"registers route"| node_telemetry_api
node_backend_app -->|"registers route"| node_nodes_api
node_backend_app -->|"registers route"| node_analytics_api
node_backend_app -->|"registers route"| node_alerts_api
node_backend_app -->|"registers route"| node_notifications_api
node_backend_app -->|"registers route"| node_auth_api
node_backend_app -->|"registers route"| node_sms_api
node_mine_nodes -->|"submits readings"| node_telemetry_api
node_backend_app -->|"checks timeouts"| node_health_service
node_health_service -->|"reads and updates"| node_db_store
node_health_service -->|"broadcasts changes"| node_ws_manager
node_ml_inference -->|"builds features"| node_feature_extractor
node_alert_service -->|"stores alerts"| node_db_store
node_alert_service -->|"dispatches subsidence alert"| node_sms_service
node_sms_service -->|"reads config and logs"| node_db_store
node_sms_service -.->|"sends messages"| node_sms_provider
node_auth_api -->|"looks up users"| node_mongo_store
node_auth_api -->|"fallback lookup"| node_db_store
node_auth_api -->|"verifies and issues tokens"| node_jwt
node_backend_app -->|"accepts telemetry socket"| node_ws_manager

click node_web_app "https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/api/client.ts"
click node_dashboards "https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/user/UserDashboard.tsx"
click node_admin_analytics "https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/admin/AdminAnalytics.tsx"
click node_node_detail "https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/shared/NodeDetail.tsx"
click node_admin_alerts "https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/admin/AdminAlerts.tsx"
click node_admin_sms "https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/admin/AdminSms.tsx"
click node_notifications_ui "https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/components/common/NotificationDrawer.tsx"
click node_backend_app "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/main.py"
click node_telemetry_api "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/telemetry.py"
click node_nodes_api "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/nodes.py"
click node_analytics_api "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/analytics.py"
click node_alerts_api "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/alerts.py"
click node_notifications_api "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/notifications.py"
click node_auth_api "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/auth.py"
click node_sms_api "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/sms.py"
click node_ml_inference "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/ml/inference.py"
click node_feature_extractor "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/ml/feature_extractor.py"
click node_alert_service "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/services/alert_service.py"
click node_health_service "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/services/node_health_service.py"
click node_kinematic_service "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/services/kinematic_service.py"
click node_sms_service "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/services/sms_service.py"
click node_ws_manager "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/websocket/manager.py"
click node_db_store "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/db/store.py"
click node_mongo_store "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/db/mongo_user_store.py"
click node_jwt "https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/auth/jwt.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_web_app,node_api_client,node_dashboards,node_admin_analytics,node_node_detail,node_admin_alerts,node_admin_sms,node_notifications_ui toneBlue
class node_backend_app,node_telemetry_api,node_nodes_api,node_analytics_api,node_alerts_api,node_notifications_api,node_auth_api,node_sms_api toneAmber
class node_ml_inference,node_feature_extractor,node_alert_service,node_health_service,node_kinematic_service,node_sms_service,node_ws_manager toneMint
class node_db_store,node_mongo_store,node_jwt toneRose
class node_operator,node_mine_nodes,node_sms_provider toneIndigo
```

## Components

### Operator Console

- [Web Application](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API Client](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Dashboards](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/user/UserDashboard.tsx): `frontend/src/pages/user/UserDashboard.tsx`
- [Analytics View](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/admin/AdminAnalytics.tsx): `frontend/src/pages/admin/AdminAnalytics.tsx`
- [Node Detail](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/shared/NodeDetail.tsx): `frontend/src/pages/shared/NodeDetail.tsx`
- [Alert Management](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/admin/AdminAlerts.tsx): `frontend/src/pages/admin/AdminAlerts.tsx`
- [SMS Controls](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/pages/admin/AdminSms.tsx): `frontend/src/pages/admin/AdminSms.tsx`
- [Notifications](https://github.com/manobalaji07/bhurakshak/blob/main/frontend/src/components/common/NotificationDrawer.tsx): `frontend/src/components/common/NotificationDrawer.tsx`

### Backend API

- [FastAPI Application](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/main.py): `backend/app/main.py`
- [Telemetry API](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/telemetry.py): `backend/app/api/telemetry.py`
- [Nodes API](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/nodes.py): `backend/app/api/nodes.py`
- [Analytics API](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/analytics.py): `backend/app/api/analytics.py`
- [Alerts API](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/alerts.py): `backend/app/api/alerts.py`
- [Notifications API](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/notifications.py): `backend/app/api/notifications.py`
- [Authentication API](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [SMS API](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/api/sms.py): `backend/app/api/sms.py`

### Monitoring and Decisions

- [ML Inference](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/ml/inference.py): `backend/app/ml/inference.py`
- [Feature Extraction](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/ml/feature_extractor.py): `backend/app/ml/feature_extractor.py`
- [Alert Decisions](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/services/alert_service.py): `backend/app/services/alert_service.py`
- [Node Health](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/services/node_health_service.py): `backend/app/services/node_health_service.py`
- [Kinematic Trends](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/services/kinematic_service.py): `backend/app/services/kinematic_service.py`
- [SMS Dispatch](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/services/sms_service.py): `backend/app/services/sms_service.py`
- [WebSocket Broadcast](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/websocket/manager.py): `backend/app/websocket/manager.py`

### State and Identity

- [Application Store](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/db/store.py): `backend/app/db/store.py`
- [Mongo User Store](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/db/mongo_user_store.py): `backend/app/db/mongo_user_store.py`
- [JWT Authentication](https://github.com/manobalaji07/bhurakshak/blob/main/backend/app/auth/jwt.py): `backend/app/auth/jwt.py`

### Other components

- **Mine Operator**
- **Mine Sensor Nodes**
- **SMS Gateway**

## Connections

- Mine Operator → Web Application: uses
- Web Application → API Client: requests data
- Web Application → Dashboards: routes to
- Web Application → Analytics View: routes to
- Web Application → Node Detail: routes to
- Web Application → Alert Management: routes to
- Web Application → SMS Controls: routes to
- Web Application → Notifications: renders
- API Client → FastAPI Application: HTTP requests
- FastAPI Application → Telemetry API: registers route
- FastAPI Application → Nodes API: registers route
- FastAPI Application → Analytics API: registers route
- FastAPI Application → Alerts API: registers route
- FastAPI Application → Notifications API: registers route
- FastAPI Application → Authentication API: registers route
- FastAPI Application → SMS API: registers route
- Mine Sensor Nodes → Telemetry API: submits readings
- FastAPI Application → Node Health: checks timeouts
- Node Health → Application Store: reads and updates
- Node Health → WebSocket Broadcast: broadcasts changes
- ML Inference → Feature Extraction: builds features
- Alert Decisions → Application Store: stores alerts
- Alert Decisions → SMS Dispatch: dispatches subsidence alert
- SMS Dispatch → Application Store: reads config and logs
- SMS Dispatch → SMS Gateway: sends messages
- Authentication API → Mongo User Store: looks up users
- Authentication API → Application Store: fallback lookup
- Authentication API → JWT Authentication: verifies and issues tokens
- FastAPI Application → WebSocket Broadcast: accepts telemetry socket
