How khaled214566/delestage works
This is a national load-shedding decision-support platform: dispatchers plan deficits, create and allocate hierarchical orders, and BCC operators execute feeder switching. Operators monitor live grid state; the platform also supports post-event equity/compliance evaluation, administration, auditability, simulation, and a public outage portal. The README documents the broader capabilities; sampled source and the SOURCE INDEX support the implementation links shown. Some feature internals were not sampled, so their connections are limited to documented or indexed relationships.
Main entry points: main.py API and app entry · database.py PostgreSQL data · execution.py Feeder execution · router.py Admin routes
Components 31
Operational planning
- Deficit planner
frontend/src/features/dispatcher/DeficitPlanner.tsx - Deficit routes
backend/app/modules/deficit/router.py - Deficit planning
backend/app/services/deficit.py - Order allocation
frontend/src/features/dispatcher/AllocationTree.tsx - Order routes
backend/app/modules/orders/router.py - Allocation engine
backend/app/services/order.py
Execution and monitoring
- BCC console
frontend/src/features/execution/BccExecutionScreen.tsx - Execution routes
backend/app/modules/execution/router.py - Feeder execution
backend/app/services/execution.py - Fair rotation
backend/app/services/rotation.py - Live dashboards
frontend/src/features/monitoring/MonitoringDashboard.tsx - Monitoring routes
backend/app/modules/monitoring/router.py - Telemetry engine
backend/app/services/live_telemetry.py
Governance and analysis
- KPI evaluation
backend/app/engine/evaluation.py - Evaluation routes
backend/app/modules/evaluation/router.py - Administration
frontend/src/features/admin/AdminPanel.tsx - Admin routes
backend/app/modules/admin/router.py - User and settings admin
backend/app/services/admin.py - Tamper-evident audit
backend/app/services/audit.py - Grid simulator
backend/app/services/simulator.py
Public transparency
- Citizen map portal
frontend/src/components/CitizenMap.tsx - Public schedule API
backend/app/modules/public/router.py - Outage information
backend/app/services/citizen.py
Application platform
- API and app entry
backend/app/main.py - Web application
frontend/src/App.tsx - HTTP client
frontend/src/api/client.ts - Authentication
backend/app/modules/auth/router.py - Role and scope checks
backend/app/core/deps.py - PostgreSQL data
backend/app/core/database.py - WebSocket transport
backend/app/core/websocket.py
Other components
- Grid operators
Connections 41
- Grid operators → Deficit planner: plans demand
- Deficit planner → Deficit routes: submits plans
- Deficit routes → Deficit planning: delegates planning
backend/app/modules/deficit/router.py - Deficit planning → PostgreSQL data: stores forecasts
- Grid operators → Order allocation: allocates targets
- Order allocation → Order routes: requests orders
- Order routes → Allocation engine: delegates allocation
backend/app/modules/orders/router.py - Allocation engine → PostgreSQL data: reads and writes
- Allocation engine → Tamper-evident audit: records actions
backend/app/services/order.py - BCC console → Execution routes: confirms switching
- Execution routes → Feeder execution: delegates execution
backend/app/modules/execution/router.py - Feeder execution → PostgreSQL data: updates events
- Feeder execution → Tamper-evident audit: records actions
- Feeder execution → Fair rotation: checks rotation
- Live dashboards → Monitoring routes: requests status
- Monitoring routes → Telemetry engine: uses telemetry
backend/app/modules/monitoring/router.py - Telemetry engine → WebSocket transport: pushes updates
backend/app/services/live_telemetry.py - Telemetry engine → PostgreSQL data: reads grid state
backend/app/services/live_telemetry.py - Evaluation routes → KPI evaluation: computes KPIs
backend/app/modules/evaluation/router.py - KPI evaluation → Grid operators: reports equity
- Administration → Admin routes: manages platform
- Admin routes → User and settings admin: delegates administration
backend/app/modules/admin/router.py - User and settings admin → Tamper-evident audit: logs changes
backend/app/services/admin.py - Admin routes → Tamper-evident audit: queries audit
backend/app/modules/admin/router.py - Grid simulator → PostgreSQL data: simulates grid events
- Citizen map portal → HTTP client: fetches schedules
frontend/src/components/CitizenMap.tsx - HTTP client → Public schedule API: requests schedules
frontend/src/api/client.ts - Public schedule API → Outage information: delegates lookup
backend/app/modules/public/router.py - Web application → Citizen map portal: routes citizens
frontend/src/App.tsx - Web application → HTTP client: provides requests
- API and app entry → Deficit routes: registers routes
backend/app/main.py - API and app entry → Order routes: registers routes
backend/app/main.py - API and app entry → Execution routes: registers routes
backend/app/main.py - API and app entry → Monitoring routes: registers routes
backend/app/main.py - API and app entry → Evaluation routes: registers routes
backend/app/main.py - API and app entry → Admin routes: registers routes
backend/app/main.py - API and app entry → Public schedule API: registers routes
backend/app/main.py - API and app entry → Grid simulator: starts telemetry
backend/app/main.py - Authentication → Role and scope checks: uses dependencies
backend/app/modules/auth/router.py - Role and scope checks → PostgreSQL data: loads user
backend/app/core/deps.py - Authentication → PostgreSQL data: authenticates users
backend/app/modules/auth/router.py