# saeedezzati/superpower-chatgpt architecture

> Architecture diagram of the GitHub repository saeedezzati/superpower-chatgpt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saeedezzati/superpower-chatgpt
- Repository: https://github.com/saeedezzati/superpower-chatgpt

## Overview

#### Purpose and delivery model
Superpower ChatGPT is a browser extension that augments the ChatGPT website with local chat/prompt management, prompt authoring utilities, UI controls, exports, and community/newsletter features. The extension is defined by `manifest.json`; its user-facing extension popup is `popup.html` with `popup.css`.

#### Runtime entry points
The background runtime owns extension-level initialization and browser lifecycle work through `scripts/background/background.js` and `scripts/background/initialize.js`. On ChatGPT pages, a content-script initialization layer injects and coordinates feature modules at `scripts/content/initialize.js`, with shared page-level behavior in `scripts/content/global.js`. Firefox uses a different background declaration, documented in the README, but reuses the initialization script.

#### Page interception and ChatGPT boundary
The extension operates against ChatGPT’s client UI and network behavior rather than owning a separate application backend. `scripts/interceptor/loadScript.js` loads `scripts/interceptor/interceptor.js`, establishing an interception boundary for ChatGPT requests/events. Content modules such as `scripts/content/api.js`, `scripts/content/fetchEventListeners.js`, and `scripts/content/arkose.js` bridge intercepted platform behavior to extension features, including generation controls and moderation/challenge-related handling.

#### Conversation management pipeline
ChatGPT conversation data is read from the host page/API boundary, copied locally for sync/search/export, and rendered into extension-provided controls. The principal model/view components are `scripts/content/conversation.js`, `scripts/content/conversationList.js`, and `scripts/content/conversationElement.js`. Folder assignment and drag/reorder behavior are layered through `scripts/content/folderElement.js`, `scripts/content/categoryList.js`, and `scripts/content/sortable.js`; destructive and archive-oriented flows include `scripts/content/clearConversations.js`.

#### Prompt capture and composition
Prompt authoring is a separate feature cluster centered on local prompt history/library and input-time enhancements: `scripts/content/promptHistory.js`, `scripts/content/promptLibrary.js`, and `scripts/content/promptChain.js`. Input interception and composition features—including autocomplete, template replacement, language/style presets, and custom instructions—are split across `scripts/content/quickAccessMenu.js`, `scripts/content/templateWordsModal.js`, and `scripts/content/customInstructions.js`. This boundary modifies submitted prompts but relies on ChatGPT for model execution.

#### UI augmentation and response controls
The extension injects UI into ChatGPT navigation, conversation rows, modals, and input/response areas. Key composition points are `scripts/content/navbar.js`, `scripts/content/modal.js`, and `scripts/content/newChatPage.js`. Response lifecycle actions are implemented in `scripts/content/continue.js`, `scripts/content/regenerateResponse.js`, and `scripts/content/stopGeneratingResponse.js`; per-message presentation is handled by `scripts/content/rowUser.js` and `scripts/content/rowAssistant.js`.

#### Persistence, export, and external services
README states conversation and prompt-history copies remain on the user’s computer; auto-sync supports local search and recovery. Export flows are implemented at `scripts/content/export.js`, backed by bundled serialization/download dependencies such as `scripts/thirdParty/jszip.js`, `scripts/thirdParty/FileSaver.js`, and `scripts/thirdParty/turndown.js`. Community prompt sharing and newsletter functionality imply remote service interaction, while private chats remain outside that server boundary; relevant page modules include `scripts/content/pluginStore.js` and `scripts/content/newsletterList.js`.

#### Dependencies and assets
This is plain browser-extension JavaScript/CSS, with vendored browser-side libraries rather than a visible build system. Rendering/export dependencies include Markdown, syntax highlighting, KaTeX, SSE, and sortable support under `scripts/thirdParty/`. Shared injected styling is `scripts/styles/global.css` and `scripts/styles/katex.css`; notification audio is `sounds/beep.mp3`.

