# hbroek/reken architecture

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

- Interactive diagram: https://gitdiagram.com/hbroek/reken
- Repository: https://github.com/hbroek/reken

## Overview

##### Main Components

a) Core Engine Components:
- Setup Controller
- Runtime Controller
- Event Management System
- DOM Update Engine
- REST Service Handler
- Component System
- Routing System

b) Integration Layer:
- HTML Attribute Parser
- Template Engine
- Data Binding System

c) External Interfaces:
- REST API Integration
- File System Integration
- Browser DOM Interface

**┌─────────────────────────────────────────────────────────┐**
- HTML Application Layer                  │
- (Custom attributes, Components, Templates, Includes)    │
- ┤
- Reken Core Engine                      │
- ┬──────────────────────┬──────────────────┤
- Setup         │Runtime               │Event              │
- Controller    │Controller            │Management         │
- ┴──────────────────────┴──────────────────┤
- Integration Layer                      │
- ┬──────────────────────┬──────────────────┤
- Attribute     │Template              │Data              │
- Parser        │Engine                │Binding           │
- ┴──────────────────────┴──────────────────┤
- External Interfaces                    │
- (REST API, File System, Browser DOM)                │
- ┘

##### Key Relationships

a) Data Flow:
- HTML Attributes → Attribute Parser → Setup/Runtime Controllers
- User Events → Event Management → Runtime Controller
- REST Calls → REST Service Handler → Data Binding System
- Component Templates → Template Engine → DOM Update Engine

b) Control Flow:
- Setup Controller → Event Management (one-time setup)
- Runtime Controller → DOM Update Engine (continuous updates)
- Component System → Template Engine (component rendering)

##### Implementation Details

- Single DOM tree architecture
- Direct DOM manipulation without Virtual DOM
- Event-driven update system
- Component reusability
- HTML-first approach

Remember to include notes about the ES6 dependency and browser compatibility constraints, as these are important architectural considerations.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph HTML["HTML Application Layer"]
        direction TB
        ATTR["Custom Attributes"]
        COMP["Components"]:::comp
        TEMP["Templates"]:::temp
        INCL["Includes"]
    end

    subgraph CORE["Reken Core Engine"]
        direction TB
        SETUP["Setup Controller"]
        RUNTIME["Runtime Controller"]:::core
        EVENT["Event Management"]
        DOM["DOM Update Engine"]
        REST["REST Service Handler"]:::rest
        COMPSYS["Component System"]:::comp
        ROUTE["Routing System"]:::route
    end

    subgraph INTEG["Integration Layer"]
        direction TB
        PARSER["Attribute Parser"]
        TEMPENG["Template Engine"]:::temp
        BINDING["Data Binding System"]:::bind
    end

    subgraph EXT["External Interfaces"]
        direction TB
        RESTAPI["REST API"]:::rest
        FS["File System"]:::fs
        BROWSER["Browser DOM"]
    end

    %% Relationships
    ATTR --> PARSER
    PARSER --> SETUP
    PARSER --> RUNTIME
    EVENT --> RUNTIME
    RUNTIME --> DOM
    REST --> BINDING
    COMPSYS --> TEMPENG
    TEMPENG --> DOM
    ROUTE --> BROWSER
    RESTAPI --> REST
    FS --> COMPSYS

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef comp fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef rest fill:#FF9800,stroke:#F57C00,color:white
    classDef temp fill:#4CAF50,stroke:#388E3C,color:white
    classDef bind fill:#E91E63,stroke:#C2185B,color:white
    classDef route fill:#607D8B,stroke:#455A64,color:white
    classDef fs fill:#795548,stroke:#5D4037,color:white

    %% Click Events
    click RUNTIME "https://github.com/hbroek/reken/blob/main/src/reken.js"
    click COMPSYS "https://github.com/hbroek/reken/blob/main/demo/components.html"
    click ROUTE "https://github.com/hbroek/reken/blob/main/demo/spa-with-routing.html"
    click REST "https://github.com/hbroek/reken/blob/main/demo/populate-table-from-rest.html"
    click TEMPENG "https://github.com/hbroek/reken/blob/main/demo/includes/demo-lib.html"
    click BINDING "https://github.com/hbroek/reken/blob/main/demo/component-bindable-attributes.html"
    click FS "https://github.com/hbroek/reken/blob/main/demo/file-open.html"
    click RESTAPI "https://github.com/hbroek/reken/tree/main/integrations/pwa-rest/"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Component System"]:::comp
        L3["REST Services"]:::rest
        L4["Templates"]:::temp
        L5["Data Binding"]:::bind
        L6["Routing"]:::route
        L7["File System"]:::fs
    end
```
