# suptimio/liveview architecture

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

- Interactive diagram: https://gitdiagram.com/suptimio/liveview
- Repository: https://github.com/suptimio/liveview

## Overview

Viewlife is a VS Code custom editor for Markdown. The principal workflow is opening a Markdown document, rendering it in an editable webview, and sending edits back to the VS Code document so normal saving and undo apply. The webview also supports tables, styling and PDF export. Edges reflect calls visible in excerpts or capabilities documented in the README; unsampled stylesheet and message handling are represented only where documented, so some connections are omitted.

Main entry points: [`webview/src/main.ts`](https://github.com/suptimio/liveview/blob/main/webview/src/main.ts) (Live edit workflow), [`src/extension.ts`](https://github.com/suptimio/liveview/blob/main/src/extension.ts) (Custom editor host), [`webview/src/vdom.ts`](https://github.com/suptimio/liveview/blob/main/webview/src/vdom.ts) (DOM patching), [`webview/src/markdown.ts`](https://github.com/suptimio/liveview/blob/main/webview/src/markdown.ts) (Markdown parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vscode["VS Code integration"]
  node_extension["Custom editor host<br/>[extension.ts]"]
  node_webview["Editor webview<br/>[main.ts]"]
end

subgraph group_editing["Markdown editing"]
  node_editor["Live edit workflow<br/>[main.ts]"]
  node_selection["Selection handling<br/>[selection.ts]"]
  node_markdown["Markdown parser<br/>[markdown.ts]"]
  node_vdom["DOM patching<br/>[vdom.ts]"]
  node_preview["Inline previews and tables<br/>[preview.ts]"]
end

subgraph group_presentation["Rendering and styles"]
  node_profiles["Render profiles<br/>[profiles.ts]"]
  node_theme["Theme selection<br/>[theme.ts]"]
  node_paperstyles["Paper styles<br/>[style.css]"]
  node_uistyles["Editor UI styles<br/>[ui.css]"]
  node_customcss["Custom stylesheets<br/>[extension.ts]"]
end

subgraph group_output["Export"]
  node_pdf["PDF generation<br/>[exporter.ts]"]
end

node_user(("Markdown author"))
node_vscode["VS Code"]
node_document["Markdown document"]
node_filesystem[("Workspace files")]

node_user -->|"opens Markdown"| node_vscode
node_vscode -->|"routes editor"| node_extension
node_extension -->|"reads and edits"| node_document
node_extension -->|"hosts"| node_webview
node_webview -->|"runs"| node_editor
node_editor -->|"parses source"| node_markdown
node_editor -->|"reads selection"| node_selection
node_editor -->|"patches DOM"| node_vdom
node_markdown -->|"produces nodes"| node_vdom
node_vdom -->|"patches previews"| node_preview
node_preview -.->|"dispatches table edits"| node_editor
node_editor -->|"sends edits"| node_document
node_document -->|"refreshes content"| node_editor
node_editor -->|"sets profile"| node_profiles
node_editor -->|"sets theme"| node_theme
node_profiles -.->|"selects overrides"| node_paperstyles
node_editor -.->|"requests stylesheets"| node_customcss
node_customcss -->|"reads CSS"| node_filesystem
node_editor -->|"starts export"| node_pdf
node_pdf -.->|"sends PDF"| node_extension
node_extension -.->|"saves PDF"| node_filesystem

click node_extension "https://github.com/suptimio/liveview/blob/main/src/extension.ts"
click node_webview "https://github.com/suptimio/liveview/blob/main/webview/src/main.ts"
click node_editor "https://github.com/suptimio/liveview/blob/main/webview/src/main.ts"
click node_selection "https://github.com/suptimio/liveview/blob/main/webview/src/selection.ts"
click node_markdown "https://github.com/suptimio/liveview/blob/main/webview/src/markdown.ts"
click node_vdom "https://github.com/suptimio/liveview/blob/main/webview/src/vdom.ts"
click node_preview "https://github.com/suptimio/liveview/blob/main/webview/src/preview.ts"
click node_profiles "https://github.com/suptimio/liveview/blob/main/webview/src/profiles.ts"
click node_theme "https://github.com/suptimio/liveview/blob/main/webview/src/theme.ts"
click node_paperstyles "https://github.com/suptimio/liveview/blob/main/webview/src/style.css"
click node_uistyles "https://github.com/suptimio/liveview/blob/main/webview/src/ui.css"
click node_customcss "https://github.com/suptimio/liveview/blob/main/src/extension.ts"
click node_pdf "https://github.com/suptimio/liveview/blob/main/webview/src/exporter.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_webview toneBlue
class node_editor,node_selection,node_markdown,node_vdom,node_preview,node_filesystem toneAmber
class node_profiles,node_theme,node_paperstyles,node_uistyles,node_customcss toneMint
class node_pdf toneRose
class node_user,node_vscode,node_document toneIndigo
```

## Components

### VS Code integration

- [Custom editor host](https://github.com/suptimio/liveview/blob/main/src/extension.ts): `src/extension.ts`
- [Editor webview](https://github.com/suptimio/liveview/blob/main/webview/src/main.ts): `webview/src/main.ts`

### Markdown editing

- [Live edit workflow](https://github.com/suptimio/liveview/blob/main/webview/src/main.ts): `webview/src/main.ts`
- [Selection handling](https://github.com/suptimio/liveview/blob/main/webview/src/selection.ts): `webview/src/selection.ts`
- [Markdown parser](https://github.com/suptimio/liveview/blob/main/webview/src/markdown.ts): `webview/src/markdown.ts`
- [DOM patching](https://github.com/suptimio/liveview/blob/main/webview/src/vdom.ts): `webview/src/vdom.ts`
- [Inline previews and tables](https://github.com/suptimio/liveview/blob/main/webview/src/preview.ts): `webview/src/preview.ts`

### Rendering and styles

- [Render profiles](https://github.com/suptimio/liveview/blob/main/webview/src/profiles.ts): `webview/src/profiles.ts`
- [Theme selection](https://github.com/suptimio/liveview/blob/main/webview/src/theme.ts): `webview/src/theme.ts`
- [Paper styles](https://github.com/suptimio/liveview/blob/main/webview/src/style.css): `webview/src/style.css`
- [Editor UI styles](https://github.com/suptimio/liveview/blob/main/webview/src/ui.css): `webview/src/ui.css`
- [Custom stylesheets](https://github.com/suptimio/liveview/blob/main/src/extension.ts): `src/extension.ts`

### Export

- [PDF generation](https://github.com/suptimio/liveview/blob/main/webview/src/exporter.ts): `webview/src/exporter.ts`

### Other components

- **Markdown author**
- **VS Code**
- **Markdown document**
- **Workspace files**

## Connections

- Markdown author → VS Code: opens Markdown (evidence: `README.md`)
- VS Code → Custom editor host: routes editor (evidence: `src/extension.ts`)
- Custom editor host → Markdown document: reads and edits (evidence: `src/extension.ts`)
- Custom editor host → Editor webview: hosts (evidence: `src/extension.ts`)
- Editor webview → Live edit workflow: runs (evidence: `webview/src/main.ts`)
- Live edit workflow → Markdown parser: parses source (evidence: `webview/src/main.ts`)
- Live edit workflow → Selection handling: reads selection (evidence: `webview/src/main.ts`)
- Live edit workflow → DOM patching: patches DOM (evidence: `webview/src/main.ts`)
- Markdown parser → DOM patching: produces nodes (evidence: `webview/src/markdown.ts`)
- DOM patching → Inline previews and tables: patches previews (evidence: `webview/src/vdom.ts`)
- Inline previews and tables → Live edit workflow: dispatches table edits
- Live edit workflow → Markdown document: sends edits (evidence: `README.md`)
- Markdown document → Live edit workflow: refreshes content
- Live edit workflow → Render profiles: sets profile (evidence: `webview/src/main.ts`)
- Live edit workflow → Theme selection: sets theme (evidence: `webview/src/main.ts`)
- Render profiles → Paper styles: selects overrides
- Live edit workflow → Custom stylesheets: requests stylesheets
- Custom stylesheets → Workspace files: reads CSS (evidence: `src/extension.ts`)
- Live edit workflow → PDF generation: starts export (evidence: `webview/src/main.ts`)
- PDF generation → Custom editor host: sends PDF
- Custom editor host → Workspace files: saves PDF
