# mchandru13/mermaid-desk architecture

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

- Interactive diagram: https://gitdiagram.com/mchandru13/mermaid-desk
- Repository: https://github.com/mchandru13/mermaid-desk

## Overview

MermaidDesk is an offline desktop editor: users create or open a diagram, edit it in tabs, see a live preview, and save or export it. React manages the workspace and rendering; a platform adapter connects the UI to Tauri commands, where Rust mediates local files, settings, recovery, and clipboard access. The README documents additional editor and desktop capabilities; some implementation details were not sampled, so the graph only draws relationships evidenced by excerpts, the source index, or the README.

Main entry points: [`src/App.tsx`](https://github.com/mchandru13/mermaid-desk/blob/main/src/App.tsx) (App coordinator), [`src-tauri/src/lib.rs`](https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/lib.rs) (Tauri command host), [`src/state/workspace.ts`](https://github.com/mchandru13/mermaid-desk/blob/main/src/state/workspace.ts) (Workspace state), [`src-tauri/src/settings.rs`](https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/settings.rs) (App settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Editing UI"]
  node_app["App coordinator<br/>[App.tsx]"]
  node_editor["Monaco editor<br/>[EditorPane.tsx]"]
  node_preview["Diagram preview<br/>[PreviewPane.tsx]"]
  node_tabs["Tab strip<br/>[TabStrip.tsx]"]
  node_toolbar["Toolbar<br/>[Toolbar.tsx]"]
  node_templates["Template gallery"]
end

subgraph group_frontend["Workspace Services"]
  node_workspace["Workspace state<br/>[workspace.ts]"]
  node_render["Mermaid renderer<br/>[render.ts]"]
  node_export["Export helpers<br/>[export.ts]"]
  node_platform["Platform adapter<br/>[platform.ts]"]
  node_editorconfig["Editor language setup<br/>[monaco.ts]"]
end

subgraph group_native["Desktop Services"]
  node_tauri["Tauri command host<br/>[lib.rs]"]
  node_documents["Document file access<br/>[documents.rs]"]
  node_clipboard["Image clipboard<br/>[clipboard.rs]"]
  node_menu["Native menu<br/>[menu.rs]"]
end

subgraph group_state["Local State"]
  node_settings[("App settings<br/>[settings.rs]")]
  node_session[("Session recovery<br/>[session.rs]")]
end

node_user(("Diagram user"))
node_localfiles[("User files")]

node_user -->|"operates"| node_app
node_app -->|"coordinates"| node_workspace
node_app -->|"renders diagrams"| node_render
node_app -->|"shows editor"| node_editor
node_app -->|"shows preview"| node_preview
node_app -->|"shows tabs"| node_tabs
node_app -->|"shows controls"| node_toolbar
node_app -->|"opens gallery"| node_templates
node_editor -->|"configures editor"| node_editorconfig
node_preview -->|"measures SVG"| node_render
node_workspace -->|"uses platform"| node_platform
node_workspace -->|"rasterizes exports"| node_export
node_workspace -->|"saves recovery"| node_session
node_workspace -->|"persists preferences"| node_settings
node_platform -->|"invokes commands"| node_tauri
node_tauri -->|"registers commands"| node_documents
node_tauri -->|"registers command"| node_clipboard
node_tauri -->|"registers commands"| node_session
node_tauri -->|"registers commands"| node_settings
node_tauri -->|"installs menu"| node_menu
node_documents -->|"reads and writes"| node_localfiles
node_settings -->|"stores JSON"| node_localfiles
node_session -->|"journals session"| node_localfiles
node_user -->|"chooses documents"| node_localfiles

click node_app "https://github.com/mchandru13/mermaid-desk/blob/main/src/App.tsx"
click node_editor "https://github.com/mchandru13/mermaid-desk/blob/main/src/components/EditorPane.tsx"
click node_preview "https://github.com/mchandru13/mermaid-desk/blob/main/src/components/PreviewPane.tsx"
click node_tabs "https://github.com/mchandru13/mermaid-desk/blob/main/src/components/TabStrip.tsx"
click node_toolbar "https://github.com/mchandru13/mermaid-desk/blob/main/src/components/Toolbar.tsx"
click node_templates "https://github.com/mchandru13/mermaid-desk/blob/main/src/components/TemplateGallery.tsx"
click node_workspace "https://github.com/mchandru13/mermaid-desk/blob/main/src/state/workspace.ts"
click node_render "https://github.com/mchandru13/mermaid-desk/blob/main/src/lib/render.ts"
click node_export "https://github.com/mchandru13/mermaid-desk/blob/main/src/lib/export.ts"
click node_platform "https://github.com/mchandru13/mermaid-desk/blob/main/src/lib/platform.ts"
click node_editorconfig "https://github.com/mchandru13/mermaid-desk/blob/main/src/lib/monaco.ts"
click node_tauri "https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/lib.rs"
click node_documents "https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/documents.rs"
click node_clipboard "https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/clipboard.rs"
click node_menu "https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/menu.rs"
click node_settings "https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/settings.rs"
click node_session "https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/session.rs"

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_app,node_editor,node_preview,node_tabs,node_toolbar,node_templates,node_user toneBlue
class node_workspace,node_render,node_export,node_platform,node_editorconfig,node_localfiles toneAmber
class node_tauri,node_documents,node_clipboard,node_menu toneMint
class node_settings,node_session toneRose
```

## Components

### Editing UI

- [App coordinator](https://github.com/mchandru13/mermaid-desk/blob/main/src/App.tsx): `src/App.tsx`
- [Monaco editor](https://github.com/mchandru13/mermaid-desk/blob/main/src/components/EditorPane.tsx): `src/components/EditorPane.tsx`
- [Diagram preview](https://github.com/mchandru13/mermaid-desk/blob/main/src/components/PreviewPane.tsx): `src/components/PreviewPane.tsx`
- [Tab strip](https://github.com/mchandru13/mermaid-desk/blob/main/src/components/TabStrip.tsx): `src/components/TabStrip.tsx`
- [Toolbar](https://github.com/mchandru13/mermaid-desk/blob/main/src/components/Toolbar.tsx): `src/components/Toolbar.tsx`
- [Template gallery](https://github.com/mchandru13/mermaid-desk/blob/main/src/components/TemplateGallery.tsx): `src/components/TemplateGallery.tsx`

### Workspace Services

- [Workspace state](https://github.com/mchandru13/mermaid-desk/blob/main/src/state/workspace.ts): `src/state/workspace.ts`
- [Mermaid renderer](https://github.com/mchandru13/mermaid-desk/blob/main/src/lib/render.ts): `src/lib/render.ts`
- [Export helpers](https://github.com/mchandru13/mermaid-desk/blob/main/src/lib/export.ts): `src/lib/export.ts`
- [Platform adapter](https://github.com/mchandru13/mermaid-desk/blob/main/src/lib/platform.ts): `src/lib/platform.ts`
- [Editor language setup](https://github.com/mchandru13/mermaid-desk/blob/main/src/lib/monaco.ts): `src/lib/monaco.ts`

### Desktop Services

- [Tauri command host](https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [Document file access](https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/documents.rs): `src-tauri/src/documents.rs`
- [Image clipboard](https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/clipboard.rs): `src-tauri/src/clipboard.rs`
- [Native menu](https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/menu.rs): `src-tauri/src/menu.rs`

### Local State

- [App settings](https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/settings.rs): `src-tauri/src/settings.rs`
- [Session recovery](https://github.com/mchandru13/mermaid-desk/blob/main/src-tauri/src/session.rs): `src-tauri/src/session.rs`

### Other components

- **Diagram user**
- **User files**

## Connections

- Diagram user → App coordinator: operates (evidence: `README.md`)
- App coordinator → Workspace state: coordinates (evidence: `src/App.tsx`)
- App coordinator → Mermaid renderer: renders diagrams (evidence: `src/App.tsx`)
- App coordinator → Monaco editor: shows editor (evidence: `src/App.tsx`)
- App coordinator → Diagram preview: shows preview (evidence: `src/App.tsx`)
- App coordinator → Tab strip: shows tabs (evidence: `src/App.tsx`)
- App coordinator → Toolbar: shows controls (evidence: `src/App.tsx`)
- App coordinator → Template gallery: opens gallery (evidence: `src/App.tsx`)
- Monaco editor → Editor language setup: configures editor (evidence: `src/components/EditorPane.tsx`)
- Diagram preview → Mermaid renderer: measures SVG (evidence: `src/components/PreviewPane.tsx`)
- Workspace state → Platform adapter: uses platform (evidence: `src/state/workspace.ts`)
- Workspace state → Export helpers: rasterizes exports (evidence: `src/state/workspace.ts`)
- Workspace state → Session recovery: saves recovery (evidence: `README.md`)
- Workspace state → App settings: persists preferences (evidence: `README.md`)
- Platform adapter → Tauri command host: invokes commands (evidence: `README.md`)
- Tauri command host → Document file access: registers commands (evidence: `src-tauri/src/lib.rs`)
- Tauri command host → Image clipboard: registers command (evidence: `src-tauri/src/lib.rs`)
- Tauri command host → Session recovery: registers commands (evidence: `src-tauri/src/lib.rs`)
- Tauri command host → App settings: registers commands (evidence: `src-tauri/src/lib.rs`)
- Tauri command host → Native menu: installs menu (evidence: `src-tauri/src/lib.rs`)
- Document file access → User files: reads and writes (evidence: `README.md`)
- App settings → User files: stores JSON (evidence: `README.md`)
- Session recovery → User files: journals session (evidence: `README.md`)
- Diagram user → User files: chooses documents (evidence: `README.md`)
