# vform666/variant-form3-vite architecture

> Architecture diagram of the GitHub repository vform666/variant-form3-vite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vform666/variant-form3-vite
- Repository: https://github.com/vform666/variant-form3-vite

## Overview

##### Project’s Main Purpose and Type
- The README clearly states it is “Variant Form 3 For Vue 3.x” – a low-code form designer that supports both form design (designer component) and form rendering (render component).
- The project is a front-end focused, Vue 3 application built with Vite, intended to be integrated into Vue 3 projects via component registration.

##### Break Down the Core Components
a. Frontend Shell & Entry:
– index.html and main.js form the entry point.
– Vite configuration files (vite.config.js, vite-lib.config.js, vite-lib-render.config.js) define build pipelines for different outputs.
b. Form Designer Module:
– Located in src/components/form-designer.
– Contains UI parts for drag-and-drop design, component panels, toolbars, and a setting panel.
– Includes many submodules (e.g., code-editor, widget-panel, property-editor with its many specialized editors).
– Extension support provided in src/extension for loading and integrating extra form components.
c. Form Renderer Module:
– Located in src/components/form-render.
– Responsible for rendering the designed forms based on a JSON schema and handling interaction/validation.
d. Supporting Utilities:
– src/utils contains helpers for generating code (vue2js-generator.js, vue3js-generator.js, sfc-generator.js, code-generator.js), directives, event bus, internationalization (i18n.js, smart-vue-i18n), and configuration.
– Libraries like “vuedraggable” in the lib folder facilitate drag-and-drop functionality.
e. Assets and Styles:
– Global styles in src/styles (global.scss, index.scss) ensure a consistent UI.

##### Relationships and Data Flow
- That both modules share the underlying form schema, which is manipulated by the designer and interpreted/rendered by the renderer.
– Data flow from the designer’s output (JSON/form configuration) to the renderer’s consumption.
– Interaction layers: UI actions in the designer panel trigger changes in the settings panel (via property-editor components) and update underlying data.
– Utility functions that bridge code generation and runtime behavior.
- That the extension loader (in src/extension) is responsible for importing additional widgets and sample extensions, thereby promoting customizability.

##### Architectural Patterns and Design Principles
- The project relies on component-based architecture typical to Vue applications.
- It separates concerns by dividing the UI into multiple layers: design components (widget panels, toolbars, settings), rendering components, and utility helpers.
- There is a focus on reusability and extensibility: for instance, the detailed property-editor folders indicate a strategy to modularize widget configuration.
- Use of external libraries (e.g., Element Plus for UI components, vuedraggable for drag & drop) is highlighted in both the README and file structure.

## Diagram (Mermaid)

```mermaid
flowchart TB

    %% Frontend Entry & Build Layer
    subgraph "Frontend Entry & Build"
        A1["index.html"]:::entry
        A2["main.js"]:::entry
        B1["vite.config.js"]:::build
        B2["vite-lib.config.js"]:::build
        B3["vite-lib-render.config.js"]:::build
    end

    %% UI Modules Layer
    subgraph "UI Modules"
        subgraph "Form Designer Module"
            C1["Form Designer"]:::designer
            C2["Widget Panel"]:::designer
            C3["Toolbar Panel"]:::designer
            C4["Setting Panel"]:::designer
            C5["Code Editor"]:::designer
        end
        subgraph "Form Renderer Module"
            D1["Form Renderer"]:::renderer
        end
        subgraph "Extensions"
            E1["Extension Loader"]:::extension
            E2["Extension Samples"]:::extension
        end
    end

    %% Utilities Layer
    subgraph "Supporting Utilities"
        F1["Utilities"]:::utility
    end

    %% Assets & Styles Layer
    subgraph "Assets & Styles"
        G1["Assets"]:::asset
        G2["Styles"]:::asset
        G3["Global Assets"]:::asset
    end

    %% Connections between layers
    A1 --> A2
    A2 -->|"registers components"| C1
    A2 -->|"registers components"| D1
    B1 --- A1
    B2 --- A2
    B3 --- A2
    C1 -->|"outputs JSONschema"| D1
    C1 -->|"loads"| E1
    E1 --> E2
    F1 --- C1
    F1 --- D1
    G1 --- C1
    G1 --- D1
    G2 --- C1
    G2 --- D1
    G3 --- C1
    G3 --- D1

    %% Click Events
    click A1 "https://github.com/vform666/variant-form3-vite/blob/master/index.html"
    click A2 "https://github.com/vform666/variant-form3-vite/blob/master/src/main.js"
    click B1 "https://github.com/vform666/variant-form3-vite/blob/master/vite.config.js"
    click B2 "https://github.com/vform666/variant-form3-vite/blob/master/vite-lib.config.js"
    click B3 "https://github.com/vform666/variant-form3-vite/blob/master/vite-lib-render.config.js"
    click C1 "https://github.com/vform666/variant-form3-vite/tree/master/src/components/form-designer"
    click D1 "https://github.com/vform666/variant-form3-vite/tree/master/src/components/form-render"
    click E1 "https://github.com/vform666/variant-form3-vite/blob/master/src/extension/extension-loader.js"
    click E2 "https://github.com/vform666/variant-form3-vite/tree/master/src/extension/samples"
    click F1 "https://github.com/vform666/variant-form3-vite/tree/master/src/utils"
    click G1 "https://github.com/vform666/variant-form3-vite/tree/master/src/assets"
    click G2 "https://github.com/vform666/variant-form3-vite/tree/master/src/styles"
    click G3 "https://github.com/vform666/variant-form3-vite/tree/master/public"

    %% Styles
    classDef entry fill:#f8b195,stroke:#333,stroke-width:2px;
    classDef build fill:#f67280,stroke:#333,stroke-width:2px;
    classDef designer fill:#c06c84,stroke:#333,stroke-width:2px;
    classDef renderer fill:#c06c84,stroke:#333,stroke-width:2px;
    classDef extension fill:#6c5b7b,stroke:#333,stroke-width:2px;
    classDef utility fill:#355c7d,stroke:#333,stroke-width:2px;
    classDef asset fill:#99b898,stroke:#333,stroke-width:2px;
```
