# woai3c/visual-drag-demo architecture

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

- Interactive diagram: https://gitdiagram.com/woai3c/visual-drag-demo
- Repository: https://github.com/woai3c/visual-drag-demo

## Overview

##### Main Components
- Application Shell – This includes the main Vue application (src/main.js) with the global configuration and initialization.
- Editor Interface – The central “Editor” module (under src/components/Editor) that encompasses several subcomponents, such as:
- Canvas/Preview
- Grid
- Custom Components Library – Located under src/custom-component, which contains different types of user-defined components (e.g., CircleShape, RectShape, VText, VButton, and SVG components). This can be treated as a plugin-like architecture to extend the available components.
- State Management – Vuex store modules (src/store directory) that manage various aspects such as alignment, animation, event handling, layering, and snapshots (undo/redo features).
- Routing – The vue-router in src/router that handles different views and navigation, e.g., Home view in src/views.
- Utility Functions – A set of shared utilities located under src/utils that support functionalities like animation, coordinate calculations, and event bus management.
- Public Files & Configurations – The public directory (with index.html) and configuration files including babel, eslint, prettier, etc., that manage development and build configurations.

##### Relationship and Interactions Between Components
- The Application Shell loads the main Vue instance, which sets up the Routing (src/router) and the Global State (src/store).
- The Editor view (src/views/Home.vue) is central; it integrates various subcomponents such as the toolbar, component list (both built-in and custom), and the drag-and-drop canvas.
- When a user drags a component from the Component List (or Custom Component List) onto the canvas, interactions are managed via the central state store and utilities that calculate positions, sizes, and events.
- Editor components (like the context menu, grid, and preview modules) communicate with each other using event buses (as seen in src/utils/eventBus.js) and Vuex actions/mutations.
- Custom Components are built with a standardized “Component” and “Attr” structure for each type (such as Button, Text, etc.), ensuring consistency. Common shared functionalities (linkage, events, requests) exist under src/custom-component/common.
- The style and assets modules ensure that all components maintain a consistent UI/UX, with additional styles and themes distinguished in src/styles.

##### Architectural Patterns and Design Principles
- MVC/MVVM Patterns: The project separates the view layers (Vue components) from state management (Vuex) and business logic (utility functions, component modules).
- Modular Components: The Editor and custom components are organized as self-contained modules, which promotes extensibility (e.g., adding more custom components is simply a folder addition under src/custom-component).
- Event-driven Communication: Use of eventBus and Vuex for communication between layers is central to handling interactions (such as drag-and-drop, component attribute changes, or undo/redo operations).

##### Relevant Technologies and Frameworks
- Vue.js, including Vue Router and Vuex.
- ESLint, Prettier, and Babel for code quality and compatibility.
- Modern JavaScript utilities and libraries to handle animations, component positioning, and drag-and-drop functionalities.
- CSS/SCSS and Component-specific styling to ensure modular styling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Application Shell"]:::ui
    R["Routing"]:::business
    S["State Management (Vuex)"]:::business
    E["Editor Interface"]:::ui
    C["Custom Components Library"]:::ui
    U["Utility Functions"]:::business

    subgraph "Editor Subcomponents"
        E1["Canvas/Preview"]:::ui
        E2["Grid"]:::ui
        E3["Context Menu"]:::ui
        E4["MarkLine"]:::ui
    end

    subgraph "Asset & Styling Management"
        As["Assets"]:::config
        St["Styles"]:::config
    end

    subgraph "Public & Configurations"
        P["Public Files"]:::config
        B["babel.config.js"]:::config
        L[".eslintrc.js"]:::config
        Vc["vue.config.js"]:::config
    end

    A -->|"loads"| R
    A -->|"initializes"| S
    A -->|"renders"| E
    A -->|"includes"| P
    E -->|"contains"| E1
    E -->|"contains"| E2
    E -->|"contains"| E3
    E -->|"contains"| E4
    E -->|"triggers"| U
    E -->|"integrates"| C
    U -->|"updates"| S
    As -->|"styles/supports"| E
    St -->|"styles/supports"| E
    As -->|"styles/supports"| C
    St -->|"styles/supports"| C

    click A "https://github.com/woai3c/visual-drag-demo/blob/main/src/main.js"
    click R "https://github.com/woai3c/visual-drag-demo/tree/main/src/router"
    click S "https://github.com/woai3c/visual-drag-demo/tree/main/src/store"
    click E "https://github.com/woai3c/visual-drag-demo/tree/main/src/components/Editor"
    click C "https://github.com/woai3c/visual-drag-demo/tree/main/src/custom-component"
    click U "https://github.com/woai3c/visual-drag-demo/tree/main/src/utils"
    click As "https://github.com/woai3c/visual-drag-demo/tree/main/src/assets"
    click St "https://github.com/woai3c/visual-drag-demo/tree/main/src/styles"
    click P "https://github.com/woai3c/visual-drag-demo/tree/main/public"
    click B "https://github.com/woai3c/visual-drag-demo/blob/main/babel.config.js"
    click L "https://github.com/woai3c/visual-drag-demo/blob/main/.eslintrc.js"
    click Vc "https://github.com/woai3c/visual-drag-demo/blob/main/vue.config.js"

    classDef ui fill:#A5D6A7,stroke:#333,stroke-width:2px;
    classDef business fill:#90CAF9,stroke:#333,stroke-width:2px;
    classDef config fill:#FFCC80,stroke:#333,stroke-width:2px;
```
