# flowfuse/node-red-dashboard architecture

> Architecture diagram of the GitHub repository flowfuse/node-red-dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flowfuse/node-red-dashboard
- Repository: https://github.com/flowfuse/node-red-dashboard

## Overview

##### Project Type and Purpose
- This is an open-source dashboard extension for Node-RED. Its purpose is to provide a set of UI nodes (widgets) for building user interfaces and data visualizations inside Node-RED flows. It offers rich customization (via templates, custom theming etc.), and includes both a runtime component (the nodes and configuration under “nodes”) and a full-featured front-end dashboard component (under “ui”). In addition, there is extensive documentation and examples.

##### File Structure to Identify Architectural Components
- Core Backend/Node Components:
- The “nodes” directory contains configuration files (HTML/JS for UI nodes, multilingual locale support, data store files, etc.) that integrate into Node-RED’s backend.
- Subdirectories such as “nodes/config”, “nodes/store”, “nodes/utils”, and “nodes/widgets” indicate modular organization for node definitions, configuration options, and widget logic.
- Frontend UI:
- The “ui” directory holds the front-end assets including a Vue-based application (in “ui/src”) that renders the dashboard interface, including components, layouts, and widgets.
- Files like “ui/src/App.vue”, “ui/src/router.mjs”, and “ui/src/services” indicate a SPA (Single Page Application) that communicates with the Node-RED nodes.
- Testing and Continuous Integration:
- Cypress tests under the “cypress” folder show that end-to-end user flows, widget behaviors, and layout configurations are validated.
- The “test” directory includes unit tests for various aspects, especially for Node-related configurations and widget functionality.
- Documentation and Examples:
- The “docs” directory with subdirectories for guides, examples, contributed code demos, and design patterns reveal how end users can implement, customize, and extend the dashboard.
- CI/CD and Project Automation:
- The “.github” directory contains GitHub workflows (build, test, deploy docs, and automation scripts) which are essential to understanding the overall development and deployment lifecycle.
- Supporting Files/Configuration:
- Files like “manifest.json”, “package.json”, “vite.config.js”, and “pwa-assets.config.js” define the build and dependency environment.

a. Main Components:
- Node-RED Integration Layer / Backend:
- Nodes (core implementation in “nodes” – configuration, store, and widgets).
- API or service layer that handles communication between Node-RED runtime and the dashboard.
- Dashboard Frontend:
- The UI application (built using Vue.js under “ui/src”) that renders the dashboard and handles user interactions.
- Database/State Management:
- Although there isn’t any explicit database directory, the “nodes/store” and “ui/src/store” manage state.
- Testing & Automation:
- Cypress and unit test components.
- Documentation/Developer Resources:
- Docs, examples, and guides.
- External Dependencies:

b. Relationships and Interactions:
- The Node-RED runtime communicates with dashboard nodes (from the “nodes” directory) to relay control commands and data.
- The UI front-end (SPA) interacts with these nodes via API calls (or WebSocket events) to render dashboards.
- User interactions (e.g., clicks on a widget) send events from the UI back to the Node-RED flow.
- The testing pipelines (CI tools in “.github/workflows” and Cypress tests) trigger builds, tests, and deployment which feed back into both the UI and the Node integration.
c. Architectural Patterns and Design Principles:
- Modularized structure separating concerns:
- Backend nodes and configuration are kept separate from the front-end application.
- A clear MVC-like pattern for the UI: Vue components (views), store (model), and services (controller/API access).
- Emphasis on extensibility: numerous directories under “nodes/widgets” and “docs/contributing” encourage community extension.
- Continuous Integration/Deployment flows integrate code quality (linting, tests) and documentation (deploy-docs workflow).

d. Relevant Technologies, Frameworks, or Libraries:
- Node-RED platform integration.
- Vue.js (observed in “ui/src” components and configuration files like “main.mjs” and “router.mjs”).
- Cypress for end-to-end testing.
- Possibly Vite (given the “vite.config.js”) for build processes.

