# pengzz9527/mind-map architecture

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

- Interactive diagram: https://gitdiagram.com/pengzz9527/mind-map
- Repository: https://github.com/pengzz9527/mind-map

## Overview

##### Project Type and Purpose
- This is a monorepo hosting two related but distinct products:
a. **simple-mind-map**: A framework-agnostic JavaScript mind-map library (packaged to npm) that exposes a plugin-based architecture for rendering and manipulating mind maps in any web page.
b. **web**: A Vue2+ElementUI single-page application that serves both as an online demo/editor for mind maps (with file import/export) and as comprehensive documentation (multi-language) for the library.

##### High-Level File Structure
- `/simple-mind-map` – the library source:
- `src/core`, `src/layouts`, `src/parse`, `src/plugins`, `src/themes`, `src/utils`
- `bin/` (WS server example), `example/`, build scripts, package.json
- `/web` – the Vue application:
- Build/config scripts (babel.config.js, vue.config.js, custom scripts for docs)
- `/dist` – compiled output (CSS, JS bundles, static assets) for deployment
- Root files: `README.md`, `LICENSE`, top-level `index.html`, `copy.js`, `.gitignore`

##### Key Architectural Patterns
- **Plugin Architecture (Library)**: Core rendering and event loop are extended via first-class plugins (e.g., Export, Formula, MiniMap). Each plugin registers hooks with the core command/event/render pipeline.
- **Layer Separation**:
- Core: data model, command & event dispatch, rendering abstraction.
- Layout: algorithms for positioning nodes (mind-map, fishbone, timeline).
- Parse/Serialize: import/export to JSON, Markdown, XMind, PDF, SVG.
- UI App (Vue): Presentation layer, user actions → calls library API → core modifies canvas.
- **Vue SPA Structure**:
- Pages: Entry points (Index, Edit, Doc)
- Components: Reusable UI (sidebars, toolbars, node editors)
- Router & Store: Navigation and global state
- API Module: interacts with local file system (via browser APIs) and possibly remote endpoints

##### Main Components and Interactions (
A. **Library Core** (simple-mind-map):
- Core Engine: Command, Event, Render subsystems
- Layout Manager: selects and runs layout algorithms
- Parser/Serializer: modules for Markdown, XMind, JSON, PDF, SVG
- Plugin Manager: loads and executes optional features
- Themes & Utils: styling, helper functions
B. **Web Application** (Vue2 SPA):
- UI Pages:
- Index.vue (marketing/home)
- Edit.vue (interactive canvas for creating/editing maps)
- Doc.vue (documentation pages)
- Components: Toolbar, Sidebar, Node editors, Export/import dialogs, Search, MiniMap
- Router & Vuex Store: route definitions, locale and theme state
- API Layer: wraps library calls and file I/O
C. **Build & Deployment**:
- Build Scripts: Webpack/Vue CLI, babel config, custom scripts to generate docs
- Output: `/dist` directory with static assets (CSS/JS chunks, fonts, images), `index.html`

##### Relationships and Data Flows
- **User Interaction** (Web UI) → Vue Components dispatch actions → Vuex store / direct calls to the library API → Library Core processes commands/events → Render updates canvas (SVG/Canvas element) → Vue detects changes if needed (e.g. side panels).
- **Import/Export**: UI triggers parser/serializer modules in library → generates or consumes data streams (JSON, XMind, Markdown) → triggers file download or canvas update.
- **Documentation Build**: Custom scripts read Markdown under `web/src/pages/Doc` → transform to Vue components → integrated into SPA.

