# muhammadtalha-prog/ia-agent-chrome-extension architecture

> Architecture diagram of the GitHub repository muhammadtalha-prog/ia-agent-chrome-extension, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/muhammadtalha-prog/ia-agent-chrome-extension
- Repository: https://github.com/muhammadtalha-prog/ia-agent-chrome-extension

## Overview

#### Purpose and Runtime

IA Agent is a Chromium browser extension that migrates an active AI-chat conversation between ChatGPT, Gemini, and Claude. It extracts source-page history, asks DeepSeek to produce a structured handoff summary, then inserts that summary into a target chat editor.

The extension is defined by `manifest.json` and runs across extension UI pages, a background context, and page-injected content scripts.

#### User Entry Points

The toolbar popup is the main migration control surface: `popup.html`, `popup.js`, and `popup.css`. Users initiate capture/migration and navigate to settings from this UI.

Configuration is managed separately through `options.html` and `options.js`, where the DeepSeek API key, selected model, and system prompt are persisted in Chrome local storage.

#### Browser Integration Layer

`content.js` executes in supported AI-chat pages. It is responsible for page-specific DOM interaction: extracting visible user/assistant conversation history from source tabs and finding/focusing a prompt editor on target tabs for summary injection.

This is the principal boundary between extension code and third-party chat UIs; selectors and extraction behavior must tolerate changing ChatGPT, Gemini, and Claude DOM structures.

#### Orchestration and Messaging

`background.js` is the extension-level coordinator. It receives work requests from the popup/content contexts, accesses persisted settings, manages tab-level operations, and coordinates the capture → compile → inject sequence.

Control flows cross Chrome extension messaging boundaries rather than sharing in-memory state directly:
1. Popup requests migration.
2. Background identifies source/target tabs and requests extraction through the content script.
3. Background sends captured history to DeepSeek.
4. Background returns or forwards the compiled context for target-page injection.

#### Context Compilation Service

DeepSeek is the sole external service. `background.js` calls its completion API using the configured `deepseek-chat` or `deepseek-reasoner` model and a configurable system prompt.

The intended output is a migration block covering task, progress, finalized code/snippets, and next steps. API credentials remain browser-local via Chrome storage; requests go directly from the extension to DeepSeek rather than through an application backend.

#### Persistence and Fallback Behavior

Chrome local storage is the durable boundary for user configuration, notably the API key, model choice, and system prompt, managed by `options.js` and consumed by `background.js`.

When no API key is configured, the product supports a simulated mode so the UI and migration workflow can be exercised without a live DeepSeek call.

#### Auxiliary Validation

`test_api.js` is an independent Node CLI check for DeepSeek credentials and connectivity. It validates the external API outside the browser-extension runtime and is not part of the installed extension execution path.