Main entry points: [`scripts/content/initialize.js`](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/initialize.js) (Content initialization), [`scripts/content/conversation.js`](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/conversation.js) (Conversation management), [`scripts/interceptor/interceptor.js`](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/interceptor/interceptor.js) (ChatGPT interception), [`manifest.json`](https://github.com/saeedezzati/superpower-chatgpt/blob/main/manifest.json) (Extension manifest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Extension runtime"]
  node_manifest["Extension manifest<br/>browser extension config<br/>[manifest.json]"]
  node_background["Background runtime<br/>background script<br/>[background.js]"]
  node_background_init["Background initialization<br/>initializer<br/>[initialize.js]"]
  node_popup["Extension popup<br/>popup UI<br/>[popup.html]"]
end

subgraph group_chatgpt["ChatGPT page integration"]
  node_content_init["Content initialization<br/>content-script coordinator<br/>[initialize.js]"]
  node_page_global["Shared page behavior<br/>content module<br/>[global.js]"]
  node_interceptor_loader["Interceptor loader<br/>injected loader<br/>[loadScript.js]"]
  node_interceptor{{"ChatGPT interception<br/>page interception boundary<br/>[interceptor.js]"}}
end

subgraph group_features["Local features"]
  node_conversation_management["Conversation management<br/>content feature cluster<br/>[conversation.js]"]
  node_conversation_list["Conversation list UI<br/>content view"]
  node_folder_sorting["Folders and sorting<br/>content interaction<br/>[folderElement.js]"]
  node_prompt_authoring["Prompt library and chains<br/>content feature cluster<br/>[promptLibrary.js]"]
  node_prompt_composition["Prompt composition<br/>input enhancement<br/>[quickAccessMenu.js]"]
  node_ui_controls["Injected UI and response controls<br/>content feature cluster<br/>[navbar.js]"]
  node_local_copies[("Local chat and prompt copies<br/>browser-local persistence")]
  node_export["Export pipeline<br/>content export<br/>[export.js]"]
  node_export_libs["Export dependencies<br/>bundled browser libraries<br/>[jszip.js]"]
end

subgraph group_external["External boundaries"]
  node_chatgpt_ui{{"ChatGPT client UI/API<br/>host platform"}}
  node_community["Community and newsletter<br/>content integration<br/>[pluginStore.js]"]
  node_remote_services{{"Community remote services<br/>external service"}}
end

node_manifest -->|"declares"| node_background
node_manifest -->|"declares"| node_popup
node_manifest -->|"injects"| node_content_init
node_background -->|"initializes"| node_background_init
node_content_init -->|"coordinates"| node_page_global
node_content_init -->|"loads"| node_interceptor_loader
node_interceptor_loader -->|"injects"| node_interceptor
node_interceptor -->|"intercepts events and requests"| node_chatgpt_ui
node_content_init -->|"activates"| node_conversation_management
node_conversation_management -->|"renders"| node_conversation_list
node_conversation_management -->|"organizes"| node_folder_sorting
node_interceptor -->|"bridges host data"| node_conversation_management
node_conversation_management -->|"syncs copies"| node_local_copies
node_content_init -->|"activates"| node_prompt_authoring
node_prompt_authoring -->|"stores history"| node_local_copies
node_prompt_authoring -->|"supplies prompts"| node_prompt_composition
node_prompt_composition -->|"modifies submitted prompts"| node_chatgpt_ui
node_content_init -->|"injects"| node_ui_controls
node_ui_controls -->|"controls generation lifecycle"| node_interceptor
node_local_copies -->|"provides chats"| node_export
node_export -->|"uses"| node_export_libs
node_community -->|"shares prompts and newsletter data"| node_remote_services

click node_manifest "https://github.com/saeedezzati/superpower-chatgpt/blob/main/manifest.json"
click node_background "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/background/background.js"
click node_background_init "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/background/initialize.js"
click node_popup "https://github.com/saeedezzati/superpower-chatgpt/blob/main/popup.html"
click node_content_init "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/initialize.js"
click node_page_global "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/global.js"
click node_interceptor_loader "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/interceptor/loadScript.js"
click node_interceptor "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/interceptor/interceptor.js"
click node_conversation_management "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/conversation.js"
click node_conversation_list "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/conversationList.js"
click node_folder_sorting "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/folderElement.js"
click node_prompt_authoring "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/promptLibrary.js"
click node_prompt_composition "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/quickAccessMenu.js"
click node_ui_controls "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/navbar.js"
click node_export "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/export.js"
click node_export_libs "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/thirdParty/jszip.js"
click node_community "https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/pluginStore.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_manifest,node_background,node_background_init,node_popup toneBlue
class node_content_init,node_page_global,node_interceptor_loader,node_interceptor toneAmber
class node_conversation_management,node_conversation_list,node_folder_sorting,node_prompt_authoring,node_prompt_composition,node_ui_controls,node_local_copies,node_export,node_export_libs toneMint
class node_chatgpt_ui,node_community,node_remote_services toneRose
```

## Components

### Extension runtime

- [Extension manifest](https://github.com/saeedezzati/superpower-chatgpt/blob/main/manifest.json): browser extension config · Defines extension entry points and injection. · `manifest.json`
- [Background runtime](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/background/background.js): background script · Owns browser lifecycle work. · `scripts/background/background.js`
- [Background initialization](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/background/initialize.js): initializer · `scripts/background/initialize.js`
- [Extension popup](https://github.com/saeedezzati/superpower-chatgpt/blob/main/popup.html): popup UI · `popup.html`

### ChatGPT page integration

- [Content initialization](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/initialize.js): content-script coordinator · Injects and coordinates page features. · `scripts/content/initialize.js`
- [Shared page behavior](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/global.js): content module · `scripts/content/global.js`
- [Interceptor loader](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/interceptor/loadScript.js): injected loader · `scripts/interceptor/loadScript.js`
- [ChatGPT interception](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/interceptor/interceptor.js): page interception boundary · Observes ChatGPT requests and events. · `scripts/interceptor/interceptor.js`

### Local features

- [Conversation management](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/conversation.js): content feature cluster · Local conversation views, folders, ordering, archive, and clearing. · `scripts/content/conversation.js`
- [Conversation list UI](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/conversationList.js): content view · `scripts/content/conversationList.js`
- [Folders and sorting](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/folderElement.js): content interaction · Assigns folders and supports drag/reorder. · `scripts/content/folderElement.js`
- [Prompt library and chains](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/promptLibrary.js): content feature cluster · Maintains local prompt history, library, and chains. · `scripts/content/promptLibrary.js`
- [Prompt composition](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/quickAccessMenu.js): input enhancement · Applies quick access, templates, and custom instructions. · `scripts/content/quickAccessMenu.js`
- [Injected UI and response controls](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/navbar.js): content feature cluster · Adds navigation, modal, row, and generation controls. · `scripts/content/navbar.js`
- **Local chat and prompt copies**: browser-local persistence · Supports sync, search, recovery, and private data retention.
- [Export pipeline](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/export.js): content export · Serializes locally stored chats for download. · `scripts/content/export.js`
- [Export dependencies](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/thirdParty/jszip.js): bundled browser libraries · ZIP, download, and Markdown conversion support. · `scripts/thirdParty/jszip.js`

### External boundaries

- **ChatGPT client UI/API**: host platform · Host owns chat execution and conversation APIs.
- [Community and newsletter](https://github.com/saeedezzati/superpower-chatgpt/blob/main/scripts/content/pluginStore.js): content integration · Prompt sharing and newsletter features cross the remote-service boundary. · `scripts/content/pluginStore.js`
- **Community remote services**: external service · Private chats remain outside this boundary.

## Connections

- Extension manifest → Background runtime: declares
- Extension manifest → Extension popup: declares
- Extension manifest → Content initialization: injects
- Background runtime → Background initialization: initializes
- Content initialization → Shared page behavior: coordinates
- Content initialization → Interceptor loader: loads
- Interceptor loader → ChatGPT interception: injects
- ChatGPT interception → ChatGPT client UI/API: intercepts events and requests
- Content initialization → Conversation management: activates
- Conversation management → Conversation list UI: renders
- Conversation management → Folders and sorting: organizes
- ChatGPT interception → Conversation management: bridges host data
- Conversation management → Local chat and prompt copies: syncs copies
- Content initialization → Prompt library and chains: activates
- Prompt library and chains → Local chat and prompt copies: stores history
- Prompt library and chains → Prompt composition: supplies prompts
- Prompt composition → ChatGPT client UI/API: modifies submitted prompts
- Content initialization → Injected UI and response controls: injects
- Injected UI and response controls → ChatGPT interception: controls generation lifecycle
- Local chat and prompt copies → Export pipeline: provides chats
- Export pipeline → Export dependencies: uses
- Community and newsletter → Community remote services: shares prompts and newsletter data
