# dream-num/luckysheet architecture

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

- Interactive diagram: https://gitdiagram.com/dream-num/luckysheet
- Repository: https://github.com/dream-num/luckysheet

## Overview

##### Main Components
- Frontend/User Interface: The UI includes the HTML container (src/index.html) and associated JavaScript (src/index.js) that initializes and renders the spreadsheet. The UI displays the grid, menus, toolbars, cell formatting controls, and plugins.
- Data Layer: Include the “src/data” folder and demo data in “src/demoData” to represent how sheet data, chart configurations, comments, formulas, etc. are structured and stored. This layer is responsible for managing state changes.
- Global and Utility Modules: The “src/global” and “src/utils” directories contain utility functions (such as drawing, API calls, configuration, event binding, etc.) that support interactions between components.
- Plugins and Extensions: The “src/plugins” and “src/expendPlugins” directories add extra functionality for charts, Excel import/export, print, etc.
- Configuration and Localization: The “src/config.js” and “src/locale” provide customization, internationalization, and initial settings.
- Store/State Management: The “src/store” (index.js) acts as a central state or data store, which several modules depend on for session information and data consistency.

##### Relationships and Interactions
- The UI layer interacts directly with the business logic controllers; for example, user events such as cell selection or formatting trigger controller functions.
- Controllers communicate with the data layer to update cell values and with the store to maintain overall application state.
- Utility modules (in “global” and “utils”) are invoked by controllers and the store to perform common functions like rendering, math calculations, and event processing.
- Plugin components extend core functionalities. For instance, the chart plugin in “src/expendPlugins/chart” integrates with sheet data and the UI to render dynamic charts.
- Configuration and localization files are injected into various layers (controllers, UI, and plugins), ensuring adaptability and international support.

##### Incorporate Relevant Technologies and Frameworks
- JavaScript and jQuery (as implied by the demo code snippet using $() in the README).
- CSS for styling, with custom stylesheet modules in “src/css”.
- Build tools like gulp (gulpfile.js) and configuration files (package.json, commitlint.config.js) indicate a Node.js-based build environment.
- Integration with third-party dependency management (CDN links for plugins in the usage example) should be noted.

## Diagram (Mermaid)

```mermaid
graph TD
    %% UI Layer
    subgraph "UI Layer"
        UI_indexHTML["index.html"]:::ui
        UI_indexJS["index.js"]:::ui
    end

    %% Controllers
    subgraph "Business Logic / Controllers"
        CONTROLLER["Business Logic/Controllers"]:::controllers
    end

    %% Data & State
    subgraph "Data & State Management"
        DATA["Data Layer"]:::data
        DEMODATA["Demo Data"]:::data
        STORE["Store/State Management"]:::store
    end

    %% Global & Utility Modules
    subgraph "Global & Utility Modules"
        GLOBAL["Global Modules"]:::util
        UTILS["Utility Modules"]:::util
    end

    %% Plugins & Extensions
    subgraph "Plugins / Extensions"
        PLUGINS["Plugins"]:::plugins
        EXTENSIONS["Extensions"]:::plugins
    end

    %% Configuration & Localization
    subgraph "Configuration & Localization"
        CONFIG["Configuration"]:::config
        LOCALE["Localization"]:::config
    end

    %% Connections
    UI_indexHTML -->|"triggers"| CONTROLLER
    UI_indexJS   -->|"initializes"| CONTROLLER

    CONTROLLER -->|"updates"| DATA
    CONTROLLER -->|"updates"| DEMODATA
    CONTROLLER -->|"updates_state"| STORE
    CONTROLLER -->|"calls"| GLOBAL
    CONTROLLER -->|"calls"| UTILS

    PLUGINS    -->|"enhances"| CONTROLLER
    EXTENSIONS -->|"extends"| CONTROLLER

    CONFIG -->|"injects"| CONTROLLER
    LOCALE -->|"injects"| CONTROLLER

    CONFIG -->|"configures"| UI_indexHTML
    CONFIG -->|"configures"| UI_indexJS
    LOCALE -->|"localizes"| UI_indexHTML
    LOCALE -->|"localizes"| UI_indexJS

    PLUGINS    -->|"renders"| UI_indexJS
    EXTENSIONS -->|"renders"| UI_indexJS

    %% Styles
    classDef ui fill:#F4A460,stroke:#333,stroke-width:2px;
    classDef controllers fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef data fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef util fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef plugins fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef store fill:#FFA07A,stroke:#333,stroke-width:2px;

    %% Click Events
    click UI_indexHTML "https://github.com/dream-num/luckysheet/blob/master/src/index.html"
    click UI_indexJS "https://github.com/dream-num/luckysheet/blob/master/src/index.js"
    click CONTROLLER "https://github.com/dream-num/luckysheet/tree/master/src/controllers"
    click DATA "https://github.com/dream-num/luckysheet/tree/master/src/data"
    click DEMODATA "https://github.com/dream-num/luckysheet/tree/master/src/demoData"
    click GLOBAL "https://github.com/dream-num/luckysheet/tree/master/src/global"
    click UTILS "https://github.com/dream-num/luckysheet/tree/master/src/utils"
    click PLUGINS "https://github.com/dream-num/luckysheet/tree/master/src/plugins"
    click EXTENSIONS "https://github.com/dream-num/luckysheet/tree/master/src/expendPlugins"
    click CONFIG "https://github.com/dream-num/luckysheet/blob/master/src/config.js"
    click LOCALE "https://github.com/dream-num/luckysheet/tree/master/src/locale"
    click STORE "https://github.com/dream-num/luckysheet/blob/master/src/store/index.js"
```
