# givanz/vvvebjs architecture

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

- Interactive diagram: https://gitdiagram.com/givanz/vvvebjs
- Repository: https://github.com/givanz/vvvebjs

## Overview

##### Project Type and Purpose
- This is a JavaScript-based page builder library primarily focused on the front end.
- Its purpose is to allow non-technical users to design and modify web pages interactively.
- It is extensible and supports additional components, plugins, and even file management with optional backend support.

##### File Structure
- There are several top-level directories and files that indicate the architectural components:
- The root contains configuration files (Dockerfile, docker-compose.yml, package.json, gulpfile.js) for development and deployment.
- The demos in the “demo” folder give examples of pages (e.g., album, blog, carousel, landing) that the editor can work with.
- The “libs” directory is crucial; it contains subdirectories for:
– AOS (animation library)
– Codemirror (for live code editing)
– Builder components and plugins (e.g., builder.js, components-bootstrap5.js, various plugin files)
– Media and other helper libraries.
- Style assets reside in “css” and “scss” directories (plus fonts and images) and indicate the use of Bootstrap along with custom CSS/SCSS.
- PHP files (e.g., editor.php, save.php, upload.php) and Node.js script (save.js) indicate optional backend endpoints.

##### Key Components
a. Editor / UI Layer
- Editor Interface: Represented by “editor.html” and “editor.php”. This is the main entry point where users interact with the page builder.
- UI Components: The drag-and-drop interface, live code editor (with CodeMirror), undo/redo, and visual panels.

b. Builder Core / JavaScript Library
- Core Builder Engine: Indicated by “libs/builder/builder.js”, which orchestrates the page building, component insertion, and user interactions.
- Component Modules: Various components found in “libs/builder/components-*.js” (for Bootstrap 5, widgets, server components, etc.) that define available blocks, sections, and other elements.
- Plugin System: Plugins (e.g., plugin-ai-assistant.js, plugin-ckeditor.js, plugin-google-fonts.js, etc.) allow the system to be extended. Mark these as optional modules integrated into the core.
- Inputs and Undo Manager: Outline the “libs/builder/inputs.js” and “libs/builder/undo.js” (handling events and providing undo/redo functionality).

c. File and Page Management
- File Manager: Represented by “Vvveb.FileManager” functionalities (see in the example snippet) to manage and load pages.
- Save/Upload Handlers: Include “save.php”, “upload.php”, and “save.js” that allow saving/exporting pages.

d. External Libraries and Dependencies
- Integration with Bootstrap 5 and possibly CodeMirror for code editing.
- Other helper libraries such as Codemirror, Swiper, AOS (Animate on Scroll) that contribute to the user experience.

e. Build and Deployment Utilities
- The build process is managed by Gulp (gulpfile.js) and has tasks for compiling SCSS, generating HTML from templates (especially in demo/landing), and creating screenshots.
- Docker and Docker Compose configuration for local development and deployment.

##### Relationships and Data Flow
- Builder Core to component modules and plugins to show how the system dynamically loads behavior for each component.
- File Manager component and its interaction with the Builder Core (loading pages, managing assets).
- Build process as a separate, development-time utility that compiles SCSS into CSS and bundles assets.

