# rishishah1704/energy-ems architecture

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

- Interactive diagram: https://gitdiagram.com/rishishah1704/energy-ems
- Repository: https://github.com/rishishah1704/energy-ems

## Overview

Jetpace Energy EMS is a Node-RED energy-monitoring application. Meter readings flow from Modbus polling through parsing to the live dashboard and minute-limited SQL logging; separate report and email workflows query logged data and format downloadable or emailed output. Dashboard capabilities also cover device management, SMTP settings, and protected email access. The flows are documented in the README but their implementation was not sampled, so flow-node paths and links reflect that documentation rather than inspected source; runtime configuration is sampled in settings.js.

Main entry points: [`flows.json`](https://github.com/rishishah1704/energy-ems/blob/main/flows.json) (Email Access & Settings), [`settings.js`](https://github.com/rishishah1704/energy-ems/blob/main/settings.js) (File-backed Context), [`start.js`](https://github.com/rishishah1704/energy-ems/blob/main/start.js) (Node-RED Runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_metering["Metering &amp; Live View"]
  node_request_builder["Request Builder<br/>[flows.json]"]
  node_modbus_reader["Modbus Reader<br/>[flows.json]"]
  node_modbus_parser["Reading Parser<br/>[flows.json]"]
  node_live_dashboard["Live Dashboard<br/>[flows.json]"]
  node_log_limiter["Log Rate Limiter<br/>[flows.json]"]
  node_sql_writer["Energy Log Writer<br/>[flows.json]"]
end

subgraph group_reports["Reports &amp; Email"]
  node_report_builder["Report Query Builder<br/>[flows.json]"]
  node_report_query["Report Query<br/>[flows.json]"]
  node_report_formatter["Report Formatter<br/>[flows.json]"]
  node_report_page["Report Page<br/>[flows.json]"]
  node_email_handler["Email Request Handler<br/>[flows.json]"]
  node_monthly_query_builder["Monthly Query Builder<br/>[flows.json]"]
  node_monthly_query["Monthly Query<br/>[flows.json]"]
  node_email_formatter["Email Formatter<br/>[flows.json]"]
  node_pdf_csv_sender["PDF CSV Sender<br/>[flows.json]"]
  node_auto_trigger["Monthly Trigger<br/>[flows.json]"]
  node_auto_gate["Auto-send Gate<br/>[flows.json]"]
end

subgraph group_dashboard["Dashboard Controls"]
  node_device_controls["Device Management<br/>[flows.json]"]
  node_email_access["Email Access &amp; Settings<br/>[flows.json]"]
end

subgraph group_runtime["Node-RED Runtime"]
  node_persistent_context[("File-backed Context<br/>[settings.js]")]
  node_node_red["Node-RED Runtime<br/>[start.js]"]
end

node_operator(("Dashboard User"))
node_gateway["Modbus Gateway"]
node_sql_data[("MSSQL DATA")]
node_smtp["Gmail SMTP"]

node_gateway -->|"provides meter access"| node_request_builder
node_request_builder -->|"builds requests"| node_modbus_reader
node_modbus_reader -->|"returns registers"| node_modbus_parser
node_modbus_parser -->|"updates readings"| node_live_dashboard
node_modbus_parser -->|"forwards readings"| node_log_limiter
node_log_limiter -->|"limits to minute"| node_sql_writer
node_sql_writer -->|"inserts readings"| node_sql_data
node_operator -->|"views dashboard"| node_live_dashboard
node_operator -->|"selects report range"| node_report_builder
node_report_builder -->|"builds query"| node_report_query
node_report_query -->|"queries readings"| node_sql_data
node_report_query -->|"returns results"| node_report_formatter
node_report_formatter -->|"formats report"| node_report_page
node_operator -->|"downloads report"| node_report_page
node_operator -->|"requests email"| node_email_handler
node_email_handler -->|"routes request"| node_monthly_query_builder
node_monthly_query_builder -->|"builds query"| node_monthly_query
node_monthly_query -->|"queries readings"| node_sql_data
node_monthly_query -->|"returns results"| node_email_formatter
node_email_formatter -->|"formats attachments"| node_pdf_csv_sender
node_pdf_csv_sender -->|"sends email"| node_smtp
node_pdf_csv_sender -->|"returns feedback"| node_live_dashboard
node_auto_trigger -->|"triggers monthly"| node_auto_gate
node_auto_gate -->|"starts eligible send"| node_monthly_query_builder
node_operator -->|"manages devices"| node_device_controls
node_device_controls -->|"persists device list"| node_persistent_context
node_operator -->|"configures email access"| node_email_access
node_email_access -->|"persists settings"| node_persistent_context
node_email_access -->|"updates dashboard"| node_live_dashboard
node_email_access -->|"configures credentials"| node_smtp
node_node_red -->|"configures storage"| node_persistent_context

click node_request_builder "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_modbus_reader "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_modbus_parser "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_live_dashboard "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_log_limiter "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_sql_writer "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_report_builder "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_report_query "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_report_formatter "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_report_page "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_email_handler "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_monthly_query_builder "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_monthly_query "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_email_formatter "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_pdf_csv_sender "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_auto_trigger "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_auto_gate "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_device_controls "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_email_access "https://github.com/rishishah1704/energy-ems/blob/main/flows.json"
click node_persistent_context "https://github.com/rishishah1704/energy-ems/blob/main/settings.js"
click node_node_red "https://github.com/rishishah1704/energy-ems/blob/main/start.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_request_builder,node_modbus_reader,node_modbus_parser,node_live_dashboard,node_log_limiter,node_sql_writer,node_operator toneBlue
class node_report_builder,node_report_query,node_report_formatter,node_report_page,node_email_handler,node_monthly_query_builder,node_monthly_query,node_email_formatter,node_pdf_csv_sender,node_auto_trigger,node_auto_gate,node_sql_data toneAmber
class node_device_controls,node_email_access toneMint
class node_persistent_context,node_node_red toneRose
class node_gateway,node_smtp toneIndigo
```

## Components

### Metering & Live View

- [Request Builder](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Modbus Reader](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Reading Parser](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Live Dashboard](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Log Rate Limiter](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Energy Log Writer](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`

### Reports & Email

- [Report Query Builder](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Report Query](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Report Formatter](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Report Page](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Email Request Handler](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Monthly Query Builder](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Monthly Query](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Email Formatter](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [PDF CSV Sender](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Monthly Trigger](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Auto-send Gate](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`

### Dashboard Controls

- [Device Management](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`
- [Email Access & Settings](https://github.com/rishishah1704/energy-ems/blob/main/flows.json): `flows.json`

### Node-RED Runtime

- [File-backed Context](https://github.com/rishishah1704/energy-ems/blob/main/settings.js): `settings.js`
- [Node-RED Runtime](https://github.com/rishishah1704/energy-ems/blob/main/start.js): `start.js`

### Other components

- **Dashboard User**
- **Modbus Gateway**
- **MSSQL DATA**
- **Gmail SMTP**

## Connections

- Modbus Gateway → Request Builder: provides meter access (evidence: `README.md`)
- Request Builder → Modbus Reader: builds requests (evidence: `README.md`)
- Modbus Reader → Reading Parser: returns registers (evidence: `README.md`)
- Reading Parser → Live Dashboard: updates readings (evidence: `README.md`)
- Reading Parser → Log Rate Limiter: forwards readings (evidence: `README.md`)
- Log Rate Limiter → Energy Log Writer: limits to minute (evidence: `README.md`)
- Energy Log Writer → MSSQL DATA: inserts readings (evidence: `README.md`)
- Dashboard User → Live Dashboard: views dashboard (evidence: `README.md`)
- Dashboard User → Report Query Builder: selects report range (evidence: `README.md`)
- Report Query Builder → Report Query: builds query (evidence: `README.md`)
- Report Query → MSSQL DATA: queries readings (evidence: `README.md`)
- Report Query → Report Formatter: returns results (evidence: `README.md`)
- Report Formatter → Report Page: formats report (evidence: `README.md`)
- Dashboard User → Report Page: downloads report (evidence: `README.md`)
- Dashboard User → Email Request Handler: requests email (evidence: `README.md`)
- Email Request Handler → Monthly Query Builder: routes request (evidence: `README.md`)
- Monthly Query Builder → Monthly Query: builds query (evidence: `README.md`)
- Monthly Query → MSSQL DATA: queries readings (evidence: `README.md`)
- Monthly Query → Email Formatter: returns results (evidence: `README.md`)
- Email Formatter → PDF CSV Sender: formats attachments (evidence: `README.md`)
- PDF CSV Sender → Gmail SMTP: sends email (evidence: `README.md`)
- PDF CSV Sender → Live Dashboard: returns feedback (evidence: `README.md`)
- Monthly Trigger → Auto-send Gate: triggers monthly (evidence: `README.md`)
- Auto-send Gate → Monthly Query Builder: starts eligible send (evidence: `README.md`)
- Dashboard User → Device Management: manages devices (evidence: `README.md`)
- Device Management → File-backed Context: persists device list (evidence: `README.md`)
- Dashboard User → Email Access & Settings: configures email access (evidence: `README.md`)
- Email Access & Settings → File-backed Context: persists settings (evidence: `README.md`)
- Email Access & Settings → Live Dashboard: updates dashboard (evidence: `README.md`)
- Email Access & Settings → Gmail SMTP: configures credentials (evidence: `README.md`)
- Node-RED Runtime → File-backed Context: configures storage (evidence: `settings.js`)
