# elaina69/elaina-v4 architecture

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

- Interactive diagram: https://gitdiagram.com/elaina69/elaina-v4
- Repository: https://github.com/elaina69/elaina-v4

## Overview

##### Project Type and Purpose
- This is a front-end “theme” package for the Pengu Loader (a League of Legends launcher).

##### File Structure Analysis
- Top-Level:
- src/index.ts – entry point for bootstrapping the theme.
- vite.config.ts, tsconfig.json – build tooling (Vite + TypeScript).
- src/src/locales – language resource files.
- src/src/plugins – optional feature modules (autoQueue, hideFriendlist, customStatus, etc.).
- src/src/services – helper services (backup/restore theme settings).
- src/src/theme – core theming logic (load CSS, apply UI changes, initialize CDN).
- src/src/updates – update-checking logic.
- src/src/utils – utility functions (time setting, theme logging, datastore helpers).

##### Key README Insights
- This is exclusively a theme for Pengu Loader v1.1.0+ on Windows.
- No separate backend or database server; runs entirely in the host app’s context.
- Plugins are packaged within the theme; they hook into Pengu Loader’s API.

##### Main Components and Their Relationships
A. Pengu Loader Host (external system)
– Loads the theme’s index.ts at startup.
B. Theme Bootstrap (index.ts)
– Initializes theme: calls theme/Cdninit.ts, loadCss.ts → injects CSS and assets.
– Registers update checker (updates/checkUpdate.ts).
– Initializes services (backupAndRestoreDatastore).
C. Config Module
– Provides default settings, filters, resource paths.
– Injected into bootstrap and plugins via a shared config API.
D. Assets & Styles
– CSS components (assets/styles/components) and themes (assets/styles/themes) loaded by theme logic.
E. Plugins Subsystem
– A registry of plugin modules under src/src/plugins/*.ts
– Each plugin imports shared services/config and registers callbacks/hooks into Pengu Loader’s UI events.
– SettingsGroups define UI for plugin configuration.
F. Services & Utilities
– Backup/restore (services/backupAndRestoreDatastore.ts) persists theme settings.
– Utilities support generic tasks (themeDataStore, setTime, logging).
G. Update Manager
– Periodically checks for new theme version and prompts host.

##### Architectural Patterns & Design Principles
- Modular architecture: clear separation of theme core, assets, config, plugins, and services.
- Plug-in pattern: each feature is encapsulated in its own module and can be enabled/disabled.
- Layered asset loading: configuration → CSS injection → plugin registration → UI override.
- Single SPA entry point: index.ts orchestrates all modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External System
    Host["Pengu Loader Host"]:::external

    %% Theme Package Container
    subgraph "Theme Package"
        subgraph "Bootstrap Layer"
            Bootstrap["src/index.ts"]:::bootstrap
            CdnInit["Cdninit.ts"]:::bootstrap
            LoadCss["loadCss.ts"]:::bootstrap
            ApplyUi["applyUi.ts"]:::bootstrap
            ThemeFilters["filters.ts"]:::bootstrap
            Presets["themePresetSettingsTab.ts"]:::bootstrap
            Homepage["homepage.ts"]:::bootstrap
        end

        subgraph "Config Module"
            CDNConfig["cdnServer.js"]:::config
            ChampsBg["champsBgList.js"]:::config
            DSDefaults["datastoreDefault.js"]:::config
            UIFilters["filters.js"]:::config
            Icons["icons.js"]:::config
            CustomText["customStatus.txt"]:::config
        end

        subgraph "Assets & Styles"
            Assets["assets/"]:::assets
            StylesComp["components/"]:::assets
            StylesThemes["themes/"]:::assets
        end

        subgraph "Plugins Subsystem"
            PluginsDir["plugins/"]:::plugin
            SettingsStruct["settingsStructure.ts"]:::plugin
            SettingsUI["settingsUI.ts"]:::plugin
            AboutUs["themeAboutUs.ts"]:::plugin
            PluginsSettings["themePluginsSettings.ts"]:::plugin
            ThemeSettings["themeSettings.ts"]:::plugin
        end

        subgraph "Services & Utilities"
            Backup["backupAndRestoreDatastore.ts"]:::service
            SetTime["setTime.ts"]:::util
            DataStore["themeDataStore.ts"]:::util
            Log["themeLog.ts"]:::util
            Utils["utils.ts"]:::util
            SettingsUtils["settingsUtils.ts"]:::util
        end

        subgraph "Update Manager"
            CheckUpdate["checkUpdate.ts"]:::update
            UpdateKey["updateKeyLocal.ts"]:::update
        end
    end

    UpdateServer["Update Server (CDN/API)"]:::external

    %% Relationships
    Host -->|load & init| Bootstrap
    Bootstrap -->|"initTheme()"| CdnInit
    Bootstrap -->|"initTheme()"| LoadCss
    Bootstrap -->|"initTheme()"| ApplyUi
    Bootstrap -->|"initTheme()"| ThemeFilters
    Bootstrap -->|"initTheme()"| Presets
    Bootstrap -->|"initTheme()"| Homepage

    Bootstrap -->|"loadConfig()"| CDNConfig
    Bootstrap --> CDNConfig
    Bootstrap --> ChampsBg
    Bootstrap --> DSDefaults
    Bootstrap --> UIFilters
    Bootstrap --> Icons
    Bootstrap --> CustomText

    Bootstrap --> Assets
    Bootstrap --> StylesComp
    Bootstrap --> StylesThemes

    Bootstrap --> PluginsDir
    PluginsDir --> SettingsStruct
    PluginsDir --> SettingsUI
    PluginsDir --> AboutUs
    PluginsDir --> PluginsSettings
    PluginsDir --> ThemeSettings

    Bootstrap --> Backup
    Bootstrap --> SetTime
    Bootstrap --> DataStore
    Bootstrap --> Log
    Bootstrap --> Utils
    Bootstrap --> SettingsUtils

    Bootstrap --> CheckUpdate
    CheckUpdate -->|fetch new version| UpdateServer
    CheckUpdate --> UpdateKey

    PluginsDir -.-> Backup
    PluginsDir -.-> DataStore
    PluginsDir -.-> CDNConfig
    PluginsDir -.-> ApplyUi

    %% Click Events
    click Bootstrap "https://github.com/elaina69/elaina-v4/blob/main/src/index.ts"
    click CdnInit "https://github.com/elaina69/elaina-v4/blob/main/src/src/theme/Cdninit.ts"
    click LoadCss "https://github.com/elaina69/elaina-v4/blob/main/src/src/theme/loadCss.ts"
    click ApplyUi "https://github.com/elaina69/elaina-v4/blob/main/src/src/theme/applyUi.ts"
    click ThemeFilters "https://github.com/elaina69/elaina-v4/blob/main/src/src/theme/filters.ts"
    click Presets "https://github.com/elaina69/elaina-v4/blob/main/src/src/theme/themePresetSettingsTab.ts"
    click Homepage "https://github.com/elaina69/elaina-v4/blob/main/src/src/theme/homepage.ts"

    click CDNConfig "https://github.com/elaina69/elaina-v4/blob/main/src/src/config/cdnServer.js"
    click ChampsBg "https://github.com/elaina69/elaina-v4/blob/main/src/src/config/champsBgList.js"
    click DSDefaults "https://github.com/elaina69/elaina-v4/blob/main/src/src/config/datastoreDefault.js"
    click UIFilters "https://github.com/elaina69/elaina-v4/blob/main/src/src/config/filters.js"
    click Icons "https://github.com/elaina69/elaina-v4/blob/main/src/src/config/icons.js"
    click CustomText "https://github.com/elaina69/elaina-v4/blob/main/src/src/config/customStatus.txt"

    click Assets "https://github.com/elaina69/elaina-v4/tree/main/src/src/assets/"
    click StylesComp "https://github.com/elaina69/elaina-v4/tree/main/src/src/assets/styles/components/"
    click StylesThemes "https://github.com/elaina69/elaina-v4/tree/main/src/src/assets/styles/themes/"

    click PluginsDir "https://github.com/elaina69/elaina-v4/tree/main/src/src/plugins/"
    click SettingsStruct "https://github.com/elaina69/elaina-v4/blob/main/src/src/plugins/settingsGroups/settingsStructure.ts"
    click SettingsUI "https://github.com/elaina69/elaina-v4/blob/main/src/src/plugins/settingsGroups/settingsUI.ts"
    click AboutUs "https://github.com/elaina69/elaina-v4/blob/main/src/src/plugins/settingsGroups/themeAboutUs.ts"
    click PluginsSettings "https://github.com/elaina69/elaina-v4/blob/main/src/src/plugins/settingsGroups/themePluginsSettings.ts"
    click ThemeSettings "https://github.com/elaina69/elaina-v4/blob/main/src/src/plugins/settingsGroups/themeSettings.ts"

    click Backup "https://github.com/elaina69/elaina-v4/blob/main/src/src/services/backupAndRestoreDatastore.ts"

    click SetTime "https://github.com/elaina69/elaina-v4/blob/main/src/src/utils/setTime.ts"
    click DataStore "https://github.com/elaina69/elaina-v4/blob/main/src/src/utils/themeDataStore.ts"
    click Log "https://github.com/elaina69/elaina-v4/blob/main/src/src/utils/themeLog.ts"
    click Utils "https://github.com/elaina69/elaina-v4/blob/main/src/src/utils/utils.ts"
    click SettingsUtils "https://github.com/elaina69/elaina-v4/blob/main/src/src/utils/settingsUtils.ts"

    click CheckUpdate "https://github.com/elaina69/elaina-v4/blob/main/src/src/updates/checkUpdate.ts"
    click UpdateKey "https://github.com/elaina69/elaina-v4/blob/main/src/src/updates/updateKeyLocal.ts"

    %% Styles
    classDef external fill:#cccccc,stroke:#888888,color:#000000;
    classDef bootstrap fill:#cce5ff,stroke:#3399ff,color:#000000;
    classDef config fill:#d4edda,stroke:#28a745,color:#000000;
    classDef assets fill:#e2d3f5,stroke:#8e44ad,color:#000000;
    classDef plugin fill:#ffe5b4,stroke:#ff8c00,color:#000000;
    classDef service fill:#d4edda,stroke:#28a745,color:#000000;
    classDef util fill:#d4edda,stroke:#28a745,color:#000000;
    classDef update fill:#f0f0f0,stroke:#666666,color:#000000;
```
