# mjbvz/vscode-markdown-mermaid architecture

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

- Interactive diagram: https://gitdiagram.com/mjbvz/vscode-markdown-mermaid
- Repository: https://github.com/mjbvz/vscode-markdown-mermaid

## Overview

This VS Code extension adds Mermaid diagrams to Markdown previews and notebook cells. Markdown input is recognized by a Markdown-It extension; the preview or notebook webview then renders diagram blocks as SVG and adds interactive navigation. The VS Code extension supplies preview configuration, while the shared rendering layer registers Mermaid add-ons and handles diagram rendering. The README also documents custom syntax, Iconify icons, themes, and navigation/resizing options. Edges reflect shown calls or README statements; notebook-specific details not shown in the excerpts are omitted.

Main entry points: [`src/markdownPreview/index.ts`](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/markdownPreview/index.ts) (Preview webview), [`src/notebook/index.ts`](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/notebook/index.ts) (Notebook renderer), [`src/shared-mermaid/index.ts`](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/index.ts) (Mermaid block rendering), [`src/shared-mermaid/diagramManager.ts`](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/diagramManager.ts) (Pan and zoom manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["VS Code integration"]
  node_extension["Extension activation<br/>[index.ts]"]
  node_config["Preview config injection<br/>[config.ts]"]
end

subgraph group_syntax["Markdown syntax"]
  node_markdownit["Markdown-It syntax<br/>[index.ts]"]
end

subgraph group_rendering["Diagram rendering"]
  node_preview["Preview webview<br/>[index.ts]"]
  node_notebookrenderer["Notebook renderer<br/>[index.ts]"]
  node_render["Mermaid block rendering<br/>[index.ts]"]
  node_mermaid["Mermaid engine"]
  node_addons["Icons and layouts<br/>[iconPackConfig.ts]"]
  node_settings["Render settings<br/>[config.ts]"]
end

subgraph group_interaction["Diagram interaction"]
  node_manager["Pan and zoom manager<br/>[diagramManager.ts]"]
  node_disposable["Interaction cleanup<br/>[disposable.ts]"]
end

node_author(("Markdown author"))
node_markdown["Markdown preview"]
node_notebook["Notebook cells"]

node_author -->|"writes diagrams"| node_markdown
node_author -->|"writes diagrams"| node_notebook
node_extension -->|"registers syntax"| node_markdownit
node_extension -->|"configures preview"| node_config
node_markdownit -->|"passes diagram blocks"| node_preview
node_markdownit -->|"parses diagram blocks"| node_notebookrenderer
node_config -->|"injects settings"| node_preview
node_preview -->|"renders blocks"| node_render
node_preview -->|"sets up navigation"| node_manager
node_preview -->|"loads settings"| node_settings
node_notebookrenderer -->|"renders blocks"| node_render
node_notebookrenderer -->|"sets up navigation"| node_manager
node_notebookrenderer -->|"loads settings"| node_settings
node_render -->|"parses and renders"| node_mermaid
node_render -->|"registers add-ons"| node_addons
node_manager -->|"uses interaction settings"| node_settings
node_manager -->|"returns cleanup handle"| node_disposable

click node_extension "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/vscode-extension/index.ts"
click node_config "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/vscode-extension/config.ts"
click node_markdownit "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-md-mermaid/index.ts"
click node_preview "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/markdownPreview/index.ts"
click node_notebookrenderer "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/notebook/index.ts"
click node_render "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/index.ts"
click node_addons "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/iconPackConfig.ts"
click node_settings "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/config.ts"
click node_manager "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/diagramManager.ts"
click node_disposable "https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/disposable.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_extension,node_config,node_markdown toneBlue
class node_markdownit toneAmber
class node_preview,node_notebookrenderer,node_render,node_mermaid,node_addons,node_settings toneMint
class node_manager,node_disposable toneRose
class node_author,node_notebook toneIndigo
```

## Components

### VS Code integration

- [Extension activation](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/vscode-extension/index.ts): `src/vscode-extension/index.ts`
- [Preview config injection](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/vscode-extension/config.ts): `src/vscode-extension/config.ts`

### Markdown syntax

- [Markdown-It syntax](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-md-mermaid/index.ts): `src/shared-md-mermaid/index.ts`

### Diagram rendering

- [Preview webview](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/markdownPreview/index.ts): `src/markdownPreview/index.ts`
- [Notebook renderer](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/notebook/index.ts): `src/notebook/index.ts`
- [Mermaid block rendering](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/index.ts): `src/shared-mermaid/index.ts`
- **Mermaid engine**
- [Icons and layouts](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/iconPackConfig.ts): `src/shared-mermaid/iconPackConfig.ts`
- [Render settings](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/config.ts): `src/shared-mermaid/config.ts`

### Diagram interaction

- [Pan and zoom manager](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/diagramManager.ts): `src/shared-mermaid/diagramManager.ts`
- [Interaction cleanup](https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/shared-mermaid/disposable.ts): `src/shared-mermaid/disposable.ts`

### Other components

- **Markdown author**
- **Markdown preview**
- **Notebook cells**

## Connections

- Markdown author → Markdown preview: writes diagrams (evidence: `README.md`)
- Markdown author → Notebook cells: writes diagrams (evidence: `README.md`)
- Extension activation → Markdown-It syntax: registers syntax (evidence: `src/vscode-extension/index.ts`)
- Extension activation → Preview config injection: configures preview (evidence: `src/vscode-extension/index.ts`)
- Markdown-It syntax → Preview webview: passes diagram blocks (evidence: `README.md`)
- Markdown-It syntax → Notebook renderer: parses diagram blocks (evidence: `src/notebook/index.ts`)
- Preview config injection → Preview webview: injects settings (evidence: `src/vscode-extension/config.ts`)
- Preview webview → Mermaid block rendering: renders blocks (evidence: `src/markdownPreview/index.ts`)
- Preview webview → Pan and zoom manager: sets up navigation (evidence: `src/markdownPreview/index.ts`)
- Preview webview → Render settings: loads settings (evidence: `src/markdownPreview/index.ts`)
- Notebook renderer → Mermaid block rendering: renders blocks (evidence: `src/notebook/index.ts`)
- Notebook renderer → Pan and zoom manager: sets up navigation (evidence: `src/notebook/index.ts`)
- Notebook renderer → Render settings: loads settings (evidence: `src/notebook/index.ts`)
- Mermaid block rendering → Mermaid engine: parses and renders (evidence: `src/shared-mermaid/index.ts`)
- Mermaid block rendering → Icons and layouts: registers add-ons (evidence: `src/shared-mermaid/index.ts`)
- Pan and zoom manager → Render settings: uses interaction settings (evidence: `src/shared-mermaid/diagramManager.ts`)
- Pan and zoom manager → Interaction cleanup: returns cleanup handle (evidence: `src/shared-mermaid/diagramManager.ts`)
