# priyanshuk001/codehint-ai architecture

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

- Interactive diagram: https://gitdiagram.com/priyanshuk001/codehint-ai
- Repository: https://github.com/priyanshuk001/codehint-ai

## Overview

CodeHint AI is a browser extension that brings AI assistance into supported coding-problem pages. The user opens the popup or floating panel, selects an action, and the extension gathers problem context (and, where needed, editor code or test cases), sends a request to the background AI handler, and presents the response; generated code can be inserted into the editor. Site adapters normalize page-specific data, while a page-world bridge provides access to embedded editors. The README documents the supported sites and assistance modes; some implementation details are unsampled, so those links are shown only where documented.

Main entry points: [`content.js`](https://github.com/priyanshuk001/codehint-ai/blob/main/content.js) (Page assistant), [`core/registry.js`](https://github.com/priyanshuk001/codehint-ai/blob/main/core/registry.js) (Site registry), [`background.js`](https://github.com/priyanshuk001/codehint-ai/blob/main/background.js) (AI request handler), [`popup.js`](https://github.com/priyanshuk001/codehint-ai/blob/main/popup.js) (Toolbar popup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_popup["Toolbar popup<br/>[popup.js]"]
  node_panel["Page assistant<br/>[content.js]"]
  node_settings[("Saved settings")]
end

subgraph group_sites["Problem sites"]
  node_registry["Site registry<br/>[registry.js]"]
  node_leetcode["LeetCode adapter<br/>[leetcode.js]"]
  node_codeforces["Codeforces adapter<br/>[codeforces.js]"]
  node_codechef["CodeChef adapter<br/>[codechef.js]"]
  node_gfg["GeeksforGeeks adapter<br/>[gfg.js]"]
  node_interviewbit["InterviewBit adapter<br/>[interviewbit.js]"]
  node_siteutils["Shared page parsing<br/>[site-utils.js]"]
end

subgraph group_editor["Editor access"]
  node_editors["Editor access API<br/>[editors.js]"]
  node_bridge["Page-world bridge<br/>[page-bridge.js]"]
end

subgraph group_ai["AI assistance"]
  node_background["AI request handler<br/>[background.js]"]
  node_openai{{"OpenAI API"}}
  node_gemini{{"Google Gemini API"}}
end

node_user(("Learner"))

node_user -->|"opens"| node_popup
node_user -->|"opens"| node_panel
node_popup -->|"reads and saves"| node_settings
node_panel -->|"reads and saves"| node_settings
node_popup -->|"requests page context"| node_panel
node_panel -->|"uses active adapter"| node_registry
node_registry -->|"selects for page"| node_leetcode
node_registry -->|"selects for page"| node_codeforces
node_registry -->|"selects for page"| node_codechef
node_registry -->|"selects for page"| node_gfg
node_registry -->|"selects for page"| node_interviewbit
node_leetcode -.->|"parses shared fields"| node_siteutils
node_codeforces -->|"uses helpers"| node_siteutils
node_gfg -->|"uses helpers"| node_siteutils
node_panel -->|"reads and inserts code"| node_editors
node_editors -->|"dispatches editor requests"| node_bridge
node_bridge -->|"returns editor data"| node_editors
node_popup -->|"sends AI requests"| node_background
node_panel -->|"sends AI requests"| node_background
node_background -->|"calls when selected"| node_openai
node_background -->|"calls when selected"| node_gemini
node_background -.->|"returns assistance"| node_popup
node_background -.->|"returns assistance"| node_panel

click node_popup "https://github.com/priyanshuk001/codehint-ai/blob/main/popup.js"
click node_panel "https://github.com/priyanshuk001/codehint-ai/blob/main/content.js"
click node_registry "https://github.com/priyanshuk001/codehint-ai/blob/main/core/registry.js"
click node_leetcode "https://github.com/priyanshuk001/codehint-ai/blob/main/sites/leetcode.js"
click node_codeforces "https://github.com/priyanshuk001/codehint-ai/blob/main/sites/codeforces.js"
click node_codechef "https://github.com/priyanshuk001/codehint-ai/blob/main/sites/codechef.js"
click node_gfg "https://github.com/priyanshuk001/codehint-ai/blob/main/sites/gfg.js"
click node_interviewbit "https://github.com/priyanshuk001/codehint-ai/blob/main/sites/interviewbit.js"
click node_siteutils "https://github.com/priyanshuk001/codehint-ai/blob/main/core/site-utils.js"
click node_editors "https://github.com/priyanshuk001/codehint-ai/blob/main/core/editors.js"
click node_bridge "https://github.com/priyanshuk001/codehint-ai/blob/main/core/page-bridge.js"
click node_background "https://github.com/priyanshuk001/codehint-ai/blob/main/background.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_panel,node_settings toneBlue
class node_registry,node_leetcode,node_codeforces,node_codechef,node_gfg,node_interviewbit,node_siteutils toneAmber
class node_editors,node_bridge toneMint
class node_background,node_openai,node_gemini toneRose
class node_user toneIndigo
```

## Components

### User interface

- [Toolbar popup](https://github.com/priyanshuk001/codehint-ai/blob/main/popup.js): `popup.js`
- [Page assistant](https://github.com/priyanshuk001/codehint-ai/blob/main/content.js): `content.js`
- **Saved settings**

### Problem sites

- [Site registry](https://github.com/priyanshuk001/codehint-ai/blob/main/core/registry.js): `core/registry.js`
- [LeetCode adapter](https://github.com/priyanshuk001/codehint-ai/blob/main/sites/leetcode.js): `sites/leetcode.js`
- [Codeforces adapter](https://github.com/priyanshuk001/codehint-ai/blob/main/sites/codeforces.js): `sites/codeforces.js`
- [CodeChef adapter](https://github.com/priyanshuk001/codehint-ai/blob/main/sites/codechef.js): `sites/codechef.js`
- [GeeksforGeeks adapter](https://github.com/priyanshuk001/codehint-ai/blob/main/sites/gfg.js): `sites/gfg.js`
- [InterviewBit adapter](https://github.com/priyanshuk001/codehint-ai/blob/main/sites/interviewbit.js): `sites/interviewbit.js`
- [Shared page parsing](https://github.com/priyanshuk001/codehint-ai/blob/main/core/site-utils.js): `core/site-utils.js`

### Editor access

- [Editor access API](https://github.com/priyanshuk001/codehint-ai/blob/main/core/editors.js): `core/editors.js`
- [Page-world bridge](https://github.com/priyanshuk001/codehint-ai/blob/main/core/page-bridge.js): `core/page-bridge.js`

### AI assistance

- [AI request handler](https://github.com/priyanshuk001/codehint-ai/blob/main/background.js): `background.js`
- **OpenAI API**
- **Google Gemini API**

### Other components

- **Learner**

## Connections

- Learner → Toolbar popup: opens (evidence: `README.md`)
- Learner → Page assistant: opens (evidence: `README.md`)
- Toolbar popup → Saved settings: reads and saves (evidence: `popup.js`)
- Page assistant → Saved settings: reads and saves (evidence: `content.js`)
- Toolbar popup → Page assistant: requests page context (evidence: `popup.js`)
- Page assistant → Site registry: uses active adapter (evidence: `README.md`)
- Site registry → LeetCode adapter: selects for page (evidence: `core/registry.js`)
- Site registry → Codeforces adapter: selects for page (evidence: `core/registry.js`)
- Site registry → CodeChef adapter: selects for page (evidence: `README.md`)
- Site registry → GeeksforGeeks adapter: selects for page (evidence: `README.md`)
- Site registry → InterviewBit adapter: selects for page (evidence: `README.md`)
- LeetCode adapter → Shared page parsing: parses shared fields
- Codeforces adapter → Shared page parsing: uses helpers (evidence: `sites/codeforces.js`)
- GeeksforGeeks adapter → Shared page parsing: uses helpers (evidence: `sites/gfg.js`)
- Page assistant → Editor access API: reads and inserts code (evidence: `README.md`)
- Editor access API → Page-world bridge: dispatches editor requests (evidence: `core/editors.js`)
- Page-world bridge → Editor access API: returns editor data (evidence: `core/page-bridge.js`)
- Toolbar popup → AI request handler: sends AI requests (evidence: `popup.js`)
- Page assistant → AI request handler: sends AI requests (evidence: `content.js`)
- AI request handler → OpenAI API: calls when selected (evidence: `background.js`)
- AI request handler → Google Gemini API: calls when selected (evidence: `background.js`)
- AI request handler → Toolbar popup: returns assistance
- AI request handler → Page assistant: returns assistance