Main entry points: [`background.js`](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/background.js) (Migration Coordinator), [`manifest.json`](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/manifest.json) (Extension Manifest), [`content.js`](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/content.js) (Chat Page Adapter), [`popup.html`](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/popup.html) (Migration Popup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Extension UI"]
  node_popup["Migration Popup<br/>toolbar UI<br/>[popup.html]"]
  node_popup_logic["Popup Controller<br/>UI logic<br/>[popup.js]"]
  node_popup_styles["Popup Styles<br/>[popup.css]"]
  node_options["Settings Page<br/>settings UI<br/>[options.html]"]
  node_options_logic["Settings Controller<br/>settings logic<br/>[options.js]"]
end

subgraph group_runtime["Extension Runtime"]
  node_manifest["Extension Manifest<br/>[manifest.json]"]
  node_background{{"Migration Coordinator<br/>background context<br/>[background.js]"}}
  node_content{{"Chat Page Adapter<br/>content script<br/>[content.js]"}}
  node_simulated_mode["Simulated Compilation<br/>fallback mode"]
end

subgraph group_browser["Browser &amp; Chat Pages"]
  node_chrome_storage[("Chrome Local Storage<br/>browser storage")]
  node_chat_tabs["ChatGPT / Gemini / Claude Tabs<br/>third-party chat UIs"]
end

subgraph group_external["External Service"]
  node_deepseek{{"DeepSeek Completion API<br/>external API"}}
  node_api_check["DeepSeek CLI Check<br/>Node CLI<br/>[test_api.js]"]
end

node_manifest -->|"declares"| node_popup
node_manifest -->|"declares"| node_options
node_manifest -->|"declares"| node_background
node_manifest -->|"injects into"| node_content
node_popup -->|"runs"| node_popup_logic
node_popup_styles -->|"styles"| node_popup
node_options -->|"runs"| node_options_logic
node_options_logic -->|"saves settings"| node_chrome_storage
node_popup_logic -->|"requests migration"| node_background
node_background -->|"loads settings"| node_chrome_storage
node_background -->|"requests extract / inject"| node_content
node_content -->|"reads history; writes editor"| node_chat_tabs
node_background -->|"sends history for compilation"| node_deepseek
node_deepseek -->|"returns migration block"| node_background
node_background -.->|"falls back without API key"| node_simulated_mode
node_simulated_mode -.->|"supplies simulated context"| node_content
node_api_check -.->|"validates connectivity"| node_deepseek

click node_manifest "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/manifest.json"
click node_popup "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/popup.html"
click node_popup_logic "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/popup.js"
click node_popup_styles "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/popup.css"
click node_options "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/options.html"
click node_options_logic "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/options.js"
click node_background "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/background.js"
click node_content "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/content.js"
click node_api_check "https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/test_api.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_popup,node_popup_logic,node_popup_styles,node_options,node_options_logic toneBlue
class node_manifest,node_background,node_content,node_simulated_mode toneAmber
class node_chrome_storage,node_chat_tabs toneMint
class node_deepseek,node_api_check toneRose
```

## Components

### Extension UI

- [Migration Popup](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/popup.html): toolbar UI · Starts capture and migration flows. · `popup.html`
- [Popup Controller](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/popup.js): UI logic · `popup.js`
- [Popup Styles](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/popup.css): styles · `popup.css`
- [Settings Page](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/options.html): settings UI · Edits DeepSeek configuration. · `options.html`
- [Settings Controller](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/options.js): settings logic · `options.js`

### Extension Runtime

- [Extension Manifest](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/manifest.json): manifest · Declares extension pages, background context, and content scripts. · `manifest.json`
- [Migration Coordinator](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/background.js): background context · Coordinates tab operations, messaging, compilation, and injection. · `background.js`
- [Chat Page Adapter](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/content.js): content script · Extracts histories and injects summaries through chat-page DOMs. · `content.js`
- **Simulated Compilation**: fallback mode · Allows migration workflow without a configured API key.

### Browser & Chat Pages

- **Chrome Local Storage**: browser storage · Persists API key, model, and system prompt locally.
- **ChatGPT / Gemini / Claude Tabs**: third-party chat UIs · Source conversation and target prompt editor surfaces.

### External Service

- **DeepSeek Completion API**: external API · Compiles captured history into a structured migration block.
- [DeepSeek CLI Check](https://github.com/muhammadtalha-prog/ia-agent-chrome-extension/blob/main/test_api.js): Node CLI · Independently validates DeepSeek credentials and connectivity. · `test_api.js`

## Connections

- Extension Manifest → Migration Popup: declares
- Extension Manifest → Settings Page: declares
- Extension Manifest → Migration Coordinator: declares
- Extension Manifest → Chat Page Adapter: injects into
- Migration Popup → Popup Controller: runs
- Popup Styles → Migration Popup: styles
- Settings Page → Settings Controller: runs
- Settings Controller → Chrome Local Storage: saves settings
- Popup Controller → Migration Coordinator: requests migration
- Migration Coordinator → Chrome Local Storage: loads settings
- Migration Coordinator → Chat Page Adapter: requests extract / inject · Chrome extension messaging boundary.
- Chat Page Adapter → ChatGPT / Gemini / Claude Tabs: reads history; writes editor
- Migration Coordinator → DeepSeek Completion API: sends history for compilation · Uses configured model and system prompt.
- DeepSeek Completion API → Migration Coordinator: returns migration block
- Migration Coordinator → Simulated Compilation: falls back without API key
- Simulated Compilation → Chat Page Adapter: supplies simulated context
- DeepSeek CLI Check → DeepSeek Completion API: validates connectivity · Outside installed extension runtime.
