# gedxxe/midea-jre-uniland-waste-calculator architecture

> Architecture diagram of the GitHub repository gedxxe/midea-jre-uniland-waste-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gedxxe/midea-jre-uniland-waste-calculator
- Repository: https://github.com/gedxxe/midea-jre-uniland-waste-calculator

## Overview

Midea Daily Energy Report is a browser-based energy reporting workspace for JRE and UNILAND operators, with account-owned history and a separate IoT diagnostics area. The main workflow is entering dated meter readings, calculating and reviewing energy and utility usage, then copying a report or Excel row while drafts autosave. Other documented branches include history and monitoring, imports/exports, accounts, and device diagnostics. The sampled excerpts support the calculation, draft, authentication, and database layers; several other capabilities are README-described but their runtime wiring was not sampled.

Main entry points: [`engine.js`](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/engine.js) (Usage calculation), [`storage.js`](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/storage.js) (Workspace storage), [`app.js`](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/app.js) (Reading workspace), [`server/auth-handlers.js`](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/auth-handlers.js) (Authentication API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Reading workspace"]
  node_workspace_app["Reading workspace<br/>[app.js]"]
end

subgraph group_calculation["Energy calculations"]
  node_reading_rules["Period rules<br/>[reading-period.js]"]
  node_plant_schema["Plant meter schema<br/>[schema.js]"]
  node_energy_engine["Usage calculation<br/>[engine.js]"]
  node_gas_calc["Gas calculations<br/>[gas.js]"]
  node_water_calc["Water calculations<br/>[water.js]"]
  node_compressor_calc["Compressor calculations<br/>[air-compressor.js]"]
  node_utility_periods["Utility periods<br/>[utility-periods.js]"]
  node_numeric_rules["Number handling<br/>[numbers.js]"]
end

subgraph group_records["Drafts and history"]
  node_draft_model["Draft records<br/>[draft-records.js]"]
  node_browser_storage["Workspace storage<br/>[storage.js]"]
  node_draft_sync["Draft sync UI<br/>[drafts.js]"]
end

subgraph group_services["Server services"]
  node_accounts_ui["Account management<br/>[accounts.js]"]
  node_auth_handlers["Authentication API<br/>[auth-handlers.js]"]
  node_auth_core["Session security<br/>[auth.js]"]
  node_database_access["Database access<br/>[db.js]"]
end

subgraph group_capabilities["Reports and devices"]
  node_graphs["Monitoring graphs<br/>[graphs.js]"]
  node_reports["Reports and exports<br/>[reports.js]"]
  node_iot_ui["Device diagnostics<br/>[iot.js]"]
  node_iot_service["IoT service<br/>[iot.js]"]
  node_import_export["Reading import export<br/>[importer.js]"]
end

node_operator(("Operator"))
node_postgres[("PostgreSQL")]

node_operator -->|"enters readings"| node_workspace_app
node_workspace_app -->|"uses period rules"| node_reading_rules
node_workspace_app -->|"restores workspace"| node_browser_storage
node_workspace_app -.->|"calculates usage"| node_energy_engine
node_energy_engine -->|"checks periods"| node_reading_rules
node_energy_engine -->|"calculates gas"| node_gas_calc
node_energy_engine -->|"calculates water"| node_water_calc
node_energy_engine -->|"calculates compressor"| node_compressor_calc
node_energy_engine -->|"uses utility layout"| node_utility_periods
node_energy_engine -->|"parses readings"| node_numeric_rules
node_browser_storage -->|"creates drafts"| node_energy_engine
node_browser_storage -->|"moves utility data"| node_utility_periods
node_browser_storage -->|"checks shift type"| node_reading_rules
node_draft_model -->|"persists drafts"| node_browser_storage
node_draft_sync -->|"restores records"| node_draft_model
node_draft_sync -->|"compares workspace"| node_browser_storage
node_accounts_ui -.->|"manages accounts"| node_auth_handlers
node_auth_handlers -->|"checks sessions"| node_auth_core
node_auth_handlers -->|"runs transactions"| node_database_access
node_auth_core -.->|"queries sessions"| node_database_access
node_database_access -->|"connects to"| node_postgres
node_operator -->|"reviews monitoring"| node_graphs
node_operator -->|"copies reports"| node_reports
node_operator -->|"imports readings"| node_import_export
node_operator -->|"checks devices"| node_iot_ui
node_iot_ui -.->|"requests device data"| node_iot_service

click node_workspace_app "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/app.js"
click node_reading_rules "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/reading-period.js"
click node_plant_schema "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/schema.js"
click node_energy_engine "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/engine.js"
click node_gas_calc "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/gas.js"
click node_water_calc "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/water.js"
click node_compressor_calc "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/air-compressor.js"
click node_utility_periods "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/utility-periods.js"
click node_numeric_rules "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/numbers.js"
click node_draft_model "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/draft-records.js"
click node_browser_storage "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/storage.js"
click node_draft_sync "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/ui/drafts.js"
click node_accounts_ui "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/ui/accounts.js"
click node_auth_handlers "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/auth-handlers.js"
click node_auth_core "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/auth.js"
click node_database_access "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/db.js"
click node_graphs "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/ui/graphs.js"
click node_reports "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/reports.js"
click node_iot_ui "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/ui/iot.js"
click node_iot_service "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/iot.js"
click node_import_export "https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/importer.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_workspace_app toneBlue
class node_reading_rules,node_plant_schema,node_energy_engine,node_gas_calc,node_water_calc,node_compressor_calc,node_utility_periods,node_numeric_rules,node_postgres toneAmber
class node_draft_model,node_browser_storage,node_draft_sync toneMint
class node_accounts_ui,node_auth_handlers,node_auth_core,node_database_access toneRose
class node_graphs,node_reports,node_iot_ui,node_iot_service,node_import_export,node_operator toneIndigo
```

## Components

### Reading workspace

- [Reading workspace](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/app.js): `app.js`

### Energy calculations

- [Period rules](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/reading-period.js): `reading-period.js`
- [Plant meter schema](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/schema.js): `schema.js`
- [Usage calculation](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/engine.js): `engine.js`
- [Gas calculations](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/gas.js): `gas.js`
- [Water calculations](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/water.js): `water.js`
- [Compressor calculations](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/air-compressor.js): `air-compressor.js`
- [Utility periods](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/utility-periods.js): `utility-periods.js`
- [Number handling](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/numbers.js): `numbers.js`

### Drafts and history

- [Draft records](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/draft-records.js): `draft-records.js`
- [Workspace storage](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/storage.js): `storage.js`
- [Draft sync UI](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/ui/drafts.js): `ui/drafts.js`

### Server services

- [Account management](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/ui/accounts.js): `ui/accounts.js`
- [Authentication API](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/auth-handlers.js): `server/auth-handlers.js`
- [Session security](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/auth.js): `server/auth.js`
- [Database access](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/db.js): `server/db.js`

### Reports and devices

- [Monitoring graphs](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/ui/graphs.js): `ui/graphs.js`
- [Reports and exports](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/reports.js): `server/reports.js`
- [Device diagnostics](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/ui/iot.js): `ui/iot.js`
- [IoT service](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/server/iot.js): `server/iot.js`
- [Reading import export](https://github.com/gedxxe/midea-jre-uniland-waste-calculator/blob/main/importer.js): `importer.js`

### Other components

- **Operator**
- **PostgreSQL**

## Connections

- Operator → Reading workspace: enters readings (evidence: `README.md`)
- Reading workspace → Period rules: uses period rules (evidence: `app.js`)
- Reading workspace → Workspace storage: restores workspace (evidence: `app.js`)
- Reading workspace → Usage calculation: calculates usage (evidence: `app.js`)
- Usage calculation → Period rules: checks periods (evidence: `engine.js`)
- Usage calculation → Gas calculations: calculates gas (evidence: `engine.js`)
- Usage calculation → Water calculations: calculates water (evidence: `engine.js`)
- Usage calculation → Compressor calculations: calculates compressor (evidence: `engine.js`)
- Usage calculation → Utility periods: uses utility layout (evidence: `engine.js`)
- Usage calculation → Number handling: parses readings (evidence: `engine.js`)
- Workspace storage → Usage calculation: creates drafts (evidence: `storage.js`)
- Workspace storage → Utility periods: moves utility data (evidence: `storage.js`)
- Workspace storage → Period rules: checks shift type (evidence: `storage.js`)
- Draft records → Workspace storage: persists drafts (evidence: `draft-records.js`)
- Draft sync UI → Draft records: restores records (evidence: `ui/drafts.js`)
- Draft sync UI → Workspace storage: compares workspace (evidence: `ui/drafts.js`)
- Account management → Authentication API: manages accounts
- Authentication API → Session security: checks sessions (evidence: `server/auth-handlers.js`)
- Authentication API → Database access: runs transactions (evidence: `server/auth-handlers.js`)
- Session security → Database access: queries sessions
- Database access → PostgreSQL: connects to (evidence: `server/db.js`)
- Operator → Monitoring graphs: reviews monitoring (evidence: `README.md`)
- Operator → Reports and exports: copies reports (evidence: `README.md`)
- Operator → Reading import export: imports readings (evidence: `README.md`)
- Operator → Device diagnostics: checks devices (evidence: `README.md`)
- Device diagnostics → IoT service: requests device data
