# thegreatlucy/prompt-stacker architecture

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

- Interactive diagram: https://gitdiagram.com/thegreatlucy/prompt-stacker
- Repository: https://github.com/thegreatlucy/prompt-stacker

## Overview

Prompt Stacker is a browser extension for queuing and automating prompts across four AI chat sites, with a ChatGPT-only image browser and downloader. The main workflow is: the user queues prompts in the injected panel, the content script drives the site's chat UI and waits for replies, then sends the next prompt. A separate Images tab supports library selection or current-thread collection, followed by ZIP downloads. The excerpts show key UI, storage, locking, and archive behavior; some runtime wiring is documented but not fully sampled.

Main entry points: [`content.js`](https://github.com/thegreatlucy/prompt-stacker/blob/main/content.js) (Queue and panel), [`images-tab.js`](https://github.com/thegreatlucy/prompt-stacker/blob/main/images-tab.js) (Images tab), [`grabber.js`](https://github.com/thegreatlucy/prompt-stacker/blob/main/grabber.js) (Fetch and ZIP), [`library.js`](https://github.com/thegreatlucy/prompt-stacker/blob/main/library.js) (Library picker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prompt["Prompt queue"]
  node_panel_queue["Queue and panel<br/>[content.js]"]
end

subgraph group_images["Image tools"]
  node_images_tab["Images tab<br/>[images-tab.js]"]
  node_library_picker["Library picker<br/>[library.js]"]
  node_thread_collector["Thread collector<br/>[thread.js]"]
  node_download_engine["Fetch and ZIP<br/>[grabber.js]"]
end

subgraph group_runtime["Shared runtime"]
  node_zip_writer["ZIP writer<br/>[zip-lib.js]"]
  node_busy_lock["Cross-tab lock<br/>[busy-lock.js]"]
end

subgraph group_external["Browser and services"]
  node_chat_sites["Chat interfaces"]
  node_chrome_storage[("Chrome storage")]
  node_chatgpt_image_api{{"ChatGPT image APIs"}}
  node_image_hosts{{"Image hosts"}}
  node_browser_downloads["Browser downloads"]
end

node_user(("User"))

node_user -->|"queues prompts"| node_panel_queue
node_panel_queue -->|"drives chat UI"| node_chat_sites
node_panel_queue -->|"reads and writes"| node_chrome_storage
node_panel_queue -.->|"coordinates jobs"| node_busy_lock
node_user -->|"opens Images"| node_images_tab
node_images_tab -->|"opens picker"| node_library_picker
node_images_tab -->|"starts collection"| node_thread_collector
node_images_tab -->|"gates image jobs"| node_busy_lock
node_library_picker -->|"loads library"| node_chatgpt_image_api
node_thread_collector -->|"retrieves thread assets"| node_chatgpt_image_api
node_thread_collector -->|"passes image URLs"| node_download_engine
node_download_engine -->|"fetches image bytes"| node_image_hosts
node_download_engine -->|"builds archives"| node_zip_writer
node_download_engine -->|"saves ZIP files"| node_browser_downloads
node_library_picker -.->|"tracks saved images"| node_chrome_storage

click node_panel_queue "https://github.com/thegreatlucy/prompt-stacker/blob/main/content.js"
click node_images_tab "https://github.com/thegreatlucy/prompt-stacker/blob/main/images-tab.js"
click node_library_picker "https://github.com/thegreatlucy/prompt-stacker/blob/main/library.js"
click node_thread_collector "https://github.com/thegreatlucy/prompt-stacker/blob/main/thread.js"
click node_download_engine "https://github.com/thegreatlucy/prompt-stacker/blob/main/grabber.js"
click node_zip_writer "https://github.com/thegreatlucy/prompt-stacker/blob/main/zip-lib.js"
click node_busy_lock "https://github.com/thegreatlucy/prompt-stacker/blob/main/busy-lock.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_panel_queue,node_user toneBlue
class node_images_tab,node_library_picker,node_thread_collector,node_download_engine toneAmber
class node_zip_writer,node_busy_lock toneMint
class node_chat_sites,node_chrome_storage,node_chatgpt_image_api,node_image_hosts,node_browser_downloads toneRose
```

## Components

### Prompt queue

- [Queue and panel](https://github.com/thegreatlucy/prompt-stacker/blob/main/content.js): `content.js`

### Image tools

- [Images tab](https://github.com/thegreatlucy/prompt-stacker/blob/main/images-tab.js): `images-tab.js`
- [Library picker](https://github.com/thegreatlucy/prompt-stacker/blob/main/library.js): `library.js`
- [Thread collector](https://github.com/thegreatlucy/prompt-stacker/blob/main/thread.js): `thread.js`
- [Fetch and ZIP](https://github.com/thegreatlucy/prompt-stacker/blob/main/grabber.js): `grabber.js`

### Shared runtime

- [ZIP writer](https://github.com/thegreatlucy/prompt-stacker/blob/main/zip-lib.js): `zip-lib.js`
- [Cross-tab lock](https://github.com/thegreatlucy/prompt-stacker/blob/main/busy-lock.js): `busy-lock.js`

### Browser and services

- **Chat interfaces**
- **Chrome storage**
- **ChatGPT image APIs**
- **Image hosts**
- **Browser downloads**

### Other components

- **User**

## Connections

- User → Queue and panel: queues prompts (evidence: `README.md`)
- Queue and panel → Chat interfaces: drives chat UI (evidence: `README.md`)
- Queue and panel → Chrome storage: reads and writes (evidence: `content.js`)
- Queue and panel → Cross-tab lock: coordinates jobs (evidence: `busy-lock.js`)
- User → Images tab: opens Images (evidence: `README.md`)
- Images tab → Library picker: opens picker (evidence: `images-tab.js`)
- Images tab → Thread collector: starts collection (evidence: `images-tab.js`)
- Images tab → Cross-tab lock: gates image jobs (evidence: `images-tab.js`)
- Library picker → ChatGPT image APIs: loads library (evidence: `library.js`)
- Thread collector → ChatGPT image APIs: retrieves thread assets (evidence: `thread.js`)
- Thread collector → Fetch and ZIP: passes image URLs (evidence: `thread.js`)
- Fetch and ZIP → Image hosts: fetches image bytes (evidence: `grabber.js`)
- Fetch and ZIP → ZIP writer: builds archives (evidence: `zip-lib.js`)
- Fetch and ZIP → Browser downloads: saves ZIP files (evidence: `grabber.js`)
- Library picker → Chrome storage: tracks saved images (evidence: `library.js`)
