# jraversbcn21/snaplink architecture

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

- Interactive diagram: https://gitdiagram.com/jraversbcn21/snaplink
- Repository: https://github.com/jraversbcn21/snaplink

## Overview

SnapLink turns a page’s visible title and cleaned URL into a copyable link. The user can start from the popup, review or edit the title, and copy rich HTML/plain text or Markdown; alternatively, a keyboard shortcut requests a rich-link copy and displays a page toast. The content script detects platform-specific titles with generic fallbacks, while the popup also supports ticket-ID stripping and plain-URL copying. The graph separates those domain stages and the shortcut dispatcher. Source evidence shows the key calls; popup presentation details and some behavior are documented only in the README.

Main entry points: [`popup.js`](https://github.com/jraversbcn21/snaplink/blob/master/popup.js) (Popup controller), [`content.js`](https://github.com/jraversbcn21/snaplink/blob/master/content.js) (Title detection), [`popup.html`](https://github.com/jraversbcn21/snaplink/blob/master/popup.html) (Popup interface), [`background.js`](https://github.com/jraversbcn21/snaplink/blob/master/background.js) (Shortcut dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_popup_flow["Popup workflow"]
  node_popup_view["Popup interface<br/>[popup.html]"]
  node_popup_controller["Popup controller<br/>[popup.js]"]
  node_ticket_id_option["Ticket ID option<br/>[popup.js]"]
  node_markdown_option["Markdown option<br/>[popup.js]"]
end

subgraph group_page_processing["Page processing"]
  node_title_detection["Title detection<br/>[content.js]"]
  node_url_cleaning["URL cleaning<br/>[content.js]"]
  node_rich_link_writer["Rich link writer<br/>[content.js]"]
  node_page_toast["Page toast<br/>[content.js]"]
end

subgraph group_shortcut_flow["Shortcut workflow"]
  node_shortcut_dispatcher["Shortcut dispatcher<br/>[background.js]"]
end

node_user(("User"))
node_page_dom["Visible page DOM"]
node_clipboard["System clipboard"]
node_keyboard_shortcut(("Keyboard shortcut"))

node_user -->|"opens"| node_popup_view
node_popup_view -->|"drives"| node_popup_controller
node_popup_controller -->|"requests page info"| node_title_detection
node_page_dom -->|"provides visible text"| node_title_detection
node_title_detection -->|"returns cleaned URL"| node_url_cleaning
node_popup_controller -->|"applies option"| node_ticket_id_option
node_popup_controller -->|"applies format"| node_markdown_option
node_popup_controller -->|"writes copy"| node_clipboard
node_user -->|"presses"| node_keyboard_shortcut
node_keyboard_shortcut -->|"dispatches command"| node_shortcut_dispatcher
node_shortcut_dispatcher -->|"requests copy"| node_title_detection
node_title_detection -->|"supplies link data"| node_rich_link_writer
node_rich_link_writer -->|"writes HTML and text"| node_clipboard
node_rich_link_writer -->|"shows confirmation"| node_page_toast

click node_popup_view "https://github.com/jraversbcn21/snaplink/blob/master/popup.html"
click node_popup_controller "https://github.com/jraversbcn21/snaplink/blob/master/popup.js"
click node_ticket_id_option "https://github.com/jraversbcn21/snaplink/blob/master/popup.js"
click node_markdown_option "https://github.com/jraversbcn21/snaplink/blob/master/popup.js"
click node_title_detection "https://github.com/jraversbcn21/snaplink/blob/master/content.js"
click node_url_cleaning "https://github.com/jraversbcn21/snaplink/blob/master/content.js"
click node_rich_link_writer "https://github.com/jraversbcn21/snaplink/blob/master/content.js"
click node_page_toast "https://github.com/jraversbcn21/snaplink/blob/master/content.js"
click node_shortcut_dispatcher "https://github.com/jraversbcn21/snaplink/blob/master/background.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_view,node_popup_controller,node_ticket_id_option,node_markdown_option,node_user toneBlue
class node_title_detection,node_url_cleaning,node_rich_link_writer,node_page_toast toneAmber
class node_shortcut_dispatcher toneMint
class node_page_dom,node_clipboard,node_keyboard_shortcut toneIndigo
```

## Components

### Popup workflow

- [Popup interface](https://github.com/jraversbcn21/snaplink/blob/master/popup.html): `popup.html`
- [Popup controller](https://github.com/jraversbcn21/snaplink/blob/master/popup.js): `popup.js`
- [Ticket ID option](https://github.com/jraversbcn21/snaplink/blob/master/popup.js): `popup.js`
- [Markdown option](https://github.com/jraversbcn21/snaplink/blob/master/popup.js): `popup.js`

### Page processing

- [Title detection](https://github.com/jraversbcn21/snaplink/blob/master/content.js): `content.js`
- [URL cleaning](https://github.com/jraversbcn21/snaplink/blob/master/content.js): `content.js`
- [Rich link writer](https://github.com/jraversbcn21/snaplink/blob/master/content.js): `content.js`
- [Page toast](https://github.com/jraversbcn21/snaplink/blob/master/content.js): `content.js`

### Shortcut workflow

- [Shortcut dispatcher](https://github.com/jraversbcn21/snaplink/blob/master/background.js): `background.js`

### Other components

- **User**
- **Visible page DOM**
- **System clipboard**
- **Keyboard shortcut**

## Connections

- User → Popup interface: opens (evidence: `README.md`)
- Popup interface → Popup controller: drives (evidence: `README.md`)
- Popup controller → Title detection: requests page info (evidence: `popup.js`)
- Visible page DOM → Title detection: provides visible text (evidence: `content.js`)
- Title detection → URL cleaning: returns cleaned URL (evidence: `content.js`)
- Popup controller → Ticket ID option: applies option (evidence: `popup.js`)
- Popup controller → Markdown option: applies format (evidence: `popup.js`)
- Popup controller → System clipboard: writes copy (evidence: `popup.js`)
- User → Keyboard shortcut: presses (evidence: `README.md`)
- Keyboard shortcut → Shortcut dispatcher: dispatches command (evidence: `README.md`)
- Shortcut dispatcher → Title detection: requests copy (evidence: `background.js`)
- Title detection → Rich link writer: supplies link data (evidence: `content.js`)
- Rich link writer → System clipboard: writes HTML and text (evidence: `content.js`)
- Rich link writer → Page toast: shows confirmation (evidence: `content.js`)
