# jasminemo1110/x-digest architecture

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

- Interactive diagram: https://gitdiagram.com/jasminemo1110/x-digest
- Repository: https://github.com/jasminemo1110/x-digest

## Overview

X Digest is a local-first Chrome extension for turning a rendered X post or Article into bilingual reading, summaries, contextual language help, and saved learning material. Its main workflow starts with a reader opening Digest on an X post; the extension extracts the post, opens the side panel, and routes reading or learning requests through the background worker. Results can be saved to the local Library or Wordbook, searched, exported, or backed up. The graph includes the documented Article, excerpt-focus, backup, and reading-position capabilities; some internal routing is only documented, so those edges cite the README.

Main entry points: [`background.js`](https://github.com/jasminemo1110/x-digest/blob/main/background.js) (Message and action worker), [`sidepanel.js`](https://github.com/jasminemo1110/x-digest/blob/main/sidepanel.js) (Digest side panel), [`content.js`](https://github.com/jasminemo1110/x-digest/blob/main/content.js) (Post extraction), [`reader-state.js`](https://github.com/jasminemo1110/x-digest/blob/main/reader-state.js) (Reader position)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["X capture"]
  node_xpage["Rendered X page"]
  node_extract["Post extraction<br/>[content.js]"]
  node_sourcefocus["Excerpt source focus<br/>[content.js]"]
end

subgraph group_reading["Reading experience"]
  node_panel["Digest side panel<br/>[sidepanel.js]"]
  node_longread["Long Article reading<br/>[long-reading.js]"]
  node_readerstate["Reader position<br/>[reader-state.js]"]
end

subgraph group_worker["Background and AI"]
  node_workerbg["Message and action worker<br/>[background.js]"]
  node_aiactions["AI action shaping<br/>[ai-actions.js]"]
  node_aiprovider["DeepSeek provider<br/>[ai-provider.js]"]
  node_settings["API key settings<br/>[settings.js]"]
end

subgraph group_library["Local learning data"]
  node_learningdata["Learning data models<br/>[learning-data.js]"]
  node_localstore[("Chrome local storage")]
  node_libraryui["Library and Wordbook UI<br/>[sidepanel.js]"]
  node_backup["Backup and restore<br/>[backup-data.js]"]
end

node_reader(("X reader"))
node_deepseek["DeepSeek API"]

node_reader -->|"opens post"| node_xpage
node_xpage -->|"provides page"| node_extract
node_extract -->|"opens Digest"| node_workerbg
node_workerbg -->|"stores active post"| node_panel
node_panel -->|"requests actions"| node_workerbg
node_workerbg -->|"builds AI actions"| node_aiactions
node_workerbg -.->|"requests AI"| node_aiprovider
node_aiprovider -.->|"calls API"| node_deepseek
node_settings -->|"stores API key"| node_localstore
node_panel -->|"translates sections"| node_longread
node_workerbg -->|"summarizes Articles"| node_longread
node_panel -->|"updates position"| node_readerstate
node_readerstate -->|"persists position"| node_localstore
node_workerbg -->|"normalizes records"| node_learningdata
node_workerbg -->|"reads and writes"| node_localstore
node_panel -->|"renders collections"| node_libraryui
node_libraryui -->|"saves and searches"| node_workerbg
node_workerbg -->|"creates and merges"| node_backup
node_backup -->|"restores records"| node_localstore
node_libraryui -->|"opens saved excerpt"| node_sourcefocus
node_sourcefocus -->|"highlights source"| node_xpage

click node_extract "https://github.com/jasminemo1110/x-digest/blob/main/content.js"
click node_sourcefocus "https://github.com/jasminemo1110/x-digest/blob/main/content.js"
click node_panel "https://github.com/jasminemo1110/x-digest/blob/main/sidepanel.js"
click node_longread "https://github.com/jasminemo1110/x-digest/blob/main/long-reading.js"
click node_readerstate "https://github.com/jasminemo1110/x-digest/blob/main/reader-state.js"
click node_workerbg "https://github.com/jasminemo1110/x-digest/blob/main/background.js"
click node_aiactions "https://github.com/jasminemo1110/x-digest/blob/main/ai-actions.js"
click node_aiprovider "https://github.com/jasminemo1110/x-digest/blob/main/ai-provider.js"
click node_settings "https://github.com/jasminemo1110/x-digest/blob/main/settings.js"
click node_learningdata "https://github.com/jasminemo1110/x-digest/blob/main/learning-data.js"
click node_libraryui "https://github.com/jasminemo1110/x-digest/blob/main/sidepanel.js"
click node_backup "https://github.com/jasminemo1110/x-digest/blob/main/backup-data.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_xpage,node_extract,node_sourcefocus toneBlue
class node_panel,node_longread,node_readerstate toneAmber
class node_workerbg,node_aiactions,node_aiprovider,node_settings,node_deepseek toneMint
class node_learningdata,node_localstore,node_libraryui,node_backup toneRose
class node_reader toneIndigo
```

## Components

### X capture

- **Rendered X page**
- [Post extraction](https://github.com/jasminemo1110/x-digest/blob/main/content.js): `content.js`
- [Excerpt source focus](https://github.com/jasminemo1110/x-digest/blob/main/content.js): `content.js`

### Reading experience

- [Digest side panel](https://github.com/jasminemo1110/x-digest/blob/main/sidepanel.js): `sidepanel.js`
- [Long Article reading](https://github.com/jasminemo1110/x-digest/blob/main/long-reading.js): `long-reading.js`
- [Reader position](https://github.com/jasminemo1110/x-digest/blob/main/reader-state.js): `reader-state.js`

### Background and AI

- [Message and action worker](https://github.com/jasminemo1110/x-digest/blob/main/background.js): `background.js`
- [AI action shaping](https://github.com/jasminemo1110/x-digest/blob/main/ai-actions.js): `ai-actions.js`
- [DeepSeek provider](https://github.com/jasminemo1110/x-digest/blob/main/ai-provider.js): `ai-provider.js`
- [API key settings](https://github.com/jasminemo1110/x-digest/blob/main/settings.js): `settings.js`

### Local learning data

- [Learning data models](https://github.com/jasminemo1110/x-digest/blob/main/learning-data.js): `learning-data.js`
- **Chrome local storage**
- [Library and Wordbook UI](https://github.com/jasminemo1110/x-digest/blob/main/sidepanel.js): `sidepanel.js`
- [Backup and restore](https://github.com/jasminemo1110/x-digest/blob/main/backup-data.js): `backup-data.js`

### Other components

- **X reader**
- **DeepSeek API**

## Connections

- X reader → Rendered X page: opens post (evidence: `README.md`)
- Rendered X page → Post extraction: provides page (evidence: `README.md`)
- Post extraction → Message and action worker: opens Digest (evidence: `content.js`)
- Message and action worker → Digest side panel: stores active post (evidence: `background.js`)
- Digest side panel → Message and action worker: requests actions (evidence: `sidepanel.js`)
- Message and action worker → AI action shaping: builds AI actions (evidence: `background.js`)
- Message and action worker → DeepSeek provider: requests AI
- DeepSeek provider → DeepSeek API: calls API
- API key settings → Chrome local storage: stores API key (evidence: `README.md`)
- Digest side panel → Long Article reading: translates sections (evidence: `sidepanel.js`)
- Message and action worker → Long Article reading: summarizes Articles (evidence: `background.js`)
- Digest side panel → Reader position: updates position (evidence: `sidepanel.js`)
- Reader position → Chrome local storage: persists position
- Message and action worker → Learning data models: normalizes records (evidence: `background.js`)
- Message and action worker → Chrome local storage: reads and writes (evidence: `background.js`)
- Digest side panel → Library and Wordbook UI: renders collections (evidence: `README.md`)
- Library and Wordbook UI → Message and action worker: saves and searches (evidence: `README.md`)
- Message and action worker → Backup and restore: creates and merges (evidence: `background.js`)
- Backup and restore → Chrome local storage: restores records (evidence: `README.md`)
- Library and Wordbook UI → Excerpt source focus: opens saved excerpt (evidence: `README.md`)
- Excerpt source focus → Rendered X page: highlights source (evidence: `README.md`)
