# revuls/web-to-ai architecture

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

- Interactive diagram: https://gitdiagram.com/revuls/web-to-ai
- Repository: https://github.com/revuls/web-to-ai

## Overview

Web to AI Context is a Chrome extension that turns the active page into AI-ready Markdown. The popup requests extraction from the page script; that script clones the document, extracts readable article content, converts it to Markdown, and adds metadata. The popup estimates tokens and lets users copy or download the result, while keeping persistent local history for later copying or deletion. The main runtime flow is visible in the sampled scripts; the popup UI and extension configuration are included based on the README and file tree.

Main entry points: [`popup.js`](https://github.com/revuls/web-to-ai/blob/main/popup.js) (Popup Controller), [`content.js`](https://github.com/revuls/web-to-ai/blob/main/content.js) (Page Extractor), [`popup.html`](https://github.com/revuls/web-to-ai/blob/main/popup.html) (Popup Controls), [`lib/readability.js`](https://github.com/revuls/web-to-ai/blob/main/lib/readability.js) (Article Extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Popup Interface"]
  node_popup_ui["Popup Controls<br/>[popup.html]"]
  node_popup_logic["Popup Controller<br/>[popup.js]"]
end

subgraph group_processing["Page Processing"]
  node_page_script["Page Extractor<br/>[content.js]"]
  node_readability["Article Extraction<br/>[readability.js]"]
  node_turndown["Markdown Conversion<br/>[turndown.js]"]
end

subgraph group_outputs["Results and History"]
  node_clipboard["System Clipboard"]
  node_markdown_file["Markdown Download"]
  node_history[("Local History<br/>[popup.js]")]
end

node_user(("Extension User"))

node_user -->|"opens"| node_popup_ui
node_popup_ui -->|"uses"| node_popup_logic
node_popup_logic -->|"requests extraction"| node_page_script
node_page_script -->|"extracts article"| node_readability
node_page_script -->|"converts content"| node_turndown
node_popup_logic -->|"copies Markdown"| node_clipboard
node_popup_logic -->|"downloads Markdown"| node_markdown_file
node_popup_logic -->|"reads and writes"| node_history
node_user -->|"manages history"| node_popup_logic

click node_popup_ui "https://github.com/revuls/web-to-ai/blob/main/popup.html"
click node_popup_logic "https://github.com/revuls/web-to-ai/blob/main/popup.js"
click node_page_script "https://github.com/revuls/web-to-ai/blob/main/content.js"
click node_readability "https://github.com/revuls/web-to-ai/blob/main/lib/readability.js"
click node_turndown "https://github.com/revuls/web-to-ai/blob/main/lib/turndown.js"
click node_history "https://github.com/revuls/web-to-ai/blob/main/popup.js"

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_ui,node_popup_logic,node_user toneBlue
class node_page_script,node_readability,node_turndown toneAmber
class node_clipboard,node_markdown_file,node_history toneMint
```

## Components

### Popup Interface

- [Popup Controls](https://github.com/revuls/web-to-ai/blob/main/popup.html): `popup.html`
- [Popup Controller](https://github.com/revuls/web-to-ai/blob/main/popup.js): `popup.js`

### Page Processing

- [Page Extractor](https://github.com/revuls/web-to-ai/blob/main/content.js): `content.js`
- [Article Extraction](https://github.com/revuls/web-to-ai/blob/main/lib/readability.js): `lib/readability.js`
- [Markdown Conversion](https://github.com/revuls/web-to-ai/blob/main/lib/turndown.js): `lib/turndown.js`

### Results and History

- **System Clipboard**
- **Markdown Download**
- [Local History](https://github.com/revuls/web-to-ai/blob/main/popup.js): `popup.js`

### Other components

- **Extension User**

## Connections

- Extension User → Popup Controls: opens (evidence: `README.md`)
- Popup Controls → Popup Controller: uses (evidence: `README.md`)
- Popup Controller → Page Extractor: requests extraction (evidence: `popup.js`)
- Page Extractor → Article Extraction: extracts article (evidence: `content.js`)
- Page Extractor → Markdown Conversion: converts content (evidence: `content.js`)
- Popup Controller → System Clipboard: copies Markdown (evidence: `popup.js`)
- Popup Controller → Markdown Download: downloads Markdown (evidence: `popup.js`)
- Popup Controller → Local History: reads and writes (evidence: `popup.js`)
- Extension User → Popup Controller: manages history (evidence: `README.md`)
