# darkhanakh/pure-excel architecture

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

- Interactive diagram: https://gitdiagram.com/darkhanakh/pure-excel
- Repository: https://github.com/darkhanakh/pure-excel

## Overview

##### Main Components
- Components Layer:
– This includes all UI elements found in the “src/components” folder (e.g., Excel, Formula, Header, Table, Toolbar, Loader). These components form the view layer and are assembled to create the spreadsheet UI.
- Core Module:
– Under “src/core” you have modules like DOMListener, ExcelComponent, ExcelStateComponent, Observer, and StoreSubscriber. These implement essential design patterns (such as the observer pattern) and provide the backbone for component logic, event handling, and state synchronization.
- Routing and Pages:
– The “src/core/routes” directory (with ActiveRoute and Router) deals with client-side routing. Additionally, “src/pages” contains high-level page controllers (DashboardPage and ExcelPage) that determine which components get loaded based on the user’s navigation.
- State Management:
– The “src/store” folder indicates a centralized state management approach with Redux-like attributes. It contains actions, reducers, and a createStore file, supporting predictable state updates across the UI.
- Assets & Styling:
– The “src/assets” directory holds HTML templates (e.g., dashboard.html, excel.html) to bootstrap different sections of the UI, and “src/scss” provides stylesheet templates and variables that define the appearance and theming of components.
- Shared Utilities:
– “src/shared” contains utility modules (LocalStorageClient, dashboard functions) that likely support persistence (e.g., saving current state locally) and shared functionalities across components.

##### Relationships and Interactions
- Visual Flow:
– The application starts with high-level pages (DashboardPage and ExcelPage), which are responsible for assembling the overall layout by including components like Header, Toolbar, Table, etc.
- Component Interactions:
– UI components interact with each other through events (handled by the Observer design pattern) and utilize the central state via the Store (from the “src/store” folder). For example, a change in Table data may trigger updates in the Formula component.
- Communication Flow:
– Core modules such as ExcelComponent and DOMListener listen for and propagate DOM events, ensuring that user interactions are captured and relayed to the Observer, which in turn updates the store.
- Routing:
– The Router module coordinates URL changes with the pages that need to be rendered, dictating which high-level view (Dashboard/Excel) should be displayed.

