# azzabouzir/green-lanterns--gridbalance architecture

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

- Interactive diagram: https://gitdiagram.com/azzabouzir/green-lanterns--gridbalance
- Repository: https://github.com/azzabouzir/green-lanterns--gridbalance

## Overview

GRIDBALANCE is an operator-led decision-support platform for manual rotating load shedding; it allocates and tracks shedding but does not control the grid directly. The main workflow runs from the DN’s situation and flexibility inputs through a shedding order, CRC acknowledgement/allocation, BCC acceptance and execution, then simulated SCADA breaker telemetry, alarms and restoration. Citizens receive alerts, while history, audit and learned statistics support accountability. The README documents several capabilities whose implementation details were not sampled, so those components and relationships are shown at the documented subsystem level.

Main entry points: [`public/index.html`](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/public/index.html) (Web client), [`server.js`](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js) (Order workflow), [`scada-sim.js`](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/scada-sim.js) (RTU simulator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_decision["Decision support"]
  node_decision_assistant["DN assistant<br/>[server.js]"]
  node_scenario_planning["Scenario planning<br/>[server.js]"]
  node_flexibility["Flexibility requests<br/>[server.js]"]
  node_allocation["Regional allocation<br/>[server.js]"]
end

subgraph group_operations["Grid operations"]
  node_order_workflow["Order workflow<br/>[server.js]"]
  node_protected_sites["Protected sites<br/>[server.js]"]
  node_scada_gateway["SCADA API<br/>[server.js]"]
  node_simulator["RTU simulator<br/>[scada-sim.js]"]
  node_telemetry_alarms["Telemetry and alarms<br/>[server.js]"]
end

subgraph group_platform["Platform services"]
  node_web_client["Web client<br/>[index.html]"]
  node_database[("SQLite store<br/>[server.js]")]
  node_authentication["Role-based auth<br/>[server.js]"]
end

subgraph group_accountability["Accountability"]
  node_audit_history["Audit and history<br/>[server.js]"]
  node_learning["Learning statistics<br/>[server.js]"]
  node_citizen_services["Citizen alerts<br/>[server.js]"]
  node_reporting["Audit reporting<br/>[server.js]"]
end

node_operators(("Grid operators"))
node_industrial_users(("Industrial users"))
node_citizens(("Citizens"))

node_operators -->|"use screens"| node_web_client
node_industrial_users -->|"respond to requests"| node_web_client
node_citizens -->|"view alerts"| node_web_client
node_web_client -->|"submit inputs"| node_decision_assistant
node_decision_assistant -->|"request scenarios"| node_scenario_planning
node_decision_assistant -->|"request flexibility"| node_flexibility
node_decision_assistant -->|"create order"| node_order_workflow
node_web_client -->|"submit allocation"| node_allocation
node_web_client -->|"acknowledge and execute"| node_order_workflow
node_order_workflow -->|"check feeders"| node_protected_sites
node_order_workflow -->|"issue commands"| node_scada_gateway
node_simulator -->|"poll and send telemetry"| node_scada_gateway
node_scada_gateway -->|"process telemetry"| node_telemetry_alarms
node_telemetry_alarms -->|"propose rotation"| node_order_workflow
node_web_client -->|"log in"| node_authentication
node_authentication -->|"read and seed records"| node_database
node_audit_history -->|"write and verify events"| node_database
node_order_workflow -->|"record actions"| node_audit_history
node_order_workflow -->|"update after outage"| node_learning
node_web_client -->|"request citizen status"| node_citizen_services
node_citizen_services -->|"show alerts"| node_citizens
node_web_client -->|"request report"| node_reporting
node_reporting -->|"export audit log"| node_audit_history

click node_web_client "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/public/index.html"
click node_decision_assistant "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_scenario_planning "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_flexibility "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_allocation "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_order_workflow "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_protected_sites "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_scada_gateway "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_simulator "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/scada-sim.js"
click node_telemetry_alarms "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_database "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_authentication "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_audit_history "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_learning "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_citizen_services "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"
click node_reporting "https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js"

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_decision_assistant,node_scenario_planning,node_flexibility,node_allocation,node_industrial_users toneBlue
class node_order_workflow,node_protected_sites,node_scada_gateway,node_simulator,node_telemetry_alarms toneAmber
class node_web_client,node_database,node_authentication toneMint
class node_audit_history,node_learning,node_citizen_services,node_reporting toneRose
class node_operators,node_citizens toneIndigo
```

## Components

### Decision support

- [DN assistant](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [Scenario planning](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [Flexibility requests](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [Regional allocation](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`

### Grid operations

- [Order workflow](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [Protected sites](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [SCADA API](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [RTU simulator](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/scada-sim.js): `scada-sim.js`
- [Telemetry and alarms](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`

### Platform services

- [Web client](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/public/index.html): `public/index.html`
- [SQLite store](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [Role-based auth](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`

### Accountability

- [Audit and history](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [Learning statistics](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [Citizen alerts](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`
- [Audit reporting](https://github.com/azzabouzir/green-lanterns--gridbalance/blob/main/server.js): `server.js`

### Other components

- **Grid operators**
- **Industrial users**
- **Citizens**

## Connections

- Grid operators → Web client: use screens (evidence: `README.md`)
- Industrial users → Web client: respond to requests (evidence: `README.md`)
- Citizens → Web client: view alerts (evidence: `README.md`)
- Web client → DN assistant: submit inputs (evidence: `README.md`)
- DN assistant → Scenario planning: request scenarios (evidence: `README.md`)
- DN assistant → Flexibility requests: request flexibility (evidence: `README.md`)
- DN assistant → Order workflow: create order (evidence: `README.md`)
- Web client → Regional allocation: submit allocation (evidence: `README.md`)
- Web client → Order workflow: acknowledge and execute (evidence: `README.md`)
- Order workflow → Protected sites: check feeders (evidence: `README.md`)
- Order workflow → SCADA API: issue commands (evidence: `README.md`)
- RTU simulator → SCADA API: poll and send telemetry (evidence: `scada-sim.js`)
- SCADA API → Telemetry and alarms: process telemetry (evidence: `README.md`)
- Telemetry and alarms → Order workflow: propose rotation (evidence: `README.md`)
- Web client → Role-based auth: log in (evidence: `README.md`)
- Role-based auth → SQLite store: read and seed records (evidence: `server.js`)
- Audit and history → SQLite store: write and verify events (evidence: `server.js`)
- Order workflow → Audit and history: record actions (evidence: `README.md`)
- Order workflow → Learning statistics: update after outage (evidence: `README.md`)
- Web client → Citizen alerts: request citizen status (evidence: `README.md`)
- Citizen alerts → Citizens: show alerts (evidence: `README.md`)
- Web client → Audit reporting: request report (evidence: `README.md`)
- Audit reporting → Audit and history: export audit log (evidence: `README.md`)
