How darkhanakh/pure-excel works
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.