# coderyjc/deepseek2markdown architecture

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

- Interactive diagram: https://gitdiagram.com/coderyjc/deepseek2markdown
- Repository: https://github.com/coderyjc/deepseek2markdown

## Overview

##### Project type and purpose
- This is a Chrome extension (“DeepSeek2Markdown”) whose goal is to extract chat dialogues from DeepSeek in the browser and export them as Markdown, PDF, or image files.
- Key features from the README: a popup UI for export options, background logic to orchestrate extraction, content script to scrape the page DOM, and a small library (canvas2image.js) to generate images.

##### File structure
- src/background.js: extension’s background service worker handling long-lived tasks and message routing.
- src/content.js: content script injected into DeepSeek pages, responsible for DOM traversal and extraction of chat content.
- src/lib/canvas2image.js: a utility library used to render extracted content into an image.
- README files and doc/ directory: documentation and illustrative screenshots.

##### README for additional insights
- The README describes user flow: load extension → visit DeepSeek page → click popup → choose export format → extension scrapes DOM → processes into Markdown/PDF/image → triggers download.
- There is no backend server; all operations happen client-side using Chrome Extension APIs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Extension Context
    subgraph "Extension Context"
        direction TB
        Manifest["manifest.json\n(permissions: tabs, downloads)"]:::config
        Icons["Icon Assets\n(src/icons)"]:::config
        Popup[/"Popup UI\n(src/popup.html,\nsrc/popup.js,\nsrc/style.css)"/]:::ui
        Background["Background Service Worker\n(src/background.js)"]:::service
        CanvasLib["Canvas2Image Library\n(src/lib/canvas2image.js)"]:::util
    end

    %% Web Page Context
    subgraph "Web Page Context"
        direction TB
        Content["Content Script\n(src/content.js)"]:::model
        DeepSeek["DeepSeek Page\n(DOM with chat content)"]:::model
    end

    %% Documentation
    Docs["Documentation & Screenshots\n(README.md,\nREADME-en.md,\ndoc/)"]:::doc

    %% User Interaction
    User["User\n(click extension icon)"]:::ui

    %% Flows
    User -->|"click icon"| Popup
    Popup -->|"chrome.runtime.sendMessage"| Background
    Background -->|"chrome.tabs.sendMessage"| Content
    Content -->|"scrape DOM\n(JSON payload)"| Background
    Background -->|"process data\n(Markdown/PDF/Image)"| Popup
    Background -->|"image HTML/CSS"| CanvasLib
    CanvasLib -->|"Canvas→Blob"| Background
    Popup -->|"chrome.downloads.download"| User

    %% Configuration linkage
    Manifest --> Popup
    Manifest --> Background
    Manifest --> Content

    %% Documentation linkage
    Docs -.-> Manifest

    %% Click events
    click Popup "https://github.com/coderyjc/deepseek2markdown/blob/main/src/popup.html"
    click Popup "https://github.com/coderyjc/deepseek2markdown/blob/main/src/popup.js"
    click Popup "https://github.com/coderyjc/deepseek2markdown/blob/main/src/style.css"
    click Background "https://github.com/coderyjc/deepseek2markdown/blob/main/src/background.js"
    click Content "https://github.com/coderyjc/deepseek2markdown/blob/main/src/content.js"
    click CanvasLib "https://github.com/coderyjc/deepseek2markdown/blob/main/src/lib/canvas2image.js"
    click Manifest "https://github.com/coderyjc/deepseek2markdown/blob/main/src/manifest.json"
    click Icons "https://github.com/coderyjc/deepseek2markdown/tree/main/src/icons"
    click Docs "https://github.com/coderyjc/deepseek2markdown/blob/main/README.md"
    click Docs "https://github.com/coderyjc/deepseek2markdown/blob/main/README-en.md"
    click Docs "https://github.com/coderyjc/deepseek2markdown/tree/main/doc/"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef service fill:#C2F7A2,stroke:#333,stroke-width:1px
    classDef model fill:#F7D6A2,stroke:#333,stroke-width:1px
    classDef util fill:#E0A2F7,stroke:#333,stroke-width:1px
    classDef config fill:#F7A2A2,stroke:#333,stroke-width:1px
    classDef doc fill:#D3D3D3,stroke:#333,stroke-width:1px
```
