# devendrarajsingh07/sih2026-mghsis. architecture

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

- Interactive diagram: https://gitdiagram.com/devendrarajsingh07/sih2026-mghsis.
- Repository: https://github.com/devendrarajsingh07/sih2026-mghsis.

## Overview

MGHSIS is an operational decision-support platform for mass-gathering safety. Its principal workflow is to ingest band, CCTV, and gate observations; assess and fuse risk; present live venue conditions and forecasts in the operations portal; then let an operator authorize a simulated intervention and verify its projected effect. The README documents the broader product capabilities, but several web and API relationships are not visible in the sampled source; those links are shown only where documented or marked unverified.

Main entry points: [`apps/api/app/api/hardware.py`](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/hardware.py) (Hardware ingestion), [`apps/api/app/api/simulation.py`](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/simulation.py) (Scenario simulation), [`apps/api/app/ml/model.py`](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/ml/model.py) (Crowd-risk model), [`apps/api/app/core/redis_runtime.py`](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/core/redis_runtime.py) (Live state and pub/sub)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensing["Sensing and simulation"]
  node_hardware["Safety bands"]
  node_cctv["CCTV analytics"]
  node_gate["Gate events"]
  node_simulators["Telemetry simulators"]
end

subgraph group_api["Core API"]
  node_ingest["Hardware ingestion<br/>[hardware.py]"]
  node_mlapi["ML endpoints<br/>[ml.py]"]
  node_simulation["Scenario simulation<br/>[simulation.py]"]
  node_realtime["Realtime stream<br/>[realtime.py]"]
  node_system["System health<br/>[system.py]"]
end

subgraph group_intelligence["Risk intelligence"]
  node_fusion["Zone risk fusion<br/>[simulation.py]"]
  node_model["Crowd-risk model<br/>[model.py]"]
  node_features["Feature contract<br/>[features.py]"]
  node_risk_schema["Risk schemas<br/>[schemas.py]"]
  node_humanrisk["Human-risk workflow<br/>[human-risk.ts]"]
end

subgraph group_runtime["Shared runtime"]
  node_redis[("Live state and pub/sub<br/>[redis_runtime.py]")]
  node_postgres[("Telemetry history")]
end

subgraph group_operations["Operations portal"]
  node_twin["Digital Twin"]
  node_dashboard["Command centre"]
  node_registry["Band registry<br/>[band-registry.tsx]"]
  node_interventions["Intervention console"]
  node_alerts["Alert lifecycle<br/>[alert-feed.tsx]"]
  node_analytics["Analytics views<br/>[page.tsx]"]
  node_webapi["Web API routes"]
end

node_operator(("Safety operator"))
node_websocket["WebSocket clients"]

node_hardware -.->|"simulated by"| node_simulators
node_cctv -.->|"simulated by"| node_simulators
node_gate -.->|"simulated by"| node_simulators
node_simulators -->|"posts observations"| node_ingest
node_ingest -->|"validates with"| node_risk_schema
node_ingest -->|"publishes live state"| node_redis
node_ingest -->|"records history"| node_postgres
node_mlapi -->|"requests predictions"| node_model
node_model -->|"encodes observations"| node_features
node_model -->|"uses contracts"| node_risk_schema
node_simulation -->|"scores zones"| node_model
node_simulation -->|"fuses risk engines"| node_fusion
node_simulation -->|"shares simulation state"| node_redis
node_realtime -.->|"streams events"| node_redis
node_system -->|"checks runtime"| node_redis
node_system -->|"checks history"| node_postgres
node_system -->|"checks readiness"| node_model
node_operator -->|"monitors operations"| node_dashboard
node_operator -->|"inspects venue"| node_twin
node_operator -->|"searches bands"| node_registry
node_operator -->|"triages alerts"| node_alerts
node_operator -->|"authorizes actions"| node_interventions
node_operator -->|"reviews metrics"| node_analytics
node_redis -->|"fans out events"| node_websocket
node_websocket -->|"updates live view"| node_twin
node_twin -.->|"requests twin data"| node_webapi
node_webapi -.->|"controls scenarios"| node_simulation
node_webapi -.->|"requests risk"| node_mlapi
node_webapi -.->|"submits observations"| node_ingest
node_humanrisk -.->|"supports risk workflow"| node_dashboard
node_interventions -.->|"verifies projection"| node_simulation

