How remeic/aleli works
Main Components
• Components Module – Located in the src/components folder (e.g., aleliComponent.ts, classState.ts). This module defines the UI elements and their state.
• Tree Creation – The src/createElement module (with createElement.ts) is key in constructing virtual nodes from component descriptions.
• Differencing Engine – The src/differ module (aleliDiffer.ts) provides functionality to compare virtual DOM trees. This is essentially the diffing algorithm that identifies what updates are necessary.
• Rendering Engine – The src/renderer module (e.g., aleliRenderer.ts) is responsible for rendering the virtual DOM to the actual DOM.
• Renderer Utilities – The src/rendererUtilities module offers helper methods to assist rendering tasks.
• Types Definitions – The src/types folder defines interfaces for components, virtual nodes, differ, renderer, and utilities, ensuring strong typing across modules.
• Utility Functions – The src/utils folder includes helper scripts (like domTreeSerializer.ts and detectNodeUtils.ts) that support auxiliary operations.
• Testing Infrastructure – While not part of the runtime architecture, the test directories (unit, integration, e2e, and mocks) indicate a well-structured, TDD-based approach with Jest, Cypress, and Stryker for mutation testing.
• CI/CD Pipeline – Files like .travis.yml and configuration files for Stryker show that automated testing and continuous integration are integral to the development process.
Relationships and Interactions
• A UI component (from src/components) uses createElement to be transformed into a virtual DOM node.
• The differ module receives the new virtual DOM tree and the previous one (if any) and calculates the minimal set of changes.
• The renderer module then applies these changes to the real DOM.
• Renderer utilities and utility functions support and extend the behavior of the renderer and other components.
• All modules communicate according to the type contracts defined in the types folder, ensuring consistency and predictability.
• Testing modules verify each of these interactions at various levels (unit, integration, and e2e).
Architectural Patterns and Design Principles
• Component-Based Architecture – The separation into distinct folders (components, createElement, renderer, etc.) shows a clear modular structure.
• Virtual DOM Pattern – The interplay between createElement, differ, and renderer is reminiscent of frameworks like React, where a virtual representation of the DOM is maintained and updated.
• Separation of Concerns – Each module (creation, differencing, rendering) has a specific responsibility.
• TDD / Testing Focus – The existence of extensive test directories underlines a strong commitment to testing-driven development.
• Type Safety – Extensive TypeScript typings in the types folder enforce rigorous interfaces between components.