# sheep-realms/echo-moji architecture

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

- Interactive diagram: https://gitdiagram.com/sheep-realms/echo-moji
- Repository: https://github.com/sheep-realms/echo-moji

## Overview

##### Project type and purpose
- Echo-MoJi is a client-side OBS plugin delivered as HTML/JS/CSS, which displays random “marquee” messages (跑马灯) in a live stream.
- It also includes a standalone settings UI for configuring message content, effects, and appearance.

##### File structure
Top level:
- app.js, config.js – Bootstrap and configuration loader
- message.js – Core message-engine script
- echomoji.html – Main plugin UI (browser source)
- settings.html – Configuration interface
- lang/ – Localization modules
- lib/ – Third-party drivers and markdown support
- res/ – Plugin resources: classes, data tables, images, scripts, styles

Patterns:
- Modular JS classes under res/class
- Data-driven configuration under res/data
- Separation of “runtime” (echomoji.html + message.js + CSS) vs. “configuration” (settings.html + config.js)

##### Extract key insights from the README
- The plugin is deployed by pointing OBS’s Browser Source to echomoji.html.
- Settings saved to disk in the root directory; echomoji.html reads that file at runtime.
- message.js is the core locus for editing the displayed messages.

##### Main components and their interactions
a. OBS Host (External Service)
- Launches a browser instance pointing to echomoji.html.
b. Browser-Source Runtime
- echomoji.html
- app.js: Initializes the plugin, loads config
- driver.js (in lib/driver): Low-level rendering driver
- message.js: Controls the marquee logic
- CSS (in res/style): Defines visuals and animation
- res/class/*.js: Modular tool and UI classes (e.g., EditorConstructor, EchoMoJi, Updater)
c. Settings Interface
- settings.html + i18n.js: UI for adjusting parameters
- config.js: Reads/writes JSON config file to disk
- res/script/settings.js: Hooks UI events, persists changes
d. File System Storage
- config file (JSON) saved in project root
- echomoji.html runtime reload picks up updates
e. Localization Layer
- lang/index.js + lang/*: Language bundles for both interfaces

##### Architectural patterns and principles
- Modular JS classes (OOP-style under res/class)
- Data-driven UI/config (res/data + JSON config)
- Clear separation between “runtime” and “configuration” modes
- Single-page HTML applications leveraging resource directories

##### Technologies & frameworks
- Vanilla JavaScript with IIFE bundles for drivers (lib/driver/driver.js.iife.js)
- CSS for layout and animations (res/style)
- Simple file-based JSON config (no server)
- OBS browser source as the host environment

- Clear labels on each component block
- Blue for runtime components
- Green for settings/config components
- Orange for file storage
- Gray for external OBS host
- Related directories (res/class, res/data, res/style) inside the runtime container
- Interactions: e.g., “message.js triggers CSS animations via driver.js”

## Diagram (Mermaid)

```mermaid
graph TB
    OBS["OBS Host"]:::external

    subgraph "Browser-Source Runtime"
        RHTML["echomoji.html"]:::runtime
        App["app.js"]:::runtime
        ConfigLoader["config.js"]:::runtime
        Message["message.js"]:::runtime
        DriverBundle["driver.js.iife.js"]:::runtime
        DriverCSS["driver.css"]:::runtime

        subgraph "Resources"
            subgraph "CSS Styles"
                CSS1["echomoji.css"]:::runtime
                CSS2["echo.css"]:::runtime
                CSS3["message-effect.css"]:::runtime
            end
            subgraph "Modular JS Classes"
                EchoMoJi["EchoMoJi.js"]:::runtime
                Updater["Updater.js"]:::runtime
                EditorConstructor["EditorConstructor.js"]:::runtime
                DataFilter["DataFilter.js"]:::runtime
                EchoLiveSystem["EchoLiveSystem.js"]:::runtime
                EchoLiveTools["EchoLiveTools.js"]:::runtime
                FHUI["FHUI.js"]:::runtime
                IconClass["Icon.js"]:::runtime
                SettingsManager["SettingsManager.js"]:::runtime
                SystemNotice["SystemNotice.js"]:::runtime
                Translator["Translator.js"]:::runtime
                UniverseWindow["UniverseWindow.js"]:::runtime
            end
            subgraph "Data Definitions"
                DataIn["message_in_effect.js"]:::runtime
                DataOut["message_out_effect.js"]:::runtime
                TextStyle["text_style.js"]:::runtime
                BorderStyle["border_style.js"]:::runtime
                FontWeight["font_weight.js"]:::runtime
                RandomMethod["random_method.js"]:::runtime
                TimingFunction["timing_function.js"]:::runtime
                IconData["icon.js"]:::runtime
                RootData["root.js"]:::runtime
                ConfigDefine["config_define.js"]:::runtime
                SettingsNav["settings_navigation.js"]:::runtime
                SettingsAbout["settings_about_link.js"]:::runtime
            end
        end
    end

    subgraph "Settings UI"
        SettingsHTML["settings.html"]:::settings
        SettingsScript["res/script/settings.js"]:::settings
        i18nScript["res/script/i18n.js"]:::settings
        ConfigFail["res/script/config-load-fail.js"]:::settings
        EditorCommon["res/script/editor-common.js"]:::settings
        EchoSettings["res/script/echomoji.js"]:::settings
        ConfigModule["config.js"]:::settings
    end

    FS["Config File (JSON)"]:::storage
    Lang["Localization Layer"]:::i18n

    OBS -->|"loads"| RHTML
    RHTML -->|"init via"| App
    App -->|"loads config"| ConfigLoader
    App -->|"starts marquee"| Message
    Message -->|"renders via"| DriverBundle
    DriverBundle -->|"styles"| DriverCSS
    Message -->|"applies styles"| CSS1
    Message -->|"applies styles"| CSS2
    Message -->|"applies styles"| CSS3
    Message -->|"uses classes/data"| EchoMoJi
    Message --> EchoLiveSystem
    Message --> DataIn
    Lang --> RHTML
    Lang --> SettingsHTML

    SettingsHTML -->|"UI scripts"| SettingsScript
    SettingsScript -->|"i18n"| i18nScript
    SettingsScript -->|"writes config"| ConfigModule
    ConfigModule -->|"persists"| FS
    ConfigLoader -->|"reads config"| FS
    SettingsScript -->|"reads config"| ConfigModule
    SettingsModuleBidirectional --> SettingsScript

    class SettingsModuleBidirectional ConfigModule
    SettingsScript -->|"reads/writes"| ConfigModule

    classDef runtime fill:#ADD8E6,stroke:#000
    classDef settings fill:#90EE90,stroke:#000
    classDef storage fill:#FFA500,stroke:#000
    classDef external fill:#D3D3D3,stroke:#000
    classDef i18n fill:#E6E6FA,stroke:#000

    click RHTML "https://github.com/sheep-realms/echo-moji/blob/master/echomoji.html"
    click App "https://github.com/sheep-realms/echo-moji/blob/master/app.js"
    click ConfigLoader "https://github.com/sheep-realms/echo-moji/blob/master/config.js"
    click Message "https://github.com/sheep-realms/echo-moji/blob/master/message.js"
    click DriverBundle "https://github.com/sheep-realms/echo-moji/blob/master/lib/driver/driver.js.iife.js"
    click DriverCSS "https://github.com/sheep-realms/echo-moji/blob/master/lib/driver/driver.css"
    click CSS1 "https://github.com/sheep-realms/echo-moji/blob/master/res/style/echomoji.css"
    click CSS2 "https://github.com/sheep-realms/echo-moji/blob/master/res/style/echo.css"
    click CSS3 "https://github.com/sheep-realms/echo-moji/blob/master/res/style/message-effect.css"
    click EchoMoJi "https://github.com/sheep-realms/echo-moji/blob/master/res/class/EchoMoJi.js"
    click Updater "https://github.com/sheep-realms/echo-moji/blob/master/res/class/Updater.js"
    click EditorConstructor "https://github.com/sheep-realms/echo-moji/blob/master/res/class/EditorConstructor.js"
    click DataFilter "https://github.com/sheep-realms/echo-moji/blob/master/res/class/DataFilter.js"
    click EchoLiveSystem "https://github.com/sheep-realms/echo-moji/blob/master/res/class/EchoLiveSystem.js"
    click EchoLiveTools "https://github.com/sheep-realms/echo-moji/blob/master/res/class/EchoLiveTools.js"
    click FHUI "https://github.com/sheep-realms/echo-moji/blob/master/res/class/FHUI.js"
    click IconClass "https://github.com/sheep-realms/echo-moji/blob/master/res/class/Icon.js"
    click SettingsManager "https://github.com/sheep-realms/echo-moji/blob/master/res/class/SettingsManager.js"
    click SystemNotice "https://github.com/sheep-realms/echo-moji/blob/master/res/class/SystemNotice.js"
    click Translator "https://github.com/sheep-realms/echo-moji/blob/master/res/class/Translator.js"
    click UniverseWindow "https://github.com/sheep-realms/echo-moji/blob/master/res/class/UniverseWindow.js"
    click DataIn "https://github.com/sheep-realms/echo-moji/blob/master/res/data/message_in_effect.js"
    click DataOut "https://github.com/sheep-realms/echo-moji/blob/master/res/data/message_out_effect.js"
    click TextStyle "https://github.com/sheep-realms/echo-moji/blob/master/res/data/text_style.js"
    click BorderStyle "https://github.com/sheep-realms/echo-moji/blob/master/res/data/border_style.js"
    click FontWeight "https://github.com/sheep-realms/echo-moji/blob/master/res/data/font_weight.js"
    click RandomMethod "https://github.com/sheep-realms/echo-moji/blob/master/res/data/random_method.js"
    click TimingFunction "https://github.com/sheep-realms/echo-moji/blob/master/res/data/timing_function.js"
    click IconData "https://github.com/sheep-realms/echo-moji/blob/master/res/data/icon.js"
    click RootData "https://github.com/sheep-realms/echo-moji/blob/master/res/data/root.js"
    click ConfigDefine "https://github.com/sheep-realms/echo-moji/blob/master/res/data/config_define.js"
    click SettingsNav "https://github.com/sheep-realms/echo-moji/blob/master/res/data/settings_navigation.js"
    click SettingsAbout "https://github.com/sheep-realms/echo-moji/blob/master/res/data/settings_about_link.js"
    click SettingsHTML "https://github.com/sheep-realms/echo-moji/blob/master/settings.html"
    click SettingsScript "https://github.com/sheep-realms/echo-moji/blob/master/res/script/settings.js"
    click i18nScript "https://github.com/sheep-realms/echo-moji/blob/master/res/script/i18n.js"
    click ConfigFail "https://github.com/sheep-realms/echo-moji/blob/master/res/script/config-load-fail.js"
    click EditorCommon "https://github.com/sheep-realms/echo-moji/blob/master/res/script/editor-common.js"
    click EchoSettings "https://github.com/sheep-realms/echo-moji/blob/master/res/script/echomoji.js"
    click ConfigModule "https://github.com/sheep-realms/echo-moji/blob/master/config.js"
    click Lang "https://github.com/sheep-realms/echo-moji/blob/master/lang/index.js"
```
