# des86532/markdown-quick-preview architecture

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

- Interactive diagram: https://gitdiagram.com/des86532/markdown-quick-preview
- Repository: https://github.com/des86532/markdown-quick-preview

## Overview

Markdown Quick Preview is a Chrome/Edge extension for turning pasted Markdown, URLs, and GitHub repository links into temporary preview tabs. The popup classifies input, saves pasted text when needed, and opens the viewer; the viewer fetches and organizes GitHub documents or loads URL/paste content, then renders Markdown or Mermaid. Users can save previews as quick links and configure GitHub token rules. The graph follows documented capabilities and sampled calls; external fetch details not visible in source excerpts are documented by the README.

Main entry points: [`src/viewer/main.ts`](https://github.com/des86532/markdown-quick-preview/blob/main/src/viewer/main.ts) (Preview and navigation), [`src/popup/main.ts`](https://github.com/des86532/markdown-quick-preview/blob/main/src/popup/main.ts) (Input and quick links), [`src/lib/github.ts`](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/github.ts) (GitHub tree and files), [`src/lib/storage.ts`](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/storage.ts) (Paste and token storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Extension entry points"]
  node_popup["Input and quick links<br/>[main.ts]"]
  node_options["Token settings UI<br/>[main.ts]"]
end

subgraph group_content["Preview content workflow"]
  node_viewer["Preview and navigation<br/>[main.ts]"]
  node_input_detection["Input classification<br/>[detect.ts]"]
  node_github_tree["GitHub tree and files<br/>[github.ts]"]
  node_book["Document tree ordering<br/>[book.ts]"]
  node_renderer["Markdown and Mermaid<br/>[render.ts]"]
end

subgraph group_persistence["Local persistence"]
  node_paste_storage[("Paste and token storage<br/>[storage.ts]")]
  node_quick_links[("Quick links<br/>[links.ts]")]
end

subgraph group_settings["GitHub credentials"]
  node_token_rules["Token matching and validation<br/>[tokens.ts]"]
end

node_user(("Extension user"))
node_github_api{{"GitHub API"}}
node_raw_host{{"Raw GitHub files"}}
node_user_url{{"User-supplied HTTP URL"}}
node_markdown_result["Rendered document"]

node_user -->|"enters input"| node_popup
node_popup -->|"classifies input"| node_input_detection
node_popup -->|"saves pasted text"| node_paste_storage
node_popup -->|"opens preview tab"| node_viewer
node_popup -->|"lists and deletes"| node_quick_links
node_viewer -->|"loads paste"| node_paste_storage
node_viewer -->|"loads repository content"| node_github_tree
node_github_tree -->|"requests tree and files"| node_github_api
node_github_tree -->|"fetches raw file"| node_raw_host
node_viewer -.->|"fetches requested URL"| node_user_url
node_viewer -->|"builds document tree"| node_book
node_viewer -->|"renders selected content"| node_renderer
node_renderer -->|"produces preview"| node_markdown_result
node_viewer -->|"saves and checks links"| node_quick_links
node_user -->|"configures tokens"| node_options
node_options -->|"validates rules"| node_token_rules
node_options -->|"loads and saves rules"| node_paste_storage
node_paste_storage -->|"stores typed rules"| node_token_rules
node_github_tree -->|"loads token rules"| node_paste_storage
node_github_tree -->|"selects matching token"| node_token_rules

click node_popup "https://github.com/des86532/markdown-quick-preview/blob/main/src/popup/main.ts"
click node_options "https://github.com/des86532/markdown-quick-preview/blob/main/src/options/main.ts"
click node_viewer "https://github.com/des86532/markdown-quick-preview/blob/main/src/viewer/main.ts"
click node_input_detection "https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/detect.ts"
click node_github_tree "https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/github.ts"
click node_book "https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/book.ts"
click node_renderer "https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/render.ts"
click node_paste_storage "https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/storage.ts"
click node_quick_links "https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/links.ts"
click node_token_rules "https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/tokens.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_popup,node_options,node_user,node_user_url toneBlue
class node_viewer,node_input_detection,node_github_tree,node_book,node_renderer toneAmber
class node_paste_storage,node_quick_links,node_github_api toneMint
class node_token_rules toneRose
class node_raw_host,node_markdown_result toneIndigo
```

## Components

### Extension entry points

- [Input and quick links](https://github.com/des86532/markdown-quick-preview/blob/main/src/popup/main.ts): `src/popup/main.ts`
- [Token settings UI](https://github.com/des86532/markdown-quick-preview/blob/main/src/options/main.ts): `src/options/main.ts`

### Preview content workflow

- [Preview and navigation](https://github.com/des86532/markdown-quick-preview/blob/main/src/viewer/main.ts): `src/viewer/main.ts`
- [Input classification](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/detect.ts): `src/lib/detect.ts`
- [GitHub tree and files](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/github.ts): `src/lib/github.ts`
- [Document tree ordering](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/book.ts): `src/lib/book.ts`
- [Markdown and Mermaid](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/render.ts): `src/lib/render.ts`

### Local persistence

- [Paste and token storage](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/storage.ts): `src/lib/storage.ts`
- [Quick links](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/links.ts): `src/lib/links.ts`

### GitHub credentials

- [Token matching and validation](https://github.com/des86532/markdown-quick-preview/blob/main/src/lib/tokens.ts): `src/lib/tokens.ts`

### Other components

- **Extension user**
- **GitHub API**
- **Raw GitHub files**
- **User-supplied HTTP URL**
- **Rendered document**

## Connections

- Extension user → Input and quick links: enters input (evidence: `src/popup/main.ts`)
- Input and quick links → Input classification: classifies input (evidence: `src/popup/main.ts`)
- Input and quick links → Paste and token storage: saves pasted text (evidence: `src/popup/main.ts`)
- Input and quick links → Preview and navigation: opens preview tab (evidence: `src/popup/main.ts`)
- Input and quick links → Quick links: lists and deletes (evidence: `src/popup/main.ts`)
- Preview and navigation → Paste and token storage: loads paste (evidence: `src/viewer/main.ts`)
- Preview and navigation → GitHub tree and files: loads repository content (evidence: `src/viewer/main.ts`)
- GitHub tree and files → GitHub API: requests tree and files (evidence: `src/lib/github.ts`)
- GitHub tree and files → Raw GitHub files: fetches raw file (evidence: `src/lib/github.ts`)
- Preview and navigation → User-supplied HTTP URL: fetches requested URL (evidence: `README.md`)
- Preview and navigation → Document tree ordering: builds document tree (evidence: `src/viewer/main.ts`)
- Preview and navigation → Markdown and Mermaid: renders selected content (evidence: `src/viewer/main.ts`)
- Markdown and Mermaid → Rendered document: produces preview (evidence: `src/lib/render.ts`)
- Preview and navigation → Quick links: saves and checks links (evidence: `src/viewer/main.ts`)
- Extension user → Token settings UI: configures tokens (evidence: `src/options/main.ts`)
- Token settings UI → Token matching and validation: validates rules (evidence: `src/options/main.ts`)
- Token settings UI → Paste and token storage: loads and saves rules (evidence: `src/options/main.ts`)
- Paste and token storage → Token matching and validation: stores typed rules (evidence: `src/lib/storage.ts`)
- GitHub tree and files → Paste and token storage: loads token rules (evidence: `src/lib/github.ts`)
- GitHub tree and files → Token matching and validation: selects matching token (evidence: `src/lib/github.ts`)
