# markmap/markmap-vscode architecture

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

- Interactive diagram: https://gitdiagram.com/markmap/markmap-vscode
- Repository: https://github.com/markmap/markmap-vscode

## Overview

##### Project Type and Purpose
- The project is a VSCode extension.
- Its main purpose is to allow users to preview Markdown files as markmap visualizations directly within VSCode.
- Key features include real-time updates when editing Markdown, an interactive preview triggered via several UI elements (command palette, context menu, and title-bar button), offline operation, and customization (via custom CSS and default options).

##### Analyzing the File Structure and Components
- Top-Level Files & Configurations:
- Configuration files like .vscode, babel.config.cjs, eslint.config.mjs, tsconfig.json, rollup.config.mjs, and package.json indicate the use of TypeScript, Rollup for bundling, Babel configurations, and linting.
- GitHub workflows and husky files suggest automated testing and release processes.
- Source Code (src folder):
- extension.ts: Likely the main entry point for the VSCode extension activation – where commands are registered.
- app.ts: Contains core logic for handling interactions once the extension is active (possibly managing the preview, listening for file changes, or delegating tasks).
- plugins folder (with local-image.ts): Provides additional functionality for handling local images within the Markdown or markmap.
- postbuild.ts and util.ts: Handle post-build processes and utility functions.
- Assets:
- assets/style.css: Custom styling for markmap previews indicating UI customization.

##### Key Components
a. VSCode Environment:
- VSCode extension host and its interfaces (command palette, context menu, title-bar button).
b. Extension Entry Points:
c. Plugin Architecture:
d. Markmap Integration:
- Custom CSS asset (assets/style.css) that styles the output.
e. Build & Deployment Pipeline (Optional):
- Briefly indicate build scripts (Rollup, Babel) and configuration files (tsconfig, eslint) as the development-time processes that compile, bundle, and enforce code quality.

##### Relationships and Interactions
- Communication path from app.ts to the Markmap library, which processes the Markdown and returns a visualization.
- If applicable, include the role of plugins (local-image.ts) that may intercept, process, or enhance parts of the input/output.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Deployment Pipeline Subgraph
    subgraph "Build & Deployment Pipeline"
        B1["Rollup (rollup.config.mjs)"]:::build
        B2["Babel (babel.config.cjs)"]:::build
        B3["TypeScript Config (tsconfig.json)"]:::build
        B4["ESLint (eslint.config.mjs)"]:::build
    end

    %% VSCode Environment
    UI["VSCode UI/Extension Host"]:::user

    %% Extension Activation and Core Logic
    EA["Extension Activation (extension.ts)"]:::runtime
    AL["Application Logic (app.ts)"]:::runtime

    %% External Integration
    MI["Markmap Library Integration"]:::external

    %% Plugins and Assets
    PL["Plugins (Local Image Handling)"]:::plugin
    AC["Assets (Custom CSS)"]:::asset

    %% Relationships and Data Flow
    B1 -->|"builds"| EA
    UI -->|"triggers"| EA
    EA -->|"delegatesTo"| AL
    AL -->|"processesMarkdown"| MI
    AL -->|"invokesPlugin"| PL
    AL -->|"appliesStyling"| AC

    %% Click Events for Component Mapping
    click EA "https://github.com/markmap/markmap-vscode/blob/master/src/extension.ts"
    click AL "https://github.com/markmap/markmap-vscode/blob/master/src/app.ts"
    click PL "https://github.com/markmap/markmap-vscode/blob/master/src/plugins/local-image.ts"
    click AC "https://github.com/markmap/markmap-vscode/blob/master/assets/style.css"
    click B1 "https://github.com/markmap/markmap-vscode/blob/master/rollup.config.mjs"
    click B2 "https://github.com/markmap/markmap-vscode/blob/master/babel.config.cjs"
    click B3 "https://github.com/markmap/markmap-vscode/blob/master/tsconfig.json"
    click B4 "https://github.com/markmap/markmap-vscode/blob/master/eslint.config.mjs"

    %% Styles
    classDef user fill:#d1c4e9,stroke:#512da8,stroke-width:2px;
    classDef runtime fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
    classDef plugin fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef asset fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef build fill:#e0e0e0,stroke:#616161,stroke-width:2px;
```
