# fangyang921017/vue-jsplumb-editor architecture

> Architecture diagram of the GitHub repository fangyang921017/vue-jsplumb-editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fangyang921017/vue-jsplumb-editor
- Repository: https://github.com/fangyang921017/vue-jsplumb-editor

## Overview

##### Project Type and Purpose
- The project is a single-page application (SPA) built using Vue.js, with TypeScript integration. The main purpose is to provide a rich, interactive flow chart editor.
- Key functionalities include dragging nodes from a menu, displaying a flow chart where nodes can be added, moved, and connected using endpoints (source and target), and contextual actions via a right-click menu.

##### Analyzing the File Structure
- Notice the src directory, which contains the key Vue components (App.vue, Index.vue, Operation.vue, etc.) and a focused FlowChart folder that holds all the core logic (Command.js, EventCenter.js, Node.vue, Utils.js, configuration, and styling logic).
- The presence of subdirectories like “assets”, “views”, “api”, “mock”, “router.ts”, and “store.ts” further points toward a typical full-featured Vue SPA, where routing, state management (likely Vuex or similar), and type-safe API interactions are handled.
- The dist directory, complete with bundled CSS, JS, and other assets, confirms that this setup uses a build step (via npm scripts) to produce the production bundle.

##### Key Components
a. Frontend Application:
- Vue.js Application: Represent the root component (App.vue) that initializes the UI.

b. Flow Chart Engine:
- FlowChart Module: Include a set of components/modules like FlowChart.vue, Node.vue, and related utilities – these collectively manage the graphical representation of the flow chart.
- Command, EventCenter, and Model: Represent the core business logic that manages state changes (undo/redo actions, node creation and deletion) and event handling.
- Editor and Associated Styles: Show components responsible for rendering the editor and controlling the look and feel (e.g., editorCss.js, style.js).

c. UI Functional Areas:
- Menu Node Area: A distinct component/section where the list or palette of draggable nodes is presented.
- Main Design Area: The canvas where nodes are dropped, moved, and connected. Illustrate the handling of operations like node dragging, zooming/panning of the background, and the generation of source/target endpoints.
- Node Configuration Panel: This panel appears when a user selects a node, allowing configuration of properties.
- Context Menu: A right-click menu for nodes, links, and the background providing extra actions (e.g., copy, paste, delete, rename).

d. Data Flow/State Management:
- API/Mock: Although primarily a frontend application, the project includes an “api” and “mock” directory, indicating that data handling (or simulated back-end responses) might be abstracted through these modules.

##### Relationships and Interactions
- That the FlowChart engine modules interact with both the UI (rendering nodes, showing tooltips, updating styles on hover) and the application state.
- Bi-directional data binding between node state (managed by the store) and the configuration panel.
- Event handling paths: for example, when a node is moved or clicked, events are dispatched to the EventCenter module and then update the view accordingly.

##### Architectural Patterns and Technologies
- MVC/MVVM: Emphasize the separation of concerns: view components (Vue templates), data/state (the store and model modules), and the controller-like behavior present in the command and event-handling modules.
- Component-based Design: Each Vue component (menu, node, view) should be represented as a modular block that collaborates with others.
- Drag-and-Drop and Real-Time UI Updates: Identify the use of libraries or custom utilities (such as moveAndZoom.js, contextMenu.js) that manage user interactions.
- Technologies and Tools: Mention Vue.js, potentially TypeScript (noted by .ts files), and the use of build tools (babel, npm scripts, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Components"
        VUE["Vue Root Component"]:::ui
        subgraph "Main Views"
            Home["Home View"]:::ui
            About["About View"]:::ui
        end
        Menu["Menu Node Area"]:::ui
        Design["Main Design Area"]:::ui
        NodeOp["Node Operation Panel"]:::ui
    end

    subgraph "FlowChart Engine"
        FCC["FlowChart Container"]:::logic
        FCCore["Core FlowChart Logic & Utilities"]:::logic
        Editor["Editor and Styling"]:::logic
    end

    subgraph "State Management & Navigation"
        Router["Router Configuration"]:::state
        Store["Store"]:::state
    end

    subgraph "API & Data"
        API["API Module"]:::api
        Mock["Mock Data"]:::api
    end

    VUE -->|"initializes"| Home
    VUE -->|"initializes"| About
    VUE -->|"loads"| Menu
    VUE -->|"loads"| Design
    VUE -->|"configures"| NodeOp
    VUE -->|"configures"| Router
    VUE -->|"configures"| Store
    FCC -->|"renders"| Design
    FCCore -->|"handles_events"| Design
    FCCore --> Editor
    FCCore <-->|"internal_comm"| FCC
    Menu -->|"drag_drop"| Design
    NodeOp <-->|"state_control"| Store
    Router -->|"routes"| Home
    Router -->|"routes"| About
    Store -->|"sync_state"| Design
    API -->|"fetch_update"| Store
    Mock -->|"simulate_API"| Store

    click VUE "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/App.vue"
    click Home "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/views/Home.vue"
    click About "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/views/About.vue"
    click FCC "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/FlowChart.vue"
    click FCCore "https://github.com/fangyang921017/vue-jsplumb-editor/tree/master/src/FlowChart/"
    click NodeOp "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/Operation.vue"
    click Router "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/router.ts"
    click Store "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/store.ts"
    click API "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/api/index.ts"
    click Mock "https://github.com/fangyang921017/vue-jsplumb-editor/blob/master/src/mock/index.ts"

    classDef ui fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef state fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef api fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
```
