# cherukuriyasaswini/trinethram architecture

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

- Interactive diagram: https://gitdiagram.com/cherukuriyasaswini/trinethram
- Repository: https://github.com/cherukuriyasaswini/trinethram

## Overview

Ghat-Guard is an offline-first municipal crowd-safety terminal. Operators use the Telugu console to view telemetry and submit actions; edge nodes classify local sensor readings, enforce gate interlocks, and encode or decode LoRa telemetry. The Flask backend also accepts video for analysis and exposes telemetry and audit endpoints. Separate modules provide haze-aware vision fusion, crowd-flow and shockwave models, emergency Palm-Smash controls, and append-only audit storage. The excerpts show the backend’s own audit trail, but not how the browser console connects to backend endpoints or how the separate models are integrated at runtime.

Main entry points: [`backend_server.py`](https://github.com/cherukuriyasaswini/trinethram/blob/main/backend_server.py) (Flask command backend), [`ui_frontend/yali_telugu_console.html`](https://github.com/cherukuriyasaswini/trinethram/blob/main/ui_frontend/yali_telugu_console.html) (Telugu console), [`core_firmware/edge_hardware_node.py`](https://github.com/cherukuriyasaswini/trinethram/blob/main/core_firmware/edge_hardware_node.py) (Edge state machine), [`ui_frontend/telemetry_worker.js`](https://github.com/cherukuriyasaswini/trinethram/blob/main/ui_frontend/telemetry_worker.js) (Telemetry parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge telemetry"]
  node_edge_node["Edge state machine"]
  node_codec["LoRa packet codec<br/>[lora_mesh.py]"]
end

subgraph group_command["Command and analysis"]
  node_console["Telugu console"]
  node_worker["Telemetry parser"]
  node_backend["Flask command backend<br/>[backend_server.py]"]
  node_video["Video analysis<br/>[backend_server.py]"]
end

subgraph group_safety["Safety models"]
  node_fusion["Haze vision fusion"]
  node_granular["Granular flow model<br/>[granular_flow.py]"]
  node_shockwave["Shockwave model"]
  node_override["Palm-Smash controls"]
end

subgraph group_records["Audit records"]
  node_backend_audit["Backend audit trail<br/>[backend_server.py]"]
  node_register["Compliance register"]
  node_audit_db[("SQLite audit store<br/>[ghat_compliance.db]")]
end

node_operator(("Operator"))
node_camera(("Video operator"))

node_operator -->|"uses"| node_console
node_camera -->|"uploads video"| node_backend
node_backend -->|"routes analysis"| node_video
node_operator -->|"submits actions"| node_backend
node_console -.->|"parses telemetry"| node_worker
node_edge_node -->|"encodes packets"| node_codec
node_edge_node -->|"decodes packets"| node_codec
node_worker -->|"returns telemetry"| node_console
node_backend -->|"logs actions"| node_backend_audit
node_register -->|"reads and writes"| node_audit_db

click node_console "https://github.com/cherukuriyasaswini/trinethram/blob/main/ui_frontend/yali_telugu_console.html"
click node_worker "https://github.com/cherukuriyasaswini/trinethram/blob/main/ui_frontend/telemetry_worker.js"
click node_backend "https://github.com/cherukuriyasaswini/trinethram/blob/main/backend_server.py"
click node_video "https://github.com/cherukuriyasaswini/trinethram/blob/main/backend_server.py"
click node_edge_node "https://github.com/cherukuriyasaswini/trinethram/blob/main/core_firmware/edge_hardware_node.py"
click node_codec "https://github.com/cherukuriyasaswini/trinethram/blob/main/communications/lora_mesh.py"
click node_fusion "https://github.com/cherukuriyasaswini/trinethram/blob/main/vision_fusion/puja_haze_fusion.py"
click node_granular "https://github.com/cherukuriyasaswini/trinethram/blob/main/physics_engine/granular_flow.py"
click node_shockwave "https://github.com/cherukuriyasaswini/trinethram/blob/main/physics_engine/shockwave_propagation.py"
click node_override "https://github.com/cherukuriyasaswini/trinethram/blob/main/emergency_subsystem/palm_smash_override.py"
click node_backend_audit "https://github.com/cherukuriyasaswini/trinethram/blob/main/backend_server.py"
click node_register "https://github.com/cherukuriyasaswini/trinethram/blob/main/audit_logs/compliance_register.py"
click node_audit_db "https://github.com/cherukuriyasaswini/trinethram/blob/main/audit_logs/audit_logs/ghat_compliance.db"

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_edge_node,node_codec toneBlue
class node_console,node_worker,node_backend,node_video toneAmber
class node_fusion,node_granular,node_shockwave,node_override toneMint
class node_backend_audit,node_register,node_audit_db toneRose
class node_operator,node_camera toneIndigo
```

## Components

### Edge telemetry

- [Edge state machine](https://github.com/cherukuriyasaswini/trinethram/blob/main/core_firmware/edge_hardware_node.py): `core_firmware/edge_hardware_node.py`
- [LoRa packet codec](https://github.com/cherukuriyasaswini/trinethram/blob/main/communications/lora_mesh.py): `communications/lora_mesh.py`

### Command and analysis

- [Telugu console](https://github.com/cherukuriyasaswini/trinethram/blob/main/ui_frontend/yali_telugu_console.html): `ui_frontend/yali_telugu_console.html`
- [Telemetry parser](https://github.com/cherukuriyasaswini/trinethram/blob/main/ui_frontend/telemetry_worker.js): `ui_frontend/telemetry_worker.js`
- [Flask command backend](https://github.com/cherukuriyasaswini/trinethram/blob/main/backend_server.py): `backend_server.py`
- [Video analysis](https://github.com/cherukuriyasaswini/trinethram/blob/main/backend_server.py): `backend_server.py`

### Safety models

- [Haze vision fusion](https://github.com/cherukuriyasaswini/trinethram/blob/main/vision_fusion/puja_haze_fusion.py): `vision_fusion/puja_haze_fusion.py`
- [Granular flow model](https://github.com/cherukuriyasaswini/trinethram/blob/main/physics_engine/granular_flow.py): `physics_engine/granular_flow.py`
- [Shockwave model](https://github.com/cherukuriyasaswini/trinethram/blob/main/physics_engine/shockwave_propagation.py): `physics_engine/shockwave_propagation.py`
- [Palm-Smash controls](https://github.com/cherukuriyasaswini/trinethram/blob/main/emergency_subsystem/palm_smash_override.py): `emergency_subsystem/palm_smash_override.py`

### Audit records

- [Backend audit trail](https://github.com/cherukuriyasaswini/trinethram/blob/main/backend_server.py): `backend_server.py`
- [Compliance register](https://github.com/cherukuriyasaswini/trinethram/blob/main/audit_logs/compliance_register.py): `audit_logs/compliance_register.py`
- [SQLite audit store](https://github.com/cherukuriyasaswini/trinethram/blob/main/audit_logs/audit_logs/ghat_compliance.db): `audit_logs/audit_logs/ghat_compliance.db`

### Other components

- **Operator**
- **Video operator**

## Connections

- Operator → Telugu console: uses (evidence: `README.md`)
- Video operator → Flask command backend: uploads video (evidence: `backend_server.py`)
- Flask command backend → Video analysis: routes analysis (evidence: `backend_server.py`)
- Operator → Flask command backend: submits actions (evidence: `backend_server.py`)
- Telugu console → Telemetry parser: parses telemetry
- Edge state machine → LoRa packet codec: encodes packets (evidence: `core_firmware/edge_hardware_node.py`)
- Edge state machine → LoRa packet codec: decodes packets (evidence: `core_firmware/edge_hardware_node.py`)
- Telemetry parser → Telugu console: returns telemetry (evidence: `ui_frontend/telemetry_worker.js`)
- Flask command backend → Backend audit trail: logs actions (evidence: `backend_server.py`)
- Compliance register → SQLite audit store: reads and writes (evidence: `audit_logs/compliance_register.py`)
