# mbrizic/light-system architecture

> Architecture diagram of the GitHub repository mbrizic/light-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mbrizic/light-system
- Repository: https://github.com/mbrizic/light-system

## Overview

##### Component Details

Frontend Components:
- Controllers (dashboard, editor, lights, scenes)
- Components (both generic and specific)
- Services
- Repositories
- Models

Backend Components:
- API Controllers (fileUpload, floorplans, lights, scenes)
- Repositories
- Models
- Helpers and Config

Following interactions:
- Frontend Repository → Backend API
- Backend API → Backend Repository
- Backend Repository → Database
- Frontend Components → Frontend Controllers
- Frontend Controllers → Frontend Repositories

##### Specific Component Relationships
- Floorplan renderer → Light toggles
- Scenes list → Scene toggles
- Light/Scene models → corresponding API endpoints
- File upload component → File storage system

##### Technical Stack Callouts
- Angular.js (Frontend framework)
- Express.js (Backend framework)
- PostgreSQL (Database)
- Node.js (Runtime)
- Bower (Frontend package manager)

Key Architectural Patterns to Highlight:
- MVC pattern in both frontend and backend
- Repository pattern for data access
- Component-based frontend architecture
- RESTful API structure

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Angular.js Frontend]:::frontend
        click FE "https://github.com/mbrizic/light-system/blob/master/frontend/angularapp.js"
        
        subgraph Views
            DV[Dashboard View]:::frontend
            click DV "https://github.com/mbrizic/light-system/blob/master/frontend/views/dashboard.html"
            EV[Editor View]:::frontend
            click EV "https://github.com/mbrizic/light-system/blob/master/frontend/views/editor.html"
            LV[Lights View]:::frontend
            click LV "https://github.com/mbrizic/light-system/blob/master/frontend/views/allLights.html"
            SV[Scenes View]:::frontend
            click SV "https://github.com/mbrizic/light-system/blob/master/frontend/views/allScenes.html"
        end

        subgraph Controllers
            DC[Dashboard Controller]:::frontend
            click DC "https://github.com/mbrizic/light-system/blob/master/frontend/controllers/dashboardController.js"
            EC[Editor Controller]:::frontend
            click EC "https://github.com/mbrizic/light-system/blob/master/frontend/controllers/editorController.js"
            LC[Lights Controller]:::frontend
            click LC "https://github.com/mbrizic/light-system/blob/master/frontend/controllers/allLightsController.js"
            SC[Scenes Controller]:::frontend
            click SC "https://github.com/mbrizic/light-system/blob/master/frontend/controllers/allScenesController.js"
        end

        subgraph Components
            FR[Floorplan Renderer]:::frontend
            click FR "https://github.com/mbrizic/light-system/blob/master/frontend/components/specific/floorplanRenderer.js"
            LT[Light Toggle]:::frontend
            click LT "https://github.com/mbrizic/light-system/blob/master/frontend/components/specific/lightToggle.js"
            ST[Scene Toggle]:::frontend
            click ST "https://github.com/mbrizic/light-system/blob/master/frontend/components/specific/sceneToggle.js"
            SL[Scenes List]:::frontend
            click SL "https://github.com/mbrizic/light-system/blob/master/frontend/components/specific/scenesList.js"
        end

        subgraph "Frontend Repositories"
            LR[Light Repository]:::frontend
            click LR "https://github.com/mbrizic/light-system/blob/master/frontend/repositories/lightRepository.js"
            SR[Scene Repository]:::frontend
            click SR "https://github.com/mbrizic/light-system/blob/master/frontend/repositories/sceneRepository.js"
            FPR[Floorplan Repository]:::frontend
            click FPR "https://github.com/mbrizic/light-system/blob/master/frontend/repositories/floorplanRepository.js"
            FR2[File Repository]:::frontend
            click FR2 "https://github.com/mbrizic/light-system/blob/master/frontend/repositories/fileRepository.js"
        end

        subgraph "Frontend Services"
            MM[Model Mapper]:::frontend
            click MM "https://github.com/mbrizic/light-system/blob/master/frontend/services/modelMapper.js"
            RB[Repository Builder]:::frontend
            click RB "https://github.com/mbrizic/light-system/blob/master/frontend/services/repoBuilder.js"
            INT[Interceptor]:::frontend
            click INT "https://github.com/mbrizic/light-system/blob/master/frontend/interceptor.js"
        end
    end

    subgraph Server
        APP[Express.js Server]:::backend
        click APP "https://github.com/mbrizic/light-system/blob/master/app.js"
        CONF[Server Config]:::backend
        click CONF "https://github.com/mbrizic/light-system/blob/master/backend/config.js"

        subgraph "API Layer"
            LA["Lights API"]:::api
            click LA "https://github.com/mbrizic/light-system/blob/master/backend/api/lightsApi.js"
            SA["Scenes API"]:::api
            click SA "https://github.com/mbrizic/light-system/blob/master/backend/api/scenesApi.js"
            FPA["Floorplans API"]:::api
            click FPA "https://github.com/mbrizic/light-system/blob/master/backend/api/floorplansApi.js"
            FUA["File Upload API"]:::api
            click FUA "https://github.com/mbrizic/light-system/blob/master/backend/api/fileUploadApi.js"
            RTS["Routes"]:::api
            click RTS "https://github.com/mbrizic/light-system/blob/master/backend/api/routes.js"
        end

        subgraph "Backend Repositories"
            BLR[Lights Repository]:::backend
            click BLR "https://github.com/mbrizic/light-system/blob/master/backend/repositories/lightsRepo.js"
            BSR[Scenes Repository]:::backend
            click BSR "https://github.com/mbrizic/light-system/blob/master/backend/repositories/scenesRepo.js"
            BFPR[Floorplans Repository]:::backend
            click BFPR "https://github.com/mbrizic/light-system/blob/master/backend/repositories/floorplansRepo.js"
        end

        subgraph "Backend Models"
            LM[Light Model]:::backend
            click LM "https://github.com/mbrizic/light-system/blob/master/backend/models/LightModel.js"
            SM[Scene Model]:::backend
            click SM "https://github.com/mbrizic/light-system/blob/master/backend/models/SceneModel.js"
            FPM[Floorplan Model]:::backend
            click FPM "https://github.com/mbrizic/light-system/blob/master/backend/models/FloorplanModel.js"
            LSM[Light Scene Model]:::backend
            click LSM "https://github.com/mbrizic/light-system/blob/master/backend/models/LightSceneModel.js"
        end
    end

    subgraph Database
        DB[(PostgreSQL)]:::database
    end

    subgraph "Future Implementation"
        DALI[DALI Interface]:::future
    end

    %% Connections
    DV & EV & LV & SV --> DC & EC & LC & SC
    DC & EC & LC & SC --> LR & SR & FPR & FR2
    LR & SR & FPR & FR2 --> LA & SA & FPA & FUA
    LA & SA & FPA & FUA --> BLR & BSR & BFPR
    BLR & BSR & BFPR --> DB
    FR --> LT
    SL --> ST
    APP --> RTS
    RTS --> LA & SA & FPA & FUA

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef api fill:#e74c3c,stroke:#c0392b,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef future fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        A[API]:::api
        D[Database]:::database
        FU[Future]:::future
    end
```