click node_simulators "https://github.com/devendrarajsingh07/sih2026-mghsis./tree/main/services"
click node_ingest "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/hardware.py"
click node_mlapi "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/ml.py"
click node_simulation "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/simulation.py"
click node_realtime "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/realtime.py"
click node_system "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/system.py"
click node_fusion "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/simulation.py"
click node_model "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/ml/model.py"
click node_features "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/ml/features.py"
click node_risk_schema "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/ml/schemas.py"
click node_humanrisk "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/lib/human-risk.ts"
click node_redis "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/core/redis_runtime.py"
click node_postgres "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/core/postgres_runtime.py"
click node_twin "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/digital-twin-operations.tsx"
click node_dashboard "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/command-center-dashboard.tsx"
click node_registry "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/band-registry.tsx"
click node_interventions "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/intervention-console.tsx"
click node_alerts "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/alert-feed.tsx"
click node_analytics "https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/app/analytics/page.tsx"
click node_webapi "https://github.com/devendrarajsingh07/sih2026-mghsis./tree/main/apps/web/src/app/api"

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_hardware,node_cctv,node_gate,node_simulators,node_websocket toneBlue
class node_ingest,node_mlapi,node_simulation,node_realtime,node_system toneAmber
class node_fusion,node_model,node_features,node_risk_schema,node_humanrisk toneMint
class node_redis,node_postgres toneRose
class node_twin,node_dashboard,node_registry,node_interventions,node_alerts,node_analytics,node_webapi,node_operator toneIndigo
```

## Components

### Sensing and simulation

- **Safety bands**
- **CCTV analytics**
- **Gate events**
- [Telemetry simulators](https://github.com/devendrarajsingh07/sih2026-mghsis./tree/main/services): `services`

### Core API

- [Hardware ingestion](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/hardware.py): `apps/api/app/api/hardware.py`
- [ML endpoints](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/ml.py): `apps/api/app/api/ml.py`
- [Scenario simulation](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/simulation.py): `apps/api/app/api/simulation.py`
- [Realtime stream](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/realtime.py): `apps/api/app/api/realtime.py`
- [System health](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/system.py): `apps/api/app/api/system.py`

### Risk intelligence

- [Zone risk fusion](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/api/simulation.py): `apps/api/app/api/simulation.py`
- [Crowd-risk model](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/ml/model.py): `apps/api/app/ml/model.py`
- [Feature contract](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/ml/features.py): `apps/api/app/ml/features.py`
- [Risk schemas](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/ml/schemas.py): `apps/api/app/ml/schemas.py`
- [Human-risk workflow](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/lib/human-risk.ts): `apps/web/src/lib/human-risk.ts`

### Shared runtime

- [Live state and pub/sub](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/core/redis_runtime.py): `apps/api/app/core/redis_runtime.py`
- [Telemetry history](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/api/app/core/postgres_runtime.py): `apps/api/app/core/postgres_runtime.py`

### Operations portal

- [Digital Twin](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/digital-twin-operations.tsx): `apps/web/src/components/digital-twin-operations.tsx`
- [Command centre](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/command-center-dashboard.tsx): `apps/web/src/components/command-center-dashboard.tsx`
- [Band registry](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/band-registry.tsx): `apps/web/src/components/band-registry.tsx`
- [Intervention console](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/intervention-console.tsx): `apps/web/src/components/intervention-console.tsx`
- [Alert lifecycle](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/components/alert-feed.tsx): `apps/web/src/components/alert-feed.tsx`
- [Analytics views](https://github.com/devendrarajsingh07/sih2026-mghsis./blob/main/apps/web/src/app/analytics/page.tsx): `apps/web/src/app/analytics/page.tsx`
- [Web API routes](https://github.com/devendrarajsingh07/sih2026-mghsis./tree/main/apps/web/src/app/api): `apps/web/src/app/api`

### Other components

- **Safety operator**
- **WebSocket clients**

## Connections

- Safety bands → Telemetry simulators: simulated by
- CCTV analytics → Telemetry simulators: simulated by
- Gate events → Telemetry simulators: simulated by
- Telemetry simulators → Hardware ingestion: posts observations (evidence: `services/runtime.py`)
- Hardware ingestion → Risk schemas: validates with (evidence: `apps/api/app/api/hardware.py`)
- Hardware ingestion → Live state and pub/sub: publishes live state (evidence: `apps/api/app/api/hardware.py`)
- Hardware ingestion → Telemetry history: records history (evidence: `apps/api/app/api/hardware.py`)
- ML endpoints → Crowd-risk model: requests predictions (evidence: `apps/api/app/api/ml.py`)
- Crowd-risk model → Feature contract: encodes observations (evidence: `apps/api/app/ml/model.py`)
- Crowd-risk model → Risk schemas: uses contracts (evidence: `apps/api/app/ml/model.py`)
- Scenario simulation → Crowd-risk model: scores zones (evidence: `apps/api/app/api/simulation.py`)
- Scenario simulation → Zone risk fusion: fuses risk engines (evidence: `apps/api/app/api/simulation.py`)
- Scenario simulation → Live state and pub/sub: shares simulation state (evidence: `apps/api/app/api/simulation.py`)
- Realtime stream → Live state and pub/sub: streams events
- System health → Live state and pub/sub: checks runtime (evidence: `apps/api/app/api/system.py`)
- System health → Telemetry history: checks history (evidence: `apps/api/app/api/system.py`)
- System health → Crowd-risk model: checks readiness (evidence: `apps/api/app/api/system.py`)
- Safety operator → Command centre: monitors operations
- Safety operator → Digital Twin: inspects venue
- Safety operator → Band registry: searches bands
- Safety operator → Alert lifecycle: triages alerts
- Safety operator → Intervention console: authorizes actions
- Safety operator → Analytics views: reviews metrics
- Live state and pub/sub → WebSocket clients: fans out events
- WebSocket clients → Digital Twin: updates live view
- Digital Twin → Web API routes: requests twin data
- Web API routes → Scenario simulation: controls scenarios
- Web API routes → ML endpoints: requests risk
- Web API routes → Hardware ingestion: submits observations
- Human-risk workflow → Command centre: supports risk workflow
- Intervention console → Scenario simulation: verifies projection
