# kait-hems/elonlinedemo architecture

> Architecture diagram of the GitHub repository kait-hems/elonlinedemo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kait-hems/elonlinedemo
- Repository: https://github.com/kait-hems/elonlinedemo

## Overview

##### Project Type and Purpose
- This is a full-stack demonstration application that acts as an online control tool for ECHONET Lite (EL) compliant devices.
- Its purpose is to offer a Web UI (built using Vue.js) that allows a user to search for devices, configure settings, and perform get/set operations on EL devices over a UDP network.
- The README explains that the application starts a “controller” service and establishes WebSocket connections with the browser, while reading various configuration files (from the conf folder) that drive its behavior.

##### File Structure
- Top-Level Files: The project has an app.js file that is likely the main entry point for the Node.js server component.
- Conf Directory: Contains configuration files (app.json, manufacturer/mra data, definitions, devices, etc.) that define system behavior, network parameters, and mapping rules for EL devices. This signals that the back-end is heavily configurable.
- Public and Src Folders:
- The “public” directory holds static assets (HTML, CSS, JS, fonts, images) and likely is used as the document root (as per dir.html in app.json).
- The “src” folder holds the Vue.js application including components (e.g., TheHeader.vue, TheMain.vue, and various views for battery controls, EV charger controls, help and settings), routing, state management (store), and TypeScript setup. These indicate a clear separation between the UI and server component.
- Other Supporting Files: Configuration for Babel, TypeScript (tsconfig.json), and Vue (vue.config.js) and documentation files show that the development setup is robust and supports modern JavaScript/TypeScript frameworks.

##### Key Components
a. Frontend Component (Web UI):
- Represented by the Vue.js application (within “src” and “public”). It includes:
- Various views (Home, Logger, Settings, Help, Battery, EVCharger, etc.).
- Components and single-view components (like Controller, Profile, Search) that build the interactive UI.
- Routing and state management modules.
- That the Web UI communicates with the backend using WebSocket (as mentioned in the README) for real-time updates/control.
b. Backend Component (Node.js Server):
- The main entry point (app.js) initializes the server.
- It loads configuration from the “conf” folder including “app.json” and mra/ manufacturer-related configuration (including device definitions, rules, and profiles).
- It handles UDP communications with EL devices, as well as HTTP and WebSocket services for the UI.
c. Configuration/Data Layer:
- app.json for general settings.
- mraData subfolders (MCRules, definitions, devices, nodeProfile, etc.) to map out and define ECHONET rules and device details.
- Other configuration files (manufacturer codes, text, etc.).
d. External Communication:
- UDP Connection: Illustrate how the backend uses UDP protocols to discover and communicate with EL devices on the network.
- Web Browser: Show a client node representing the end-user’s browser connecting to the server via HTTP and WebSocket for real-time interaction.

##### Relationships and Interactions
- From the Browser (frontend) to the Backend (Node.js server) indicating HTTP requests and WebSocket connections.
- Between the Backend and the UDP network, showing communication with ECHONET Lite devices (potentially bi-directional for commands and responses).
- Within the Backend, show the flow where configuration data is loaded from the “conf” directory and used to initialize network parameters and UI settings.

##### Architectural Patterns
- Separation of Concerns: Clearly separate the UI (Vue.js SPA) from the backend server.
- Configurable Design: Emphasize that behavior is driven by external JSON configuration in the “conf” folder, allowing easy updates to network settings and device parameters without changing the code.
- Real-time Communication: Use WebSocket for pushing updates to the furthest end (browser), indicating a reactive pattern.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE1["Vue.js Frontend"]:::frontend
        FE2["Static Assets"]:::frontend
        FE1 -->|"includes"| FE2
    end

    subgraph "Backend Layer"
        BE1["Node.js Server"]:::backend
        BE2["Configuration Manager"]:::config
        BE3["UDP Communication Module"]:::backend
        BE2 -->|"load_config"| BE1
        BE1 -->|"handles"| BE3
    end

    EXT1["Web Browser (Client)"]:::external
    EXT2["EL Devices (ECHONET Lite)"]:::external

    EXT1 -->|"HTTP/WebSocket"| FE1
    FE1 -->|"API_Request"| BE1
    BE3 -->|"UDP_Command/Response"| EXT2

    click FE1 "https://github.com/kait-hems/elonlinedemo/tree/main/src/"
    click FE2 "https://github.com/kait-hems/elonlinedemo/tree/main/public/"
    click BE1 "https://github.com/kait-hems/elonlinedemo/blob/main/app.js"
    click BE2 "https://github.com/kait-hems/elonlinedemo/tree/main/conf/"

    classDef frontend fill:#DDEBF7,stroke:#2F75B5,stroke-width:2px;
    classDef backend fill:#FCE4D6,stroke:#D35400,stroke-width:2px;
    classDef config fill:#FFF2CC,stroke:#D6B656,stroke-width:2px;
    classDef external fill:#E2EFDA,stroke:#44BBA4,stroke-width:2px;
```
