# mauriciozegarra/arbol-b-web architecture

> Architecture diagram of the GitHub repository mauriciozegarra/arbol-b-web, 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/mauriciozegarra/arbol-b-web
- Repository: https://github.com/mauriciozegarra/arbol-b-web

## Overview

- Frontend/UI Layer:
- index.html – the primary HTML page
- styles.css – styling for the UI
- logica.js – JavaScript code managing the interaction between the UI and the WebAssembly module
- WebAssembly Module:
- arbol.js and arbol.wasm – the compiled output of the C++ source; these expose functions (_create_tree, _Insert, _delete_tree, _to_dot, _Print) for tree manipulation.
- C++ Core Logic:
- Files in src (BTree.h, Node.h, tree.cpp, main.cpp) – these files implement the actual tree data structure and its operations.
- Build & Deployment Tools:
- README instructions indicating the use of Emscripten (emcc) to compile C++ code to WASM and the usage of emrun to set up a local server.

##### Relationships and interactions between the components
- The UI layer (HTML/JS/CSS) acts as the front door for user interaction. It sends requests (e.g., to create, insert, delete tree elements) triggered by user actions.
- Optionally, include a local development server node (using emrun) that serves the HTML/JS/CSS and WASM content to the browser.

##### Architectural patterns and design principles
- Separation of concerns: The UI layer is clearly separated from the business logic, which is implemented in C++ and compiled into WebAssembly.
- Layered architecture: Presentation layer (front end) interacts via JavaScript API with a computation layer (WASM module) that wraps the core logic.

##### Relevant technologies and tools
- WebAssembly (arbol.wasm)
- Emscripten (for compilation using emcc)
- HTML/CSS/JavaScript for the front end (index.html, styles.css, logica.js)
- C++ for the core tree logic

##### Final assembly
- At the center, illustrate the WASM module that encapsulates the core logic.
- At the top (or side), indicate the UI layer with its HTML, CSS, and JavaScript that interacts with the user.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        A1["index.html"]
        A2["styles.css"]
        A3["logica.js"]
    end

    %% WebAssembly Module
    subgraph "WebAssembly Module"
        B1["arbol.js"]
        B2["arbol.wasm"]
    end

    %% C++ Core Logic
    subgraph "C++ Core Logic"
        C1["BTree.h"]
        C2["Node.h"]
        C3["tree.cpp"]
        C4["main.cpp"]
    end

    %% Build & Deployment Tools
    subgraph "Build & Deployment Tools"
        D1["Emscripten (emcc)"]
        D2["Local Server (emrun)"]
        D3["README.md"]
        D4["instrucciones.txt"]
    end

    %% Interactions and Data Flow
    A3 -->|"calls_API"| B1
    B1 -->|"invokes_tree_ops"| C3

    %% Build process: Compiling C++ to WebAssembly
    D1 -->|"compiles_to"| B1
    D1 -->|"compiles_to"| B2

    %% Local server serves the Frontend/UI
    D2 --> A1

    %% Styling Classes
    class A1,A2,A3 frontend;
    class B1,B2 wasm;
    class C1,C2,C3,C4 cpp;
    class D1,D2,D3,D4 build;

    %% Click Events for Frontend/UI Layer
    click A1 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/index.html"
    click A2 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/styles.css"
    click A3 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/logica.js"

    %% Click Events for WebAssembly Module
    click B1 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/arbol.js"
    click B2 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/arbol.wasm"

    %% Click Events for C++ Core Logic
    click C1 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/src/BTree.h"
    click C2 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/src/Node.h"
    click C3 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/src/tree.cpp"
    click C4 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/src/main.cpp"

    %% Click Events for Build & Deployment Tools
    click D1 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/README.md"
    click D2 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/instrucciones.txt"
    click D3 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/README.md"
    click D4 "https://github.com/mauriciozegarra/arbol-b-web/blob/main/instrucciones.txt"

    %% Class Definitions with Colors
    classDef frontend fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef wasm fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef cpp fill:#cce5ff,stroke:#003399,stroke-width:2px;
    classDef build fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
```
