# ivansstoyanov/led-lights-server architecture

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

- Interactive diagram: https://gitdiagram.com/ivansstoyanov/led-lights-server
- Repository: https://github.com/ivansstoyanov/led-lights-server

## Overview

##### Project Type and Purpose
- The project appears to be a Node.js–based LED lights server application intended to run on a Raspberry Pi (“how to start node on startup” in the README). It uses AngularJS on the frontend (inside the “public” folder with controllers, directives, and factories) and Socket.IO to enable real-time communication (note the inclusion of “socket.io-1.2.0.js” and a SocketFactory).
- The purpose is to control or manage LED lighting (likely on a Raspberry Pi) with a web-based user interface, which implies a full-stack application with a clear separation of client (Angular, jQuery, etc.) and server (Node.js, services).

##### File Structure
- Top-level Directories:
- .github: Contains CI/CD configuration (e.g., CodeQL analysis).
- public: Holds the client-side code including index.html, JavaScript controllers, directives, factories, and CSS files.
- js: Contains additional JavaScript files (e.g., socket.io library, Angular-route library, and an older version of jQuery).
- services: Contains server-side business logic (e.g., transitionService.js), likely handling effect transitions for the LED lights.
- database: Contains several JSON files (effects, errors, settings, transitions) which provide configuration and lookup data.
- server.js: The main server file that starts the Node.js application.
- The mix of directories suggests an architectural division between the client-side app (AngularJS app in the “public” directory) and the server-side logic (Node.js server with “services” and “database”).

##### Elements
- Clear labels for each component (Client UI, API/Real-time Server, Configuration Data, External Libraries, etc.).
- Client to Server (HTTP and WebSocket calls)
- Server reading from configuration JSON files
- Possibly server sending back real-time updates to the client

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        A["AngularJS Application (public/)"]:::client
    end

    %% Real-Time Communication
    subgraph "Real-Time Communication"
        B["Socket Factory (public/factories/SocketFactory.js)"]:::client
        J["Socket.IO Library (js/socket.io-1.2.0.js)"]:::external
    end

    %% Server Side
    subgraph "Server Side"
        C["Server (server.js)"]:::server
        D["Transition Service (services/transitionService.js)"]:::server
    end

    %% Configuration Data
    subgraph "Configuration Data"
        E["Configuration Data (database/)"]:::config
    end

    %% External Dependencies
    subgraph "External Dependencies"
        F["Frontend Libraries (bower_components/)"]:::external
        G["Additional Libraries (js/)"]:::external
    end

    %% CI/CD Configuration
    subgraph "CI/CD"
        H["GitHub Actions (.github/workflows)"]:::cicd
    end

    %% Deployment Environment
    I["Raspberry Pi (Deployment)"]:::deployment

    %% Connections
    A -->|"HTTP"| C
    B <-->|"socket.io"| C
    B -->|"uses"| J
    C -->|"uses"| D
    C -->|"reads_config"| E
    A -->|"depends_on"| F
    A -->|"depends_on"| G
    H -->|"deploys"| C
    C -->|"runs_on"| I

    %% Click Events
    click A "https://github.com/ivansstoyanov/led-lights-server/tree/master/public/"
    click C "https://github.com/ivansstoyanov/led-lights-server/blob/master/server.js"
    click D "https://github.com/ivansstoyanov/led-lights-server/blob/master/services/transitionService.js"
    click E "https://github.com/ivansstoyanov/led-lights-server/tree/master/database/"
    click J "https://github.com/ivansstoyanov/led-lights-server/blob/master/js/socket.io-1.2.0.js"
    click F "https://github.com/ivansstoyanov/led-lights-server/tree/master/bower_components/"
    click G "https://github.com/ivansstoyanov/led-lights-server/tree/master/js/"
    click H "https://github.com/ivansstoyanov/led-lights-server/tree/master/.github/workflows/"
    click B "https://github.com/ivansstoyanov/led-lights-server/blob/master/public/factories/SocketFactory.js"

    %% Styles
    classDef client fill:#AED6F1,stroke:#2E86C1,stroke-width:2px;
    classDef server fill:#F9E79F,stroke:#F4D03F,stroke-width:2px;
    classDef config fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef cicd fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef deployment fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
```
