# ajayrajpurohit/chat-gpt architecture

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

- Interactive diagram: https://gitdiagram.com/ajayrajpurohit/chat-gpt
- Repository: https://github.com/ajayrajpurohit/chat-gpt

## Overview

##### Project Type and Purpose
- This is an open-source, client-side “bookmarklet” tool for saving ChatGPT conversations as standalone HTML files.
- It consists of a static web page (index.html) that hosts the bookmarklet (bookmark.js) plus example saved conversation files in dated folders.

##### File Structure Analysis
- Top-level:
- index.html – landing page with instructions and the bookmarklet link
- bookmark.js – the bookmarklet script the user drags into their browser
- LICENSE, README.md – project metadata
- 12-2022/…, 03-2023/… – example saved HTML conversations
- No backend or server-side code. No build scripts or config files beyond standard static assets.

##### README Insights
- Purpose: let users “save ChatGPT conversation as HTML file on disk.”
- Notes an interesting integration: uploading saved chats to Amazon S3.
- Encourages contributions and bug reports.

##### Main Components
a. User’s Web Browser
b. Static Hosting (GitHub Pages or any static file server) serving index.html + bookmark.js
c. Bookmarklet Script (bookmark.js) injected into ChatGPT’s page context
d. Browser DOM of the ChatGPT page (source of the conversation data)
e. Local File System (where the generated HTML is downloaded)
f. Optional External Service: Amazon S3 (via fetch API)

##### Relationships & Data Flows
- User visits index.html → drags the bookmarklet to their toolbar.
- On ChatGPT page, user clicks the bookmarklet → browser injects bookmark.js into that page.
- bookmark.js reads the conversation DOM → serializes it into an HTML blob.
- Script triggers a browser download → file saved to local disk (12-2022/, 03-2023/ folders in examples).
- (Optional) bookmark.js can POST the same blob to an S3 bucket via AWS SDK or signed URL.

##### Architectural Patterns & Design Principles
- Pure client-side, zero-backend architecture.
- Bookmarklet pattern: small JavaScript snippet injected at runtime.
- Extensibility point: ability to add upload handlers (e.g., S3, Dropbox).
- Separation of concerns: index.html for distribution, bookmark.js for core logic.

##### Key Technologies & Libraries
- Vanilla JavaScript for the bookmarklet logic.
- HTML5 Blob and download API.
- (Optional) AWS S3 REST API or AWS SDK for JavaScript.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Distribution Layer
    subgraph "Distribution Layer"
        StaticServer["Static Hosting (GitHub Pages)"]:::distribution
        Index["Landing Page / Distribution UI\n(index.html)"]:::distribution
        BookmarkletDist["Bookmarklet Script\n(bookmark.js)"]:::distribution
    end

    %% Runtime Layer
    subgraph "Runtime Environment"
        Browser["User Web Browser"]:::runtime
        BookmarkletRun["Bookmarklet Script\n(bookmark.js)"]:::runtime
        ChatDOM["ChatGPT Page DOM"]:::runtime
    end

    %% Storage Layer
    subgraph "Local File System & Samples"
        LocalFS["Local File System"]:::storage
        subgraph "Sample Output Directory"
            SampleDir1["12-2022/"]:::storage
            Example1["what-is-programming.html"]:::storage
            SampleDir2["03-2023/"]:::storage
            Example2["chat-gpt-kwisatz-haderach-and-riddles.html"]:::storage
        end
    end

    %% Optional External Services
    subgraph "External Services (Optional)"
        S3["Amazon S3"]:::storage
        Dropbox["Dropbox"]:::ext
        GoogleDrive["Google Drive"]:::ext
    end

    %% Metadata
    subgraph "Project Metadata & Documentation"
        README["README.md"]:::distribution
        LICENSE["LICENSE"]:::distribution
    end

    %% Connections
    StaticServer -->|"HTTP GET index.html & bookmark.js"| Browser
    Browser -->|"Drag & Drop Bookmarklet"| BookmarkletRun
    BookmarkletRun -->|"Inject JS"| ChatDOM
    BookmarkletRun -->|"Generate & Download Blob"| LocalFS
    LocalFS --> SampleDir1
    LocalFS --> SampleDir2
    BookmarkletRun -->|"PUT/POST HTML"| S3
    BookmarkletRun -.->|"Extensible Hooks"| Dropbox
    BookmarkletRun -.->|"Extensible Hooks"| GoogleDrive

    %% Click Events
    click Index "https://github.com/ajayrajpurohit/chat-gpt/blob/master/index.html"
    click BookmarkletDist "https://github.com/ajayrajpurohit/chat-gpt/blob/master/bookmark.js"
    click README "https://github.com/ajayrajpurohit/chat-gpt/blob/master/README.md"
    click LICENSE "https://github.com/ajayrajpurohit/chat-gpt/tree/master/LICENSE"
    click SampleDir1 "https://github.com/ajayrajpurohit/chat-gpt/tree/master/12-2022/"
    click SampleDir2 "https://github.com/ajayrajpurohit/chat-gpt/tree/master/03-2023/"
    click Example1 "https://github.com/ajayrajpurohit/chat-gpt/blob/master/12-2022/what-is-programming.html"
    click Example2 "https://github.com/ajayrajpurohit/chat-gpt/blob/master/03-2023/chat-gpt-kwisatz-haderach-and-riddles.html"

    %% Styles
    classDef distribution fill:#cce5ff,stroke:#004085;
    classDef runtime fill:#d4edda,stroke:#155724;
    classDef storage fill:#fff3cd,stroke:#856404;
    classDef ext fill:#f8d7da,stroke:#721c24,stroke-dasharray: 5 5;
```