##### Visualizing Patterns and Technologies
- If applicable, show an MVC/MVVM-style layering where:
- The “View” layer is the Editor UI (editor.html/php)
- The “Controller/Service” layer is the Builder Core managing interactions
- The “Model” layer is represented by saved templates or state management (managed via FileManager, undo manager, and backend saving features).
- Modularity and extensibility as key design principles, illustrating that new components or plugins can plug into the core without breaking the architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD

  %% Client-Side Layer
  subgraph "Client-Side"
    subgraph "Editor Interface"
      EHTML["Editor Interface (HTML)"]:::frontend
      EPHP["Editor Interface (PHP)"]:::frontend
    end
    subgraph "UI Components"
      UIC1["Editor CSS"]:::frontend
      UIC2["Editor Helpers CSS"]:::frontend
      UIC3["Demo Examples"]:::frontend
    end
    BC["Builder Core Engine"]:::core
    subgraph "Component Modules"
      CM_bs5["Components Bootstrap5"]:::component
      CM_bs4["Components Bootstrap4"]:::component
      CM_common["Components Common"]:::component
      CM_elements["Components Elements"]:::component
      CM_embeds["Components Embeds"]:::component
      CM_html["Components HTML"]:::component
      CM_server["Components Server"]:::component
      CM_widgets["Components Widgets"]:::component
    end
    subgraph "Plugin System"
      PluginAI["Plugin AI Assistant"]:::plugin
      PluginAOS["Plugin AOS"]:::plugin
      PluginBP["Plugin Bootstrap Colorpicker"]:::plugin
      PluginCK["Plugin CKEditor"]:::plugin
      PluginCM["Plugin CodeMirror"]:::plugin
      PluginGF["Plugin Google Fonts"]:::plugin
      PluginJSZip["Plugin JSZip"]:::plugin
      PluginMedia["Plugin Media"]:::plugin
      PluginTiny["Plugin TinyMCE"]:::plugin
    end
    subgraph "Auxiliary Modules"
      Inputs["Inputs"]:::aux
      Undo["Undo Manager"]:::aux
      FileManager["File Manager & Handlers"]:::aux
    end
  end

  %% External Dependencies Layer
  subgraph "External Dependencies"
    CD["CodeMirror Library"]:::external
    AOS_lib["AOS Library"]:::external
    MediaHelper["Media Helper"]:::external
  end

  %% Asset Repository
  subgraph "Asset Repository"
    Icons["Icon & Asset Repository"]:::external
    GoogleFonts["Google Fonts Config"]:::external
    LineAwesome["Line Awesome HTML"]:::external
  end

  %% Backend Integration
  subgraph "Backend Integration"
    SavePHP["Save Handler (PHP)"]:::backend
    UploadPHP["Upload Handler (PHP)"]:::backend
    SaveNode["Save Handler (Node)"]:::backend
  end

  %% Build & Deployment Tools
  subgraph "Build & Deployment Tools"
    Gulp["Gulp Build"]:::build
    Docker["Dockerfile"]:::build
    DockerCompose["Docker Compose"]:::build
    Package["Package Config"]:::build
  end

  %% Connections from Editor Interface to Builder Core
  EHTML -->|"triggers"| BC
  EPHP  -->|"triggers"| BC

  %% Connections from UI Components to Builder Core
  UIC1 -->|"styles"| BC
  UIC2 -->|"helpers"| BC
  UIC3 -->|"demos"| BC

  %% Builder Core to Component Modules
  BC --> CM_bs5
  BC --> CM_bs4
  BC --> CM_common
  BC --> CM_elements
  BC --> CM_embeds
  BC --> CM_html
  BC --> CM_server
  BC --> CM_widgets

  %% Builder Core to Plugin System
  BC --> PluginAI
  BC --> PluginAOS
  BC --> PluginBP
  BC --> PluginCK
  BC --> PluginCM
  BC --> PluginGF
  BC --> PluginJSZip
  BC --> PluginMedia
  BC --> PluginTiny

  %% Builder Core to Auxiliary Modules
  BC --> Inputs
  BC --> Undo
  BC --> FileManager

  %% File Manager to Backend Handlers
  FileManager --> SavePHP
  FileManager --> UploadPHP
  FileManager --> SaveNode

  %% Builder Core uses External Dependencies
  BC --> CD
  BC --> AOS_lib
  BC --> MediaHelper

  %% UI Components use Asset Repository
  UIC3 --> Icons

  %% Build & Deployment Tools integration (development-time)
  Gulp -->|"builds"| BC
  Docker --> Gulp
  DockerCompose --> Docker
  Package --> Gulp

  %% Click Events
  click EHTML "https://github.com/givanz/vvvebjs/blob/master/editor.html"
  click EPHP "https://github.com/givanz/vvvebjs/blob/master/editor.php"
  click UIC1 "https://github.com/givanz/vvvebjs/blob/master/css/editor.css"
  click UIC2 "https://github.com/givanz/vvvebjs/blob/master/css/vvvebjs-editor-helpers.css"
  click UIC3 "https://github.com/givanz/vvvebjs/tree/master/demo/"
  click BC "https://github.com/givanz/vvvebjs/blob/master/libs/builder/builder.js"
  click CM_bs5 "https://github.com/givanz/vvvebjs/blob/master/libs/builder/components-bootstrap5.js"
  click CM_bs4 "https://github.com/givanz/vvvebjs/blob/master/libs/builder/components-bootstrap4.js"
  click CM_common "https://github.com/givanz/vvvebjs/blob/master/libs/builder/components-common.js"
  click CM_elements "https://github.com/givanz/vvvebjs/blob/master/libs/builder/components-elements.js"
  click CM_embeds "https://github.com/givanz/vvvebjs/blob/master/libs/builder/components-embeds.js"
  click CM_html "https://github.com/givanz/vvvebjs/blob/master/libs/builder/components-html.js"
  click CM_server "https://github.com/givanz/vvvebjs/blob/master/libs/builder/components-server.js"
  click CM_widgets "https://github.com/givanz/vvvebjs/blob/master/libs/builder/components-widgets.js"
  click PluginAI "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-ai-assistant.js"
  click PluginAOS "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-aos.js"
  click PluginBP "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-bootstrap-colorpicker.js"
  click PluginCK "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-ckeditor.js"
  click PluginCM "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-codemirror.js"
  click PluginGF "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-google-fonts.js"
  click PluginJSZip "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-jszip.js"
  click PluginMedia "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-media.js"
  click PluginTiny "https://github.com/givanz/vvvebjs/blob/master/libs/builder/plugin-tinymce.js"
  click Inputs "https://github.com/givanz/vvvebjs/blob/master/libs/builder/inputs.js"
  click Undo "https://github.com/givanz/vvvebjs/blob/master/libs/builder/undo.js"
  click SavePHP "https://github.com/givanz/vvvebjs/blob/master/save.php"
  click UploadPHP "https://github.com/givanz/vvvebjs/blob/master/upload.php"
  click SaveNode "https://github.com/givanz/vvvebjs/blob/master/save.js"
  click CD "https://github.com/givanz/vvvebjs/tree/master/libs/codemirror/"
  click AOS_lib "https://github.com/givanz/vvvebjs/tree/master/libs/aos/"
  click MediaHelper "https://github.com/givanz/vvvebjs/tree/master/libs/media/"
  click Icons "https://github.com/givanz/vvvebjs/tree/master/resources/svg/icons/"
  click GoogleFonts "https://github.com/givanz/vvvebjs/blob/master/resources/google-fonts.json"
  click LineAwesome "https://github.com/givanz/vvvebjs/blob/master/resources/line-awesome.html"
  click Gulp "https://github.com/givanz/vvvebjs/blob/master/gulpfile.js"
  click Docker "https://github.com/givanz/vvvebjs/tree/master/Dockerfile"
  click DockerCompose "https://github.com/givanz/vvvebjs/blob/master/docker-compose.yml"
  click Package "https://github.com/givanz/vvvebjs/blob/master/package.json"

  %% Styles
  classDef frontend fill:#f9e79f,stroke:#333,stroke-width:2px;
  classDef core fill:#aed6f1,stroke:#333,stroke-width:2px;
  classDef component fill:#abebc6,stroke:#333,stroke-width:2px;
  classDef plugin fill:#f5b7b1,stroke:#333,stroke-width:2px;
  classDef aux fill:#f9e79f,stroke:#333,stroke-width:2px;
  classDef external fill:#d6eaf8,stroke:#333,stroke-width:2px;
  classDef backend fill:#f5cba7,stroke:#333,stroke-width:2px;
  classDef build fill:#d7bde2,stroke:#333,stroke-width:2px;
```
