# mnater/hyphenopoly architecture

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

- Interactive diagram: https://gitdiagram.com/mnater/hyphenopoly
- Repository: https://github.com/mnater/hyphenopoly

## Overview

##### Main Components

a. Client-Side Components:
- Hyphenopoly_Loader.js (Feature Detection Layer)
- Hyphenopoly.js (Core Processing Layer)
- WebAssembly Modules (Language-specific Pattern Processing)
- DOM Interface

b. Node.js Components:
- Hyphenopoly Module Interface
- WebAssembly Integration
- Pattern Loading System

**┌─ Client Applications ─────────────────────┐    ┌─ Node.js Applications ──┐**

- ┌─ HTML/CSS Layer ─┐                    │    │  ┌─ Module Interface ─┐ │
- CSS Hyphenation  │                    │    │  │  hyphenopoly.      │ │
- Support      │                    │    │  │    module.js       │ │
- ┘                    │    │  └──────────────────┘ │
- ↓                             │    │           ↓           │
- ┌─ Loader Layer ──┐                    │    │  ┌─ Core Engine ────┐ │
- Feature Detection│                    │    │  │   Pattern        │ │
- Resource Loading│                    │    │  │   Processing     │ │
- ┘                    │    │  └──────────────────┘ │
- ↓                             │    │           ↓           │
- ┌─ Core Layer ────┐     ┌─ WASM ────┐  │    │  ┌─ WASM Modules ──┐ │
- DOM Processing  │←───→│ Language   │  │    │  │   Language      │ │
- Event Handling  │     │ Patterns   │  │    │  │   Patterns      │ │
- ┘     └──────────┘  │    │  └──────────────────┘ │
- ┘    └─────────────────────┘

##### Component Relationships

- Data flow between components
- Dependencies
- Loading sequences
- Feature detection paths

##### Key Elements to Highlight

a. Client-Side Flow:
- Feature detection process
- Conditional loading of resources
- DOM manipulation
- WebAssembly module integration

b. Node.js Flow:
- Module initialization
- Pattern loading
- Text processing pipeline

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Applications"]
        direction TB
        subgraph HTML["HTML/CSS Layer"]
            CSS["CSS Hyphenation Support"]
        end

        subgraph Loader["Feature Detection Layer"]
            FD["Feature Detection"]:::loader
            RL["Resource Loading"]:::loader
        end

        subgraph Core["Core Processing Layer"]
            DP["DOM Processing"]:::core
            EH["Event Handling"]:::core
            HE["Hyphenation Engine"]:::core
        end

        subgraph WASM["WebAssembly Layer"]
            LP["Language Patterns"]:::wasm
        end
    end

    subgraph Node["Node.js Applications"]
        direction TB
        subgraph Module["Module Interface"]
            MI["Module Implementation"]:::node
        end

        subgraph Engine["Core Engine"]
            PP["Pattern Processing"]:::node
        end

        subgraph WASMNode["WASM Modules"]
            LPN["Language Patterns"]:::wasm
        end
    end

    %% Relationships
    CSS --> FD
    FD --> RL
    RL --> DP
    DP <--> HE
    HE <--> LP
    EH --> DP

    MI --> PP
    PP <--> LPN

    %% Click Events
    click FD "https://github.com/mnater/Hyphenopoly/blob/master/Hyphenopoly_Loader.js"
    click DP "https://github.com/mnater/Hyphenopoly/blob/master/Hyphenopoly.js"
    click MI "https://github.com/mnater/Hyphenopoly/blob/master/hyphenopoly.module.js"
    click LP "https://github.com/mnater/Hyphenopoly/tree/master/patterns/"
    click HE "https://github.com/mnater/Hyphenopoly/blob/master/src/hyphenEngine.ts"
    click LPN "https://github.com/mnater/Hyphenopoly/tree/master/tools/modules/"
    click PP "https://github.com/mnater/Hyphenopoly/blob/master/tools/createWasmData.js"

    %% Styling
    classDef loader fill:#6495ED,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px
    classDef wasm fill:#FFD700,stroke:#333,stroke-width:2px
    classDef node fill:#90EE90,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Client Components"]:::loader
        L2["Core Components"]:::core
        L3["WebAssembly Modules"]:::wasm
        L4["Node.js Components"]:::node
    end
```
