# jorgebucaran/hyperapp architecture

> Architecture diagram of the GitHub repository jorgebucaran/hyperapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jorgebucaran/hyperapp
- Repository: https://github.com/jorgebucaran/hyperapp

## Overview

##### Main Components

a) Core Framework Layer:
- Virtual DOM Engine
- State Management System
- Action Handler
- Effect System
- Subscription System

b) Official Package Ecosystem:
- DOM Package
- SVG Package
- HTML Package
- Time Package
- Events Package

##### Key Architectural Elements

- State → View → Actions → State (cycle)
- Effects and Subscriptions as side-effect handlers

**Top Level:**
**┌─────────────────────────────────────────────┐**
- Client Browser                 │
- ┘

**Core Framework (Center):**
**┌─────────────────────────────────────────────┐**
- Hyperapp Core                   │
- ┌─────────┐    ┌─────────┐    ┌─────────┐  │
- State  │ -> │  View   │ -> │ Actions │  │
- ┘    └─────────┘    └─────────┘  │
- ↑                           │        │
- ┘        │
- ┘

**Side Systems (Connected to Core):**
**┌─────────────┐    ┌─────────────┐**
- Effects   │    │Subscriptions│
- ┘    └─────────────┘

##### Important Details

a) Core Framework Features:
- 1KB size indicator
- Virtual DOM optimization
- State management flow

b) Package Integration:
- How official packages connect to the core
- Extension points for custom effects/subscriptions

##### Notes for Implementation Details

- How `h()` and `text()` functions relate to the Virtual DOM
- Where state updates trigger re-renders
- Where side effects can occur

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser["Client Browser"]
        direction TB
        subgraph Core["Hyperapp Core (1KB)"]
            direction TB
            VirtualDOM["Virtual DOM Engine"]:::core
            State["State Management"]:::core
            View["View System"]:::core
            Actions["Action Handler"]:::core
            Dispatch["Dispatch System"]:::core
            
            State --> View
            View --> Actions
            Actions --> Dispatch
            Dispatch --> State
            VirtualDOM --> View
        end

        subgraph SideEffects["Side Systems"]
            direction TB
            Effects["Effect System"]:::side
            Subscriptions["Subscription System"]:::side
        end

        subgraph Packages["Official Package Ecosystem"]
            direction TB
            DOM["DOM Package"]:::package
            SVG["SVG Package"]:::package
            HTML["HTML Package"]:::package
            Time["Time Package"]:::package
            Events["Events Package"]:::package
        end

        Effects -.->|Side Effects| Dispatch
        Subscriptions -.->|Event Handling| Dispatch
        
        Packages -->|Extensions| Core
    end

    subgraph Legend["Legend"]
        L1[/"Core Components"/]:::core
        L2[/"Side Systems"/]:::side
        L3[/"Official Packages"/]:::package
        L4[/"→ Direct Flow"/]:::legend
        L5[/"-.-> Side Effects"/]:::legend
    end

    %% Click Events
    click VirtualDOM "https://github.com/jorgebucaran/hyperapp/blob/main/docs/api/h.md"
    click State "https://github.com/jorgebucaran/hyperapp/blob/main/docs/architecture/state.md"
    click View "https://github.com/jorgebucaran/hyperapp/blob/main/docs/architecture/views.md"
    click Actions "https://github.com/jorgebucaran/hyperapp/blob/main/docs/architecture/actions.md"
    click Effects "https://github.com/jorgebucaran/hyperapp/blob/main/docs/architecture/effects.md"
    click Subscriptions "https://github.com/jorgebucaran/hyperapp/blob/main/docs/architecture/subscriptions.md"
    click DOM "https://github.com/jorgebucaran/hyperapp/tree/main/packages/dom/"
    click SVG "https://github.com/jorgebucaran/hyperapp/tree/main/packages/svg/"
    click HTML "https://github.com/jorgebucaran/hyperapp/tree/main/packages/html/"
    click Time "https://github.com/jorgebucaran/hyperapp/tree/main/packages/time/"
    click Events "https://github.com/jorgebucaran/hyperapp/tree/main/packages/events/"
    click Core "https://github.com/jorgebucaran/hyperapp/blob/main/index.js"
    click Dispatch "https://github.com/jorgebucaran/hyperapp/blob/main/docs/architecture/dispatch.md"

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef side fill:#e67e22,stroke:#d35400,color:white
    classDef package fill:#2ecc71,stroke:#27ae60,color:white
    classDef legend fill:#95a5a6,stroke:#7f8c8d,color:white
```