##### Architectural Patterns and Design Principles
- Component-Based Architecture:
– The project relies on modular components that promote reusability and encapsulation.
- MVC/MV* Paradigm:
– Although it’s not a full backend MVC, a separation of concerns is maintained where views (UI components), business logic (core modules), and state (store operations) are clearly delineated.
- Observer Pattern:
– Used in modules like Observer and StoreSubscriber to synchronize the state and trigger component rerenders.
- Custom Routing:
– The inclusion of a Router and ActiveRoute indicates a lightweight client-side routing mechanism.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Components Layer
    subgraph "Components Layer"
        CE("Excel Component"):::components
        CF("Formula Component"):::components
        CH("Header Component"):::components
        CT("Table Component"):::components
        CTB("Toolbar Component"):::components
        CL("Loader Component"):::components
    end

    %% Core Module
    subgraph "Core Module"
        CDL("DOMListener"):::core
        CEC("ExcelComponent"):::core
        CES("ExcelStateComponent"):::core
        OBS("Observer"):::core
        SS("StoreSubscriber"):::core
    end

    %% Routing and Pages
    subgraph "Routing and Pages"
        RT("Router"):::coreRoutes
        AR("ActiveRoute"):::coreRoutes
        DP("Dashboard Page"):::pages
        EP("Excel Page"):::pages
    end

    %% State Management
    subgraph "State Management"
        ACT("Actions"):::state
        SC("Store Creation"):::state
        RED("Reducers"):::state
    end

    %% Assets & Styling
    subgraph "Assets & Styling"
        ATA("HTML Templates"):::assets
        ATS("SCSS Styles"):::assets
    end

    %% Shared Utilities
    subgraph "Shared Utilities"
        LS("LocalStorageClient"):::shared
        DF("Dashboard Functions"):::shared
    end

    %% Relationships

    %% Routing directs to Pages
    RT -->|"routesTo"| DP
    RT -->|"routesTo"| EP
    AR -->|"supports"| RT

    %% Pages load Components
    DP -->|"loads"| CH
    DP -->|"loads"| CTB
    DP -->|"loads"| CL
    EP -->|"loads"| CE
    EP -->|"loads"| CF
    EP -->|"loads"| CT

    %% Components interact with Core Modules
    CE -->|"initializes"| CEC
    CE -->|"triggers"| CDL
    CF -->|"updates"| OBS
    CT -->|"syncs"| CES

    %% Core modules coordinate via Observer and StoreSubscriber
    CEC -->|"binds"| SS
    CES -->|"binds"| SS
    OBS -->|"notifies"| SS

    %% StoreSubscriber interacts with State Management
    SS -->|"triggers"| RED
    ACT -->|"dispatches"| SS
    SC -->|"maintains"| SS

    %% Assets & Styling support Pages and Components
    ATA -->|"templates"| DP
    ATA -->|"templates"| EP
    ATS -->|"styles"| CH
    ATS -->|"styles"| CE
    ATS -->|"styles"| CT
    ATS -->|"styles"| CF
    ATS -->|"styles"| CTB
    ATS -->|"styles"| CL

    %% Shared Utilities support State and Pages
    LS -->|"supports"| SC
    DF -->|"assists"| DP

    %% Click Events for Components Layer
    click CE "https://github.com/darkhanakh/pure-excel/blob/main/src/components/excel/Excel.js"
    click CF "https://github.com/darkhanakh/pure-excel/blob/main/src/components/formula/Formula.js"
    click CH "https://github.com/darkhanakh/pure-excel/blob/main/src/components/header/Header.js"
    click CT "https://github.com/darkhanakh/pure-excel/blob/main/src/components/table/Table.js"
    click CTB "https://github.com/darkhanakh/pure-excel/blob/main/src/components/toolbar/Toolbar.js"
    click CL "https://github.com/darkhanakh/pure-excel/blob/main/src/components/Loader.js"

    %% Click Events for Core Module
    click CDL "https://github.com/darkhanakh/pure-excel/blob/main/src/core/DOMListener.js"
    click CEC "https://github.com/darkhanakh/pure-excel/blob/main/src/core/ExcelComponent.js"
    click CES "https://github.com/darkhanakh/pure-excel/blob/main/src/core/ExcelStateComponent.js"
    click OBS "https://github.com/darkhanakh/pure-excel/blob/main/src/core/Observer.js"
    click SS "https://github.com/darkhanakh/pure-excel/blob/main/src/core/StoreSubscriber.js"

    %% Click Events for Routing and Pages
    click RT "https://github.com/darkhanakh/pure-excel/blob/main/src/core/routes/Router.js"
    click AR "https://github.com/darkhanakh/pure-excel/blob/main/src/core/routes/ActiveRoute.js"
    click DP "https://github.com/darkhanakh/pure-excel/blob/main/src/pages/DashboardPage.js"
    click EP "https://github.com/darkhanakh/pure-excel/blob/main/src/pages/ExcelPage.js"

    %% Click Events for State Management
    click ACT "https://github.com/darkhanakh/pure-excel/blob/main/src/store/actions/actions.js"
    click SC "https://github.com/darkhanakh/pure-excel/blob/main/src/store/createStore.js"
    click RED "https://github.com/darkhanakh/pure-excel/blob/main/src/store/reducers/rootReducer.reducer.js"

    %% Click Events for Assets & Styling
    click ATA "https://github.com/darkhanakh/pure-excel/blob/main/src/assets/dashboard.html"
    click ATS "https://github.com/darkhanakh/pure-excel/tree/main/src/scss"

    %% Click Events for Shared Utilities
    click LS "https://github.com/darkhanakh/pure-excel/blob/main/src/shared/LocalStorageClient.js"
    click DF "https://github.com/darkhanakh/pure-excel/blob/main/src/shared/dashboard.functions.js"

    %% Styles
    classDef components fill:#e1f5fe,stroke:#0277bd,stroke-width:2px;
    classDef core fill:#fce4ec,stroke:#c2185b,stroke-width:2px;
    classDef coreRoutes fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px;
    classDef pages fill:#fff9c4,stroke:#fbc02d,stroke-width:2px;
    classDef state fill:#e8f5e9,stroke:#388e3c,stroke-width:2px;
    classDef assets fill:#ede7f6,stroke:#5e35b1,stroke-width:2px;
    classDef shared fill:#fff3e0,stroke:#fb8c00,stroke-width:2px;
```
