# suptimio/viewlive architecture

> Architecture diagram of the GitHub repository suptimio/viewlive, 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/suptimio/viewlive
- Repository: https://github.com/suptimio/viewlive

## Overview

ViewLive is a VS Code extension that opens Markdown files in a live WYSIWYG editor. The main workflow is: a VS Code user opens a Markdown file, the extension presents the editor, webview code parses and renders Markdown, and edits are written back to the file. Editing also includes table and list actions; separate branches handle links, PDF export, styles and themes, and saved preferences. The graph uses the sampled entry point and module references; some extension-to-webview wiring and unsampled subsystem internals are documented by the README rather than shown in source excerpts.

Main entry points: [`webview/src/main.ts`](https://github.com/suptimio/viewlive/blob/main/webview/src/main.ts) (Webview entry), [`src/extension.ts`](https://github.com/suptimio/viewlive/blob/main/src/extension.ts) (Extension host), [`webview/src/host/host.ts`](https://github.com/suptimio/viewlive/blob/main/webview/src/host/host.ts) (Host messaging), [`webview/src/editor/editor.ts`](https://github.com/suptimio/viewlive/blob/main/webview/src/editor/editor.ts) (WYSIWYG editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["VS Code Extension"]
  node_extension["Extension host<br/>[extension.ts]"]
end

subgraph group_editing["Markdown Editing"]
  node_webview["Webview entry<br/>[main.ts]"]
  node_editor["WYSIWYG editor<br/>[editor.ts]"]
  node_markdown["Markdown parser<br/>[markdown.ts]"]
  node_preview["Inline previews<br/>[preview.ts]"]
  node_actions["List actions<br/>[list.ts]"]
  node_tables["Table editing<br/>[table.ts]"]
  node_links["Link handling<br/>[links.ts]"]
  node_completion["Link completion<br/>[link-completion.ts]"]
end

subgraph group_presentation["Paper and UI"]
  node_stylemenu["Styles workbench<br/>[style-menu.ts]"]
  node_profiles["Style profiles<br/>[profiles.ts]"]
  node_theme["Theme handling<br/>[theme.ts]"]
  node_toolbar["Toolbar<br/>[toolbar.ts]"]
  node_toolmenu["Action menu<br/>[tool-menu.ts]"]
  node_stylesheets["Paper styles<br/>[style.css]"]
end

subgraph group_services["Host Services"]
  node_host["Host messaging<br/>[host.ts]"]
  node_preferences["Preferences<br/>[preferences.ts]"]
  node_exporter["PDF export<br/>[exporter.ts]"]
end

node_user(("VS Code user"))

node_user -->|"opens Markdown"| node_extension
node_extension -->|"opens editor"| node_webview
node_webview -->|"creates editor"| node_editor
node_webview -->|"creates parser"| node_markdown
node_editor -->|"parses source"| node_markdown
node_markdown -->|"renders nodes"| node_preview
node_webview -->|"sets up menu"| node_toolmenu
node_toolmenu -.->|"runs actions"| node_tables
node_toolmenu -.->|"runs actions"| node_actions
node_preview -->|"dispatches edits"| node_tables
node_tables -->|"sorts rows"| node_actions
node_webview -->|"sets up links"| node_links
node_webview -->|"sets up completion"| node_completion
node_editor -->|"sends edits"| node_host
node_webview -->|"handles messages"| node_host
node_host -->|"exchanges messages"| node_extension
node_extension -->|"writes file edits"| node_extension
node_webview -->|"loads preferences"| node_preferences
node_preferences -->|"posts updates"| node_host
node_webview -->|"sets up export"| node_exporter
node_exporter -->|"sends PDF"| node_host
node_webview -->|"sets up styles"| node_stylemenu
node_stylemenu -->|"selects profile"| node_profiles
node_webview -->|"sets theme"| node_theme
node_webview -->|"sets up toolbar"| node_toolbar
node_stylemenu -.->|"applies CSS"| node_stylesheets

click node_extension "https://github.com/suptimio/viewlive/blob/main/src/extension.ts"
click node_webview "https://github.com/suptimio/viewlive/blob/main/webview/src/main.ts"
click node_editor "https://github.com/suptimio/viewlive/blob/main/webview/src/editor/editor.ts"
click node_markdown "https://github.com/suptimio/viewlive/blob/main/webview/src/editor/markdown.ts"
click node_preview "https://github.com/suptimio/viewlive/blob/main/webview/src/editor/preview.ts"
click node_actions "https://github.com/suptimio/viewlive/blob/main/webview/src/actions/list.ts"
click node_tables "https://github.com/suptimio/viewlive/blob/main/webview/src/actions/table.ts"
click node_links "https://github.com/suptimio/viewlive/blob/main/webview/src/editor/links.ts"
click node_completion "https://github.com/suptimio/viewlive/blob/main/webview/src/editor/link-completion.ts"
click node_host "https://github.com/suptimio/viewlive/blob/main/webview/src/host/host.ts"
click node_preferences "https://github.com/suptimio/viewlive/blob/main/webview/src/host/preferences.ts"
click node_exporter "https://github.com/suptimio/viewlive/blob/main/webview/src/host/exporter.ts"
click node_stylemenu "https://github.com/suptimio/viewlive/blob/main/webview/src/ui/style-menu.ts"
click node_profiles "https://github.com/suptimio/viewlive/blob/main/webview/src/paper/profiles.ts"
click node_theme "https://github.com/suptimio/viewlive/blob/main/webview/src/paper/theme.ts"
click node_toolbar "https://github.com/suptimio/viewlive/blob/main/webview/src/ui/toolbar.ts"
click node_toolmenu "https://github.com/suptimio/viewlive/blob/main/webview/src/ui/tool-menu.ts"
click node_stylesheets "https://github.com/suptimio/viewlive/blob/main/webview/src/paper/style.css"

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_user toneBlue
class node_webview,node_editor,node_markdown,node_preview,node_actions,node_tables,node_links,node_completion toneAmber
class node_stylemenu,node_profiles,node_theme,node_toolbar,node_toolmenu,node_stylesheets toneMint
class node_host,node_preferences,node_exporter toneRose
```

## Components

### VS Code Extension

- [Extension host](https://github.com/suptimio/viewlive/blob/main/src/extension.ts): `src/extension.ts`

### Markdown Editing

- [Webview entry](https://github.com/suptimio/viewlive/blob/main/webview/src/main.ts): `webview/src/main.ts`
- [WYSIWYG editor](https://github.com/suptimio/viewlive/blob/main/webview/src/editor/editor.ts): `webview/src/editor/editor.ts`
- [Markdown parser](https://github.com/suptimio/viewlive/blob/main/webview/src/editor/markdown.ts): `webview/src/editor/markdown.ts`
- [Inline previews](https://github.com/suptimio/viewlive/blob/main/webview/src/editor/preview.ts): `webview/src/editor/preview.ts`
- [List actions](https://github.com/suptimio/viewlive/blob/main/webview/src/actions/list.ts): `webview/src/actions/list.ts`
- [Table editing](https://github.com/suptimio/viewlive/blob/main/webview/src/actions/table.ts): `webview/src/actions/table.ts`
- [Link handling](https://github.com/suptimio/viewlive/blob/main/webview/src/editor/links.ts): `webview/src/editor/links.ts`
- [Link completion](https://github.com/suptimio/viewlive/blob/main/webview/src/editor/link-completion.ts): `webview/src/editor/link-completion.ts`

### Paper and UI

- [Styles workbench](https://github.com/suptimio/viewlive/blob/main/webview/src/ui/style-menu.ts): `webview/src/ui/style-menu.ts`
- [Style profiles](https://github.com/suptimio/viewlive/blob/main/webview/src/paper/profiles.ts): `webview/src/paper/profiles.ts`
- [Theme handling](https://github.com/suptimio/viewlive/blob/main/webview/src/paper/theme.ts): `webview/src/paper/theme.ts`
- [Toolbar](https://github.com/suptimio/viewlive/blob/main/webview/src/ui/toolbar.ts): `webview/src/ui/toolbar.ts`
- [Action menu](https://github.com/suptimio/viewlive/blob/main/webview/src/ui/tool-menu.ts): `webview/src/ui/tool-menu.ts`
- [Paper styles](https://github.com/suptimio/viewlive/blob/main/webview/src/paper/style.css): `webview/src/paper/style.css`

### Host Services

- [Host messaging](https://github.com/suptimio/viewlive/blob/main/webview/src/host/host.ts): `webview/src/host/host.ts`
- [Preferences](https://github.com/suptimio/viewlive/blob/main/webview/src/host/preferences.ts): `webview/src/host/preferences.ts`
- [PDF export](https://github.com/suptimio/viewlive/blob/main/webview/src/host/exporter.ts): `webview/src/host/exporter.ts`

### Other components

- **VS Code user**

## Connections

- VS Code user → Extension host: opens Markdown (evidence: `README.md`)
- Extension host → Webview entry: opens editor (evidence: `README.md`)
- Webview entry → WYSIWYG editor: creates editor (evidence: `webview/src/main.ts`)
- Webview entry → Markdown parser: creates parser (evidence: `webview/src/main.ts`)
- WYSIWYG editor → Markdown parser: parses source (evidence: `webview/src/editor/editor.ts`)
- Markdown parser → Inline previews: renders nodes
- Webview entry → Action menu: sets up menu (evidence: `webview/src/main.ts`)
- Action menu → Table editing: runs actions
- Action menu → List actions: runs actions
- Inline previews → Table editing: dispatches edits (evidence: `webview/src/editor/preview.ts`)
- Table editing → List actions: sorts rows (evidence: `webview/src/actions/table.ts`)
- Webview entry → Link handling: sets up links (evidence: `webview/src/main.ts`)
- Webview entry → Link completion: sets up completion (evidence: `webview/src/main.ts`)
- WYSIWYG editor → Host messaging: sends edits (evidence: `webview/src/editor/editor.ts`)
- Webview entry → Host messaging: handles messages (evidence: `webview/src/main.ts`)
- Host messaging → Extension host: exchanges messages (evidence: `webview/src/host/host.ts`)
- Extension host → Extension host: writes file edits (evidence: `README.md`)
- Webview entry → Preferences: loads preferences (evidence: `webview/src/main.ts`)
- Preferences → Host messaging: posts updates (evidence: `webview/src/host/preferences.ts`)
- Webview entry → PDF export: sets up export (evidence: `webview/src/main.ts`)
- PDF export → Host messaging: sends PDF (evidence: `webview/src/main.ts`)
- Webview entry → Styles workbench: sets up styles (evidence: `webview/src/main.ts`)
- Styles workbench → Style profiles: selects profile (evidence: `webview/src/ui/style-menu.ts`)
- Webview entry → Theme handling: sets theme (evidence: `webview/src/main.ts`)
- Webview entry → Toolbar: sets up toolbar (evidence: `webview/src/main.ts`)
- Styles workbench → Paper styles: applies CSS
