# bp2008/ui3 architecture

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

- Interactive diagram: https://gitdiagram.com/bp2008/ui3
- Repository: https://github.com/bp2008/ui3

## Overview

##### Main Components Identification
The system appears to be a web-based frontend application with several key components:

a. Core Interface Components:
- Main UI (ui3.htm, ui3.js, ui3.css)
- Login System (login.htm, loginScripts.js)
- Live Streaming (livestream.htm)
- Help System (ui3/help/)

b. Resource Components:
- Sound Library (/sounds/)
- Third-party Libraries (ui3/libs-src/)

**┌─────────────────────────────────────────────┐**
- UI Layer                   │
- ┤
- Service Worker                 │
- ┤
- Communication Layer               │
- ┤
- Blue Iris Server               │
- ┘

##### Component Relationships

Key interactions:
- Frontend components → Service Worker (ui3serviceworker.js)
- Service Worker → Blue Iris Server
- MQTT Communication (paho-mqtt.js)
- Video Streaming Components (using WebGL, AVI.js, jmuxer.js)

##### Technical Elements

a. Frontend Technologies:
- HTML5 Components
- JavaScript Libraries (Vue.js, jQuery)
- CSS Styling
- WebGL Video Rendering

b. Communication Protocols:
- MQTT
- WebSocket (for real-time updates)
- HTTP/HTTPS

##### User Interface Layer
- Main UI
- Live View
- Configuration Panels

##### Processing Layer
- Video Decoder (openh264_decoder.js)
- Audio Handler
- Event System

##### Communication Layer
- MQTT Client
- WebSocket Handler
- REST API Interface

##### Important Notes

- HTML5/modern browser focus
- Separation between UI3 and Blue Iris server
- Real-time video streaming architecture
- Authentication flow
- Service worker caching strategy

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "UI Layer"
        MainUI["Main UI Interface"]:::ui
        Login["Login System"]:::auth
        LiveStream["Live Streaming"]:::media
        Help["Help System"]:::ui
        click MainUI "https://github.com/bp2008/ui3/blob/master/ui3/ui3.js"
        click Login "https://github.com/bp2008/ui3/blob/master/applet/loginScripts.js"
        click LiveStream "https://github.com/bp2008/ui3/blob/master/livestream.htm"
        click Help "https://github.com/bp2008/ui3/blob/master/ui3/help/help.html"
    end

    subgraph "Service Worker Layer"
        SW["Service Worker"]:::worker
        Cache["Cache Storage"]:::storage
        click SW "https://github.com/bp2008/ui3/blob/master/ui3serviceworker.js"
    end

    subgraph "Processing Layer"
        VideoProc["Video Processing"]:::media
        WebGL["WebGL Renderer"]:::media
        AudioHandler["Audio Handler"]:::media
        EventSystem["Event System"]:::core
        click VideoProc "https://github.com/bp2008/ui3/blob/master/ui3/libs-src/openh264_decoder.js"
        click WebGL "https://github.com/bp2008/ui3/blob/master/ui3/libs-src/WebGLCanvas.js"
    end

    subgraph "Communication Layer"
        MQTT["MQTT Client"]:::comm
        WebSocket["WebSocket Handler"]:::comm
        REST["REST API Interface"]:::comm
        click MQTT "https://github.com/bp2008/ui3/blob/master/ui3/libs-src/paho-mqtt.js"
    end

    subgraph "Resource Layer"
        Sounds["Sound Library"]:::resource
        Icons["Visual Assets"]:::resource
        Libraries["Core Libraries"]:::resource
        click Sounds "https://github.com/bp2008/ui3/tree/master//sounds/"
        click Icons "https://github.com/bp2008/ui3/tree/master/ui3/icons-src/"
        click Libraries "https://github.com/bp2008/ui3/tree/master/ui3/libs-src/"
    end

    subgraph "Server Layer"
        BlueIris["Blue Iris Server"]:::server
    end

    MainUI --> SW
    Login --> SW
    LiveStream --> SW
    Help --> SW

    SW --> Cache
    SW --> MQTT
    SW --> WebSocket
    SW --> REST

    LiveStream --> VideoProc
    VideoProc --> WebGL
    LiveStream --> AudioHandler
    MainUI --> EventSystem

    MQTT --> BlueIris
    WebSocket --> BlueIris
    REST --> BlueIris

    MainUI --> Libraries
    MainUI --> Icons
    AudioHandler --> Sounds

    classDef ui fill:#4287f5,stroke:#333,stroke-width:2px
    classDef auth fill:#f7d794,stroke:#333,stroke-width:2px
    classDef media fill:#2ecc71,stroke:#333,stroke-width:2px
    classDef worker fill:#a55eea,stroke:#333,stroke-width:2px
    classDef storage fill:#778ca3,stroke:#333,stroke-width:2px
    classDef comm fill:#ff7675,stroke:#333,stroke-width:2px
    classDef resource fill:#ffeaa7,stroke:#333,stroke-width:2px
    classDef server fill:#6c5ce7,stroke:#333,stroke-width:2px
    classDef core fill:#81ecec,stroke:#333,stroke-width:2px
```
