# yaph/chatgpt-export architecture

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

- Interactive diagram: https://gitdiagram.com/yaph/chatgpt-export
- Repository: https://github.com/yaph/chatgpt-export

## Overview

Key Components to Include:

##### Browser Environment
- Bookmark Bar (where the bookmarklet resides)
- Active ChatGPT Web Page
- DOM Manipulation Layer
- File System Interface

##### Core Processing Components
- HTML Cloning Module
- Content Cleaning Pipeline
- Markdown Conversion Engine
- File Download Manager

##### Component Representation

a) User Interface Layer (Top)
- Browser Bookmark Bar containing the bookmarklet
- ChatGPT webpage DOM

b) Processing Layer (Middle)
- Document Cloning Module
- Content Cleaning Pipeline
- Markdown Conversion Engine

c) Output Layer (Bottom)
- File System Interface
- Download Manager

##### Data Flow Representation
1. Bookmarklet Activation → ChatGPT DOM
2. DOM → Document Cloning
3. Cloned Document → Content Cleaning
4. Cleaned Content → Markdown Conversion
5. Markdown → File Download

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef browser fill:#a8d1f0,stroke:#333
    classDef process fill:#90EE90,stroke:#333
    classDef io fill:#FFA07A,stroke:#333
    classDef external fill:#DCDCDC,stroke:#333

    %% Browser Environment
    subgraph BrowserEnv["Browser Environment"]
        BookmarkBar["Bookmark Bar"]:::browser
        ChatGPTPage["ChatGPT Web Page"]:::external
        DOMLayer["DOM Manipulation Layer"]:::browser
    end

    %% Processing Layer
    subgraph ProcessingLayer["Processing Layer"]
        Bookmarklet["Bookmarklet Build System"]:::process
        CorePipeline["Core Processing Pipeline"]:::process
        subgraph CleaningPipeline["Content Processing Pipeline"]
            HTMLClone["HTML Cloning Module"]:::process
            ContentCleaner["Content Cleaning"]:::process
            MarkdownConverter["Markdown Conversion"]:::process
        end
    end

    %% Output Layer
    subgraph OutputLayer["Output Layer"]
        FSInterface["File System Interface"]:::io
        DownloadMgr["Download Manager"]:::io
    end

    %% Connections
    BookmarkBar --> ChatGPTPage
    ChatGPTPage --> DOMLayer
    DOMLayer --> CorePipeline
    CorePipeline --> HTMLClone
    HTMLClone --> ContentCleaner
    ContentCleaner --> MarkdownConverter
    MarkdownConverter --> FSInterface
    FSInterface --> DownloadMgr

    %% Click Events
    click CorePipeline "https://github.com/yaph/chatgpt-export/blob/main/gpt2md.js"
    click Bookmarklet "https://github.com/yaph/chatgpt-export/blob/main/build.js"

    %% Legend
    subgraph Legend
        Browser["Browser Component"]:::browser
        Process["Processing Component"]:::process
        IO["I/O Component"]:::io
        External["External System"]:::external
    end
```
