# ptlc8/anchovy architecture

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

- Interactive diagram: https://gitdiagram.com/ptlc8/anchovy
- Repository: https://github.com/ptlc8/anchovy

## Overview

##### Project Type Analysis
This is a frontend JavaScript library project, similar in concept to Vue.js or React, but lighter. The focus should be on showing how the library interacts with the DOM and manages dynamic UI updates.

##### Main Components

a. Core Library Components:
- DOM Manipulation Engine
- Template Engine
- Event Handling System
- Data Binding System
- State Management
- Transition Handler

b. Integration Layer:
- Browser DOM Interface
- Client Application Interface

**Top Layer (Client Application)**
**↕️ Integration Layer**
**Middle Layer (Anchovy.js Core)**
**↕️ DOM Interface**
**Bottom Layer (Browser DOM)**

##### Specific Component Details

Core Features (based on example files):
- Attribute Binding System (bind-attr-events.html)
- Data Model Management (model.html)
- Conditional Rendering (if-else.html)
- Loop Handling (loops.html)
- View Management (view.html)
- Transition Effects (transition.html)

##### Detailed Component Relationships

**[Client Application]**
- ↕️
**[Anchovy.js Integration Layer]**
- ↕️
**[Core Components]**
- [Template Engine] ←→ [Data Binding System]
- [Event Handler] ←→ [State Manager]
- [DOM Manipulator] ←→ [Transition Manager]
- ↕️
**[Browser DOM Interface]**
- ↕️
**[Browser DOM]**

##### Implementation Notes

- The lightweight nature of the library
- Client-side only architecture
- Direct DOM manipulation without virtual DOM
- Event-driven architecture
- Reactive data binding system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        App["Client Application"]
        click App "https://github.com/ptlc8/anchovy/blob/master/src/index.html"
        Style["Styling System"]
        click Style "https://github.com/ptlc8/anchovy/blob/master/src/style.css"
        TestSuite["Test Suite"]
        click TestSuite "https://github.com/ptlc8/anchovy/blob/master/src/test.html"
    end

    subgraph Core["Anchovy.js Core"]
        MainLib["Core Library"]
        click MainLib "https://github.com/ptlc8/anchovy/blob/master/src/anchovy.js"
        
        subgraph Engine["Template & DOM Engine"]
            TemplateEngine["Template Engine"]
            ConditionalRender["Conditional Renderer"]
            click ConditionalRender "https://github.com/ptlc8/anchovy/blob/master/src/examples/if-else.html"
            LoopHandler["Loop Handler"]
            click LoopHandler "https://github.com/ptlc8/anchovy/blob/master/src/examples/loops.html"
            ViewManager["View Manager"]
            click ViewManager "https://github.com/ptlc8/anchovy/blob/master/src/examples/view.html"
        end

        subgraph State["State & Events"]
            DataBinding["Data Binding System"]
            click DataBinding "https://github.com/ptlc8/anchovy/blob/master/src/examples/bind-update.html"
            EventSystem["Event System"]
            click EventSystem "https://github.com/ptlc8/anchovy/blob/master/src/examples/bind-attr-events.html"
            StateManager["State Manager"]
            click StateManager "https://github.com/ptlc8/anchovy/blob/master/src/examples/model.html"
        end

        TransitionMgr["Transition Manager"]
        click TransitionMgr "https://github.com/ptlc8/anchovy/blob/master/src/examples/transition.html"
    end

    subgraph Browser
        DOM["Browser DOM"]
        DOMInterface["DOM Interface"]
    end

    %% Example Implementation
    TodoExample["Todo App Example"]
    click TodoExample "https://github.com/ptlc8/anchovy/blob/master/src/examples/todo.html"

    %% Relationships
    App --> MainLib
    MainLib --> Engine
    MainLib --> State
    MainLib --> TransitionMgr
    
    Engine --> DOMInterface
    State --> DOMInterface
    TransitionMgr --> DOMInterface
    
    DOMInterface --> DOM
    
    %% State Management Flow
    DataBinding <--> StateManager
    EventSystem <--> StateManager
    
    %% Template Engine Flow
    TemplateEngine --> ConditionalRender
    TemplateEngine --> LoopHandler
    TemplateEngine --> ViewManager

    %% Styling
    Style -.-> DOM
    
    %% Testing
    TestSuite -.-> MainLib

    %% Example
    TodoExample -.-> MainLib

    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef interface fill:#4CAF50,stroke:#2E7D32,color:white
    classDef browser fill:#FFC107,stroke:#FFA000,color:black
    classDef example fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef test fill:#FF5722,stroke:#E64A19,color:white

    class MainLib,Engine,State,TransitionMgr core
    class DOMInterface interface
    class DOM browser
    class TodoExample example
    class TestSuite test
```