##### Final Recommendations
- That all key elements (integration, UI, testing, documentation, CI/CD) are represented.
- If possible, include notes on how each component interfaces with the core Node-RED engine.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build & Dependency Configuration
    subgraph "Build & Dependency Configuration"
        manifest["manifest.json"]:::build
        pkg["package.json"]:::build
        vite["vite.config.js"]:::build
        pwa["pwa-assets.config.js"]:::build
    end

    %% Node-RED Integration / Backend Nodes
    subgraph "Node-RED Integration (Backend Nodes)"
        nBackend["Nodes (Backend)"]:::backend
        nConfig["Nodes Config"]:::backend
        nStore["Nodes Store"]:::backend
        nUtils["Nodes Utils"]:::backend
        nWidgets["Nodes Widgets"]:::backend
    end

    %% Dashboard Frontend (Vue.js UI)
    subgraph "Dashboard Frontend (Vue.js UI)"
        uiApp["UI Application (Vue.js)"]:::frontend
    end

    %% Testing & Continuous Integration
    subgraph "Testing & Continuous Integration"
        e2e["End-to-end Tests (Cypress)"]:::testing
        unit["Unit Tests (Node Tests)"]:::testing
    end

    %% Documentation & Examples
    subgraph "Documentation & Examples"
        docsMain["Documentation Main"]:::docs
        docsContrib["Contributing"]:::docs
        docsExamples["Examples"]:::docs
        docsNodes["Nodes Docs"]:::docs
        docsLayouts["Layouts Guides"]:::docs
    end

    %% CI/CD and Project Automation
    subgraph "CI/CD and Project Automation"
        github[".github Workflows"]:::cicd
    end

    %% Relationships
    %% Build & Config feeds Backend and Frontend
    manifest -->|"configures"| nBackend
    pkg -->|"manages"| nBackend
    vite -->|"builds"| uiApp
    pwa -->|"assets"| uiApp

    %% UI and Backend Communication
    uiApp -- "sends/receives" --> nWidgets
    uiApp -- "updates" --> nStore

    %% Testing affects both UI and Backend
    e2e -- "validates" --> uiApp
    e2e -- "validates" --> nWidgets
    unit -- "verifies" --> nBackend

    %% CI/CD triggers Testing and Documentation updates
    github -- "runs" --> e2e
    github -- "runs" --> unit
    github -- "deploys" --> docsMain

    %% Documentation reflects structure of Backend and UI
    docsMain -- "describes" --> nBackend
    docsMain -- "describes" --> uiApp
    docsMain -- "includes" --> docsContrib
    docsMain -- "includes" --> docsExamples
    docsMain -- "includes" --> docsNodes
    docsMain -- "includes" --> docsLayouts

    %% Click Events
    click nBackend "https://github.com/flowfuse/node-red-dashboard/tree/main/nodes"
    click nConfig "https://github.com/flowfuse/node-red-dashboard/tree/main/nodes/config"
    click nStore "https://github.com/flowfuse/node-red-dashboard/tree/main/nodes/store"
    click nUtils "https://github.com/flowfuse/node-red-dashboard/tree/main/nodes/utils"
    click nWidgets "https://github.com/flowfuse/node-red-dashboard/tree/main/nodes/widgets"
    click uiApp "https://github.com/flowfuse/node-red-dashboard/tree/main/ui/src"
    click e2e "https://github.com/flowfuse/node-red-dashboard/tree/main/cypress"
    click unit "https://github.com/flowfuse/node-red-dashboard/tree/main/test"
    click docsMain "https://github.com/flowfuse/node-red-dashboard/tree/main/docs"
    click docsContrib "https://github.com/flowfuse/node-red-dashboard/tree/main/docs/contributing"
    click docsExamples "https://github.com/flowfuse/node-red-dashboard/tree/main/docs/examples"
    click docsNodes "https://github.com/flowfuse/node-red-dashboard/tree/main/docs/nodes"
    click docsLayouts "https://github.com/flowfuse/node-red-dashboard/tree/main/docs/layouts"
    click github "https://github.com/flowfuse/node-red-dashboard/tree/main/.github/workflows"
    click manifest "https://github.com/flowfuse/node-red-dashboard/blob/main/manifest.json"
    click pkg "https://github.com/flowfuse/node-red-dashboard/blob/main/package.json"
    click vite "https://github.com/flowfuse/node-red-dashboard/blob/main/vite.config.js"
    click pwa "https://github.com/flowfuse/node-red-dashboard/blob/main/pwa-assets.config.js"

    %% Styles
    classDef backend fill:#f1c40f,stroke:#000,stroke-width:1px;
    classDef frontend fill:#3498db,stroke:#000,stroke-width:1px;
    classDef testing fill:#9b59b6,stroke:#000,stroke-width:1px;
    classDef docs fill:#2ecc71,stroke:#000,stroke-width:1px;
    classDef cicd fill:#e67e22,stroke:#000,stroke-width:1px;
    classDef build fill:#e74c3c,stroke:#000,stroke-width:1px;
```