##### Essential Elements
- User → Vue Components
- Components → Library API
- Library API → Core Engine → Render
- Build Scripts → Dist
- Blue for library internals
- Green for SPA structures
- Gray for build/deployment
- Yellow for external inputs (Markdown, JSON, XMind)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Library Layer
    subgraph "Library" 
        direction TB
        CoreEngine["Core Engine"]:::lib
        Command["Command Subsystem"]:::lib
        Event["Event Subsystem"]:::lib
        Render["Render Subsystem"]:::lib
        View["View Abstraction"]:::lib
        PluginManager["Plugin Manager"]:::lib
        AssocLine["AssociativeLine Plugin"]:::lib
        Layouts["Layout Manager"]:::lib
        Parsers["Parser/Serializer Modules"]:::lib
        Themes["Themes Collection"]:::lib
        Utils["Utility Functions"]:::lib
        SVGAssets["SVG Assets"]:::lib
    end

    %% Web App Layer
    subgraph "Web App" 
        direction TB
        App["App.vue"]:::spa
        Router["Vue Router"]:::spa
        Store["Vuex Store"]:::spa
        API["API Layer"]:::spa
        i18n["i18n Setup"]:::spa
        Lang["Language Packs"]:::spa
        subgraph "Pages"
            direction TB
            HomePg["Index.vue"]:::spa
            EditPg["Edit.vue"]:::spa
            DocPg["Doc.vue"]:::spa
        end
        subgraph "Page Components"
            direction TB
            HomeComp["Home Components"]:::spa
            EditComp["Edit Components"]:::spa
            DocComp["Doc Page Components"]:::spa
        end
        Assets["Global Assets"]:::spa
        ThemesWeb["Custom Themes"]:::spa
    end

    %% Build & Deployment Layer
    subgraph "Build & Deployment"
        direction TB
        Scripts["Build & Docs Scripts"]:::build
        Dist["Compiled Output"]:::build
        RootHTML["index.html"]:::build
        CopyJS["Monorepo Utility Script"]:::build
    end

    %% External Inputs
    subgraph "External Inputs"
        direction TB
        MD["Markdown"]:::external
        JSON["JSON"]:::external
        XMind["XMind"]:::external
    end

    %% Relationships
    HomePg -->|navigates| Router
    EditPg -->|navigates| Router
    DocPg  -->|navigates| Router
    Router -->|routes to| HomePg
    Router -->|routes to| EditPg
    Router -->|routes to| DocPg
    HomePg -->|renders| HomeComp
    EditPg -->|renders| EditComp
    DocPg  -->|renders| DocComp
    HomeComp -->|calls| API
    EditComp -->|calls| API
    DocComp  -->|calls| API
    API -->|invokes| CoreEngine
    CoreEngine -->|uses| Command
    CoreEngine -->|uses| Event
    CoreEngine -->|uses| Render
    CoreEngine -->|uses| View
    CoreEngine -->|loads| PluginManager
    PluginManager -->|loads| AssocLine
    CoreEngine -->|delegates| Layouts
    CoreEngine -->|delegates| Parsers
    CoreEngine -->|uses| Themes
    CoreEngine -->|uses| Utils
    CoreEngine -->|uses| SVGAssets
    Layouts -.->|layout algorithms| CoreEngine
    Parsers -->|parse/serialize| CoreEngine
    MD -->|parsed by| Parsers
    JSON -->|parsed by| Parsers
    XMind -->|parsed by| Parsers
    Scripts -->|builds| Dist
    Scripts -->|reads| CoreEngine
    Scripts -->|reads| App
    Scripts -->|generates| DocComp
    Dist -->|serves| RootHTML
    CopyJS -->|utilities| Scripts

    %% Click Events
    click CoreEngine "https://github.com/pengzz9527/mind-map/tree/main/simple-mind-map/src/core"
    click Command "https://github.com/pengzz9527/mind-map/blob/main/simple-mind-map/src/core/command/Command.js"
    click Event "https://github.com/pengzz9527/mind-map/blob/main/simple-mind-map/src/core/event/Event.js"
    click Render "https://github.com/pengzz9527/mind-map/blob/main/simple-mind-map/src/core/render/Render.js"
    click View "https://github.com/pengzz9527/mind-map/blob/main/simple-mind-map/src/core/view/View.js"
    click Layouts "https://github.com/pengzz9527/mind-map/tree/main/simple-mind-map/src/layouts"
    click Parsers "https://github.com/pengzz9527/mind-map/tree/main/simple-mind-map/src/parse"
    click PluginManager "https://github.com/pengzz9527/mind-map/tree/main/simple-mind-map/src/plugins"
    click AssocLine "https://github.com/pengzz9527/mind-map/tree/main/simple-mind-map/src/plugins/associativeLine"
    click SVGAssets "https://github.com/pengzz9527/mind-map/tree/main/simple-mind-map/src/svg"
    click Themes "https://github.com/pengzz9527/mind-map/blob/main/simple-mind-map/src/themes/index.js"
    click Utils "https://github.com/pengzz9527/mind-map/blob/main/simple-mind-map/src/utils/index.js"
    click App "https://github.com/pengzz9527/mind-map/blob/main/web/src/App.vue"
    click Router "https://github.com/pengzz9527/mind-map/blob/main/web/src/router.js"
    click Store "https://github.com/pengzz9527/mind-map/blob/main/web/src/store.js"
    click API "https://github.com/pengzz9527/mind-map/blob/main/web/src/api/index.js"
    click i18n "https://github.com/pengzz9527/mind-map/blob/main/web/src/i18n.js"
    click Lang "https://github.com/pengzz9527/mind-map/tree/main/web/src/lang"
    click HomePg "https://github.com/pengzz9527/mind-map/blob/main/web/src/pages/Index/Index.vue"
    click EditPg "https://github.com/pengzz9527/mind-map/blob/main/web/src/pages/Edit/Index.vue"
    click DocPg "https://github.com/pengzz9527/mind-map/blob/main/web/src/pages/Doc/Index.vue"
    click HomeComp "https://github.com/pengzz9527/mind-map/tree/main/web/src/pages/Index/components"
    click EditComp "https://github.com/pengzz9527/mind-map/tree/main/web/src/pages/Edit/components"
    click DocComp "https://github.com/pengzz9527/mind-map/tree/main/web/src/pages/Doc/components"
    click Assets "https://github.com/pengzz9527/mind-map/tree/main/web/src/assets"
    click ThemesWeb "https://github.com/pengzz9527/mind-map/tree/main/web/src/customThemes"
    click Scripts "https://github.com/pengzz9527/mind-map/tree/main/web/scripts"
    click Dist "https://github.com/pengzz9527/mind-map/tree/main/dist"
    click RootHTML "https://github.com/pengzz9527/mind-map/blob/main/index.html"
    click CopyJS "https://github.com/pengzz9527/mind-map/blob/main/copy.js"

    %% Styles
    classDef lib fill:#D0E8FF,stroke:#036,stroke-width:1px
    classDef spa fill:#DFFFD0,stroke:#262,stroke-width:1px
    classDef build fill:#E0E0E0,stroke:#666,stroke-width:1px
    classDef external fill:#FFF4C6,stroke:#aa0,stroke-width:1px
```
