# ikuaitu/vue-fabric-editor architecture

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

- Interactive diagram: https://gitdiagram.com/ikuaitu/vue-fabric-editor
- Repository: https://github.com/ikuaitu/vue-fabric-editor

## Overview

##### Main Components
- Core Editor & Plugin Library (located in packages/core):
– The core code (Editor.ts, Instance.ts, ContextMenu.js, etc.) implements the primary functionalities.
– Individual plugins (e.g., AddBaseTypePlugin.ts, AlignGuidLinePlugin.ts, HistoryPlugin.ts, etc.) are organized in subfolders, and they encapsulate discrete features that extend the editor.
- Frontend Application (located in src):
– App.vue along with the various Vue components (e.g., admin.vue, align.vue, group.vue, cropperDialog.vue, etc.) form the user interface.
– The views (in src/views) and layout components organize the overall editor experience (workspace, toolbars, modal dialogs, etc.).
– The API layer (src/api) and configurations (src/config, src/router) manage client-side routing, state management, user interactions, and integration with external services if needed.
- Build/Deployment & Configuration:
– Configuration files (vite.config.ts, tsconfig.json, etc.) and CI/CD pipeline definitions (.github/workflows, Dockerfile/docker-compose.yml, nginx.conf) illustrate how the project is built, tested, and deployed.
– Testing components in packages/core/__tests__ show that there is a layer of testing and validation.

##### Relationship & Data Flow
– The “App” container interacts with boutique Vue components that call editor-related functions.
– Frontend components request editing services that are provided by the editor core and its loaded plugins.
- Plugin Architecture:
– Indicate the flow from the core to the plugins and back, such as when a user action in the UI triggers a plugin function, which then affects the editing canvas.
- Asset & Utility Integration:
– Include supporting modules like “assets,” “utils,” “styles,” and “ruler” (which offer guidelines and snapping functionality) that complement the core efforts.

##### Architectural Patterns & Design Principles
- Plugin-based extensibility is the core design principle:
– Emphasize how the editor core loads and executes plugin modules, and how plugins encapsulate their functionalities to be optionally included or replaced.
- Separation of Concerns:
– The Editor Core (and its plugins) is cleanly separated from the frontend Vue components; this modular separation ensures that UI logic and editor logic remain decoupled.
- Component-based UI:
– The front-end is organized with reusable Vue components (organized by function: templates, controls, dialogs, etc.) which interact with the editor backend.

##### Mention Key Technologies & Tools
- Vue.js: Powers the front-end user interface.
- fabric.js: Provides the canvas-based image editing functionalities.
- Vite: Used as the build system (note the vite.config.ts).
- Testing Frameworks: Vitest and testing configurations in packages/core/__tests__ indicate an emphasis on test-driven development.
- CI/CD & Deployment: Docker, docker-compose, and GitHub workflows for continuous integration and deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface (Vue Front-end)"
        U_main("App.vue"):::ui
        U_comp("UI Components"):::ui
        U_api("API Modules"):::ui
        U_router("Router"):::ui
        U_conf("Configurations"):::ui
    end

    subgraph "Editor Core (packages/core)"
        E_core("Core Engine (Editor.ts, Instance.ts, ContextMenu.js)"):::core
        E_plugins("Plugins"):::plugin
        E_assets("Objects & Assets"):::core
        E_utils("Utilities"):::core
        E_ruler("Ruler & Guideline Functions"):::core
        E_tests("Tests"):::core
    end

    subgraph "Build & Deployment"
        B_config("Configuration Files (vite.config.ts, tsconfig.json, Dockerfile, docker-compose.yml, nginx.conf)"):::deploy
        B_cicd("CI/CD Pipelines"):::deploy
    end

    %% Connections between UI and Editor Core
    U_main -->|"triggers"| E_core
    U_comp -->|"calls"| E_core
    U_api -->|"requestsEditing"| E_core
    U_conf -->|"configures"| U_main
    U_router -->|"navigatesTo"| U_main

    %% Internal connections within Editor Core
    E_core -->|"loads"| E_plugins
    E_plugins -->|"executes"| E_core
    E_core -->|"utilizes"| E_assets
    E_core -->|"invokes"| E_utils
    E_core -->|"integrates"| E_ruler
    E_tests -->|"validates"| E_core

    %% Connections to Build & Deployment
    B_config -->|"buildsUI"| U_main
    B_config -->|"buildsEditor"| E_core
    B_cicd -->|"automatesDeploy"| B_config

    %% Click Events for UI Components
    click U_main "https://github.com/ikuaitu/vue-fabric-editor/tree/main/src"
    click U_comp "https://github.com/ikuaitu/vue-fabric-editor/tree/main/src/components"
    click U_api "https://github.com/ikuaitu/vue-fabric-editor/tree/main/src/api"
    click U_router "https://github.com/ikuaitu/vue-fabric-editor/tree/main/src/router"
    click U_conf "https://github.com/ikuaitu/vue-fabric-editor/tree/main/src/config"

    %% Click Events for Editor Core Components
    click E_core "https://github.com/ikuaitu/vue-fabric-editor/tree/main/packages/core"
    click E_plugins "https://github.com/ikuaitu/vue-fabric-editor/tree/main/packages/core/plugin"
    click E_assets "https://github.com/ikuaitu/vue-fabric-editor/tree/main/packages/core/objects"
    click E_utils "https://github.com/ikuaitu/vue-fabric-editor/tree/main/packages/core/utils"
    click E_ruler "https://github.com/ikuaitu/vue-fabric-editor/tree/main/packages/core/ruler"
    click E_tests "https://github.com/ikuaitu/vue-fabric-editor/tree/main/packages/core/__tests__"

    %% Click Event for Build/Deployment component (CI/CD)
    click B_cicd "https://github.com/ikuaitu/vue-fabric-editor/tree/main/.github/workflows"
    click B_config "https://github.com/ikuaitu/vue-fabric-editor/blob/main/."

    %% Styles
    classDef ui fill:#f6d186,stroke:#333,stroke-width:2px;
    classDef core fill:#bdd7ee,stroke:#333,stroke-width:2px;
    classDef plugin fill:#f9c2ff,stroke:#333,stroke-width:2px;
    classDef deploy fill:#d7f9f5,stroke:#333,stroke-width:2px;
```
