# closetgeekshow/axure-to-mermaid architecture

> Architecture diagram of the GitHub repository closetgeekshow/axure-to-mermaid, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/closetgeekshow/axure-to-mermaid
- Repository: https://github.com/closetgeekshow/axure-to-mermaid

## Overview

##### Project Type and Purpose
- This is a front-end bookmarklet tool (an open-source browser plugin) that runs entirely in the browser.

##### File-Structure Analysis
Top-level:
- build/
– embedAssets.js: embeds CSS/HTML assets into the bookmarklet bundle
– processBookmarklet.js: bundles and minifies code for distribution
- src/
– components/: React-like UI modules
· AxureToMermaid.js – orchestrates data extraction from Axure
· Toolbar.js – renders the floating toolbar and export buttons
– store/:
– config/:
· buttonConfig.js, constants.js, embeddedAssets.js – UI settings and injected assets
– index.js – entry point, bootstraps the bookmarklet injection
- package.json, .gitignore, README.md, LICENSE, plan/…

##### README Insights
- The tool loads dependencies (js-base64, pako, matcha-css) at run-time from CDN to keep the bookmarklet small.
- It relies on Axure’s global object (`$axure`) at runtime.
- No server component; all logic runs in the browser.

##### Core System Components & Interactions
A. Components:
1. Bookmarklet Loader (index.js + build scripts)
2. UI Layer (Toolbar.js)
3. Data Extraction (AxureToMermaid.js)
5. State Store (MermaidStore.js + EventEmitter)
6. Export & Sharing (button handlers that call CDN services or clipboard APIs)
7. Config & Assets (buttonConfig, constants, embeddedAssets)
8. Utils (cssLoader for injecting styles, dom helpers)

B. Relationships / Data Flow:
- User clicks bookmarklet → Bookmarklet Loader injects CSS & Toolbar component into page
- Toolbar UI emits events (start conversion, export) via EventEmitter → Store updates
- MermaidStore holds markup → Toolbar presents it and export options

C. Architectural Patterns / Principles:
- Modular componentization: UI vs processing vs store vs utils
- Unidirectional data flow: actions → store → UI updates
- Dependency injection via CDN to minimize bundle size
- Separation of build-time (build/) vs run-time code (src/)

D. Key Technologies / Libraries:
- Vanilla JS modules (ES6)
- EventEmitter pattern for pub/sub
- CDN-loaded: js-base64, pako, matcha-css
- Build tools: Node scripts in build/, package.json scripts

- Blue rectangles for internal modules (components, store, utils)
- Injection flow (Bookmarklet → Toolbar)
- Data flow (AxureToMermaid → SitemapProcessor → MermaidStore → Toolbar)
- Related modules (e.g., src/components) with a shaded border or container

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build Pipeline
    BuildPipeline[(Build Pipeline)]:::build
    BuildPipeline -->|produces| BookmarkletLoader

    %% Entry Point
    User["End User"]:::external
    User -->|clicks bookmarklet| BookmarkletLoader["Bookmarklet Loader"]:::internal

    %% Runtime Injection
    BookmarkletLoader -->|"injects CSS"| CSSLoader["CSS Loader"]:::internal
    BookmarkletLoader -->|"injects Toolbar"| Toolbar

    %% Components Group
    subgraph "src/components" 
        style src/components fill:#f0f9ff,stroke:#a3c2f0
        Toolbar["Toolbar (UI Layer)"]:::internal
        AxureToMermaid["AxureToMermaid (Data Extraction)"]:::internal
        SitemapProcessor["SitemapProcessor (Transformer)"]:::internal
    end

    %% Store
    subgraph "src/store"
        style src/store fill:#f0f9ff,stroke:#a3c2f0
        MermaidStore["MermaidStore (State Store)"]:::internal
    end

    %% Utils
    subgraph "src/utils"
        style src/utils fill:#f0f9ff,stroke:#a3c2f0
        EventEmitter["EventEmitter"]:::internal
        CSSLoader
        DOMHelpers["DOM Helpers"]:::internal
        MermaidUtils["Mermaid Utilities"]:::internal
    end

    %% Config
    subgraph "src/config"
        style src/config fill:#f0f9ff,stroke:#a3c2f0
        ButtonConfig["buttonConfig"]:::internal
        Constants["constants"]:::internal
        EmbeddedAssets["embeddedAssets"]:::internal
    end

    %% External
    subgraph "External Dependencies"
        style ExternalDependencies fill:#e6f9e6,stroke:#b3e6b3
        CDNLibraries["CDN Libraries\n(js-base64, pako, matcha-css)"]:::external
        MermaidInk["Mermaid.Ink"]:::external
        AxureGlobal["$axure Global Obj"]:::external
    end

    %% Runtime Flow
    Toolbar -->|"onConvert event"| EventEmitter
    EventEmitter -->|notifies| MermaidStore
    EventEmitter -->|triggers| AxureToMermaid
    AxureToMermaid -->|calls| AxureGlobal
    AxureToMermaid -->|provides sitemap| SitemapProcessor
    SitemapProcessor -->|uses| MermaidUtils
    SitemapProcessor -->|outputs markup| MermaidStore
    MermaidStore -->|updates| Toolbar
    Toolbar -->|export action| ExportSharing

    %% Export Sharing
    ExportSharing["Export & Sharing\n(clipboard/download/Mermaid.Ink)"]:::internal
    Toolbar -->|export| ExportSharing
    ExportSharing -->|submits to| MermaidInk
    ExportSharing -->|uses| DOMHelpers

    %% CDN load
    CDNLibraries -->|loaded by| BookmarkletLoader

    %% Legend
    subgraph Legend
        direction LR
        A[Internal Modules]:::internal
        B[External Services]:::external
        C[(Build Artifacts)]:::build
    end

    %% Click Events
    click BookmarkletLoader "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/index.js"
    click BuildPipeline "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/build/embedAssets.js"
    click BuildPipeline "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/build/processBookmarklet.js"
    click Toolbar "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/components/Toolbar.js"
    click AxureToMermaid "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/components/AxureToMermaid.js"
    click SitemapProcessor "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/components/SitemapProcessor.js"
    click MermaidUtils "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/utils/mermaidUtils.js"
    click MermaidStore "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/store/MermaidStore.js"
    click EventEmitter "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/utils/EventEmitter.js"
    click CSSLoader "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/utils/cssLoader.js"
    click DOMHelpers "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/utils/dom.js"
    click ButtonConfig "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/config/buttonConfig.js"
    click Constants "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/config/constants.js"
    click EmbeddedAssets "https://github.com/closetgeekshow/axure-to-mermaid/blob/main/src/config/embeddedAssets.js"

    %% Styles
    classDef internal fill:#cfe2f3,stroke:#6fa8dc,stroke-width:1px
    classDef external fill:#d9ead3,stroke:#93c47d,stroke-width:1px,stroke-dasharray: 5 5
    classDef build fill:#f9cb9c,stroke:#e69138,stroke-width:1px,stroke-dasharray: 2 2
```
