# tarekraafat/eleva architecture

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

- Interactive diagram: https://gitdiagram.com/tarekraafat/eleva
- Repository: https://github.com/tarekraafat/eleva

## Overview

##### Main Components
- Core Library (Eleva Core): Represented by files like src/core/Eleva.js and its TypeScript declarations in types/core/Eleva.d.ts. This is the heart of the framework.
- Modules: These include specialized functionalities to support the framework’s features:
- Emitter (src/modules/Emitter.js / types/modules/Emitter.d.ts): Provides event handling and inter-component communication.
- Renderer (src/modules/Renderer.js / types/modules/Renderer.d.ts): Handles the high-performance DOM diffing and patching.
- Signal (src/modules/Signal.js / types/modules/Signal.d.ts): Implements the reactive data holder that supports signal-based reactivity.
- TemplateEngine (src/modules/TemplateEngine.js / types/modules/TemplateEngine.d.ts): Manages template parsing and safe expression evaluations.
- Build & Distribution System: Indicate build configurations and outputs:
- Configuration files like .babelrc, eslint.config.js, rollup.config.js, and tsconfig.json.
- The dist folder contains the final UMD and ES module builds along with their source maps.
- Documentation & Examples:
- The docs folder (with assets like docs/imgs and docs/index.md) helps in visualizing the library’s API and usage.
- The examples folder provides usage examples (e.g., counter, custom plugin, todo-app) that show how the components integrate in practice.
- Testing Infrastructure: The test folder using Jest (test/ElevaCore.test.js, etc.) ensures reliability and correctness.
- Development Tools & Type Definitions:
- Configuration for development (Jest, Babel, Prettier, ESLint).
- A dedicated types folder for TS support to improve developer experience.

##### Their Relationships and Interactions
- Eleva Core acts as the orchestrator that brings together all modules. It provides the public API (such as app.component and app.mount) which internally leverages:
- Signal for state management and reactivity.
- Renderer for efficient DOM updates.
- Emitter for event handling between components.
- TemplateEngine for dynamic HTML template interpolation.
- The build system (using Rollup for bundling) takes the source in the src folder and compiles it along with type definitions which are then output in the dist and types directories.
- Testing is connected to each module to ensure every unit (core and modules) behaves as expected.
- The documentation and examples serve as an external guide, showing how the core and modules are integrated in real-world applications.

##### Architectural Patterns and Design Principles
- Modular Architecture: Each module (Emitter, Renderer, Signal, TemplateEngine) is a separate component that can be reused or replaced by plugins.
- Unopinionated & Flexible Design: Eleva does not enforce a strict structure on applications. Instead, it gives developers free rein to compose components.
- Minimalism and Performance Focus: The design strictly uses vanilla JavaScript with no external dependencies, keeping the footprint extremely low (around ~4 KB minified) while ensuring performance (efficient reactivity and DOM diffing).
- Separation of Concerns: Building different roles (state management, event handling, rendering, templating) into discrete subcomponents facilitates clear responsibilities and easier maintenance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Runtime Architecture
    subgraph "Runtime Architecture"
        User["User Code (interaction)"]:::runtime
        Core["Eleva Core"]:::runtime
        Emitter["Emitter Module"]:::runtime
        Renderer["Renderer Module"]:::runtime
        Signal["Signal Module"]:::runtime
        TemplateEngine["TemplateEngine Module"]:::runtime
    end

    %% Development and Build
    subgraph "Development & Build"
        Build["Build & Distribution System"]:::build
        Testing["Testing Infrastructure"]:::external
        Docs["Documentation"]:::external
        Examples["Examples"]:::external
    end

    %% Connections within Runtime Architecture
    User -->|"registers/mounts"| Core
    Core -->|"emits-event"| Emitter
    Core -->|"updates-DOM"| Renderer
    Core -->|"reactivity"| Signal
    Core -->|"compiles-templates"| TemplateEngine

    %% Connections between Development & Build and Runtime
    Build -->|"packages"| Core
    Testing -->|"tests"| Core
    Testing -->|"tests"| Emitter
    Testing -->|"tests"| Renderer
    Testing -->|"tests"| Signal
    Testing -->|"tests"| TemplateEngine
    Docs -->|"guides-usage"| User
    Examples -->|"demonstrates-usage"| User

    %% Styling
    classDef runtime fill:#D0E6A5,stroke:#5B8930,stroke-width:2px;
    classDef build fill:#F1C27D,stroke:#B45309,stroke-width:2px;
    classDef external fill:#AEDFF7,stroke:#2F77BA,stroke-width:2px;

    %% Click Events
    click Core "https://github.com/tarekraafat/eleva/blob/master/src/core/Eleva.js"
    click Emitter "https://github.com/tarekraafat/eleva/blob/master/src/modules/Emitter.js"
    click Renderer "https://github.com/tarekraafat/eleva/blob/master/src/modules/Renderer.js"
    click Signal "https://github.com/tarekraafat/eleva/blob/master/src/modules/Signal.js"
    click TemplateEngine "https://github.com/tarekraafat/eleva/blob/master/src/modules/TemplateEngine.js"
    click Build "https://github.com/tarekraafat/eleva/blob/master/rollup.config.js"
    click Docs "https://github.com/tarekraafat/eleva/blob/master/docs/index.md"
    click Examples "https://github.com/tarekraafat/eleva/tree/master/examples"
    click Testing "https://github.com/tarekraafat/eleva/blob/master/test/ElevaCore.test.js"
```
