# qasimwani/leethub architecture

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

- Interactive diagram: https://gitdiagram.com/qasimwani/leethub
- Repository: https://github.com/qasimwani/leethub

## Overview

LeetHub is a browser extension that authorizes a GitHub account, lets the user create or link a repository, then syncs accepted coding solutions to GitHub. The principal path runs from solving and passing a problem on LeetCode (or GeeksforGeeks) through solution capture and repository upload; the popup and onboarding page expose account and repository status. The graph reflects the sampled scripts and documented workflow; unsampled manifest wiring and some implementation details are omitted.

Main entry points: [`popup.js`](https://github.com/qasimwani/leethub/blob/main/popup.js) (Extension Popup), [`scripts/leetcode.js`](https://github.com/qasimwani/leethub/blob/main/scripts/leetcode.js) (GitHub Sync), [`scripts/welcome.js`](https://github.com/qasimwani/leethub/blob/main/scripts/welcome.js) (Onboarding UI), [`scripts/background.js`](https://github.com/qasimwani/leethub/blob/main/scripts/background.js) (Extension State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Authorization"]
  node_oauth["OAuth Launcher<br/>[oauth2.js]"]
  node_callback["OAuth Callback<br/>[authorize.js]"]
  node_message_handler["Auth Message Handler<br/>[background.js]"]
  node_extension_state[("Extension State<br/>[background.js]")]
end

subgraph group_setup["Repository Setup"]
  node_repo_setup["Repository Setup<br/>[welcome.js]"]
end

subgraph group_sync["Solution Sync"]
  node_leetcode_capture["LeetCode Capture<br/>[leetcode.js]"]
  node_gfg_capture["GFG Capture<br/>[gfg.js]"]
  node_github_sync["GitHub Sync<br/>[leetcode.js]"]
  node_progress["Progress Stats<br/>[leetcode.js]"]
end

subgraph group_ui["Extension UI"]
  node_popup["Extension Popup<br/>[popup.js]"]
  node_onboarding["Onboarding UI<br/>[welcome.js]"]
end

node_developer(("Developer"))
node_leetcode(("LeetCode"))
node_gfg(("GeeksforGeeks"))
node_github["GitHub"]

node_developer -->|"opens"| node_popup
node_popup -->|"starts auth"| node_oauth
node_oauth -->|"requests authorization"| node_github
node_github -->|"redirects"| node_callback
node_callback -->|"exchanges code"| node_github
node_callback -->|"sends result"| node_message_handler
node_message_handler -->|"stores credentials"| node_extension_state
node_message_handler -->|"opens"| node_onboarding
node_developer -->|"sets up repo"| node_onboarding
node_onboarding -->|"configures"| node_repo_setup
node_repo_setup -->|"creates or links"| node_github
node_repo_setup -->|"stores repo settings"| node_extension_state
node_developer -->|"solves problem"| node_leetcode
node_leetcode -->|"submits solution"| node_leetcode_capture
node_leetcode_capture -->|"uploads solution"| node_github_sync
node_developer -.->|"solves problem"| node_gfg
node_gfg -->|"submits solution"| node_gfg_capture
node_gfg_capture -->|"calls uploadGit"| node_github_sync
node_github_sync -->|"writes files"| node_github
node_github_sync -->|"reads and updates stats"| node_extension_state
node_popup -->|"reads status"| node_extension_state
node_popup -->|"validates token"| node_github
node_onboarding -->|"displays stats"| node_progress

click node_popup "https://github.com/qasimwani/leethub/blob/main/popup.js"
click node_onboarding "https://github.com/qasimwani/leethub/blob/main/scripts/welcome.js"
click node_oauth "https://github.com/qasimwani/leethub/blob/main/scripts/oauth2.js"
click node_callback "https://github.com/qasimwani/leethub/blob/main/scripts/authorize.js"
click node_message_handler "https://github.com/qasimwani/leethub/blob/main/scripts/background.js"
click node_extension_state "https://github.com/qasimwani/leethub/blob/main/scripts/background.js"
click node_repo_setup "https://github.com/qasimwani/leethub/blob/main/scripts/welcome.js"
click node_leetcode_capture "https://github.com/qasimwani/leethub/blob/main/scripts/leetcode.js"
click node_gfg_capture "https://github.com/qasimwani/leethub/blob/main/scripts/gfg.js"
click node_github_sync "https://github.com/qasimwani/leethub/blob/main/scripts/leetcode.js"
click node_progress "https://github.com/qasimwani/leethub/blob/main/scripts/leetcode.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_oauth,node_callback,node_message_handler,node_extension_state toneBlue
class node_repo_setup toneAmber
class node_leetcode_capture,node_gfg_capture,node_github_sync,node_progress toneMint
class node_popup,node_onboarding toneRose
class node_developer,node_leetcode,node_gfg,node_github toneIndigo
```

## Components

### Authorization

- [OAuth Launcher](https://github.com/qasimwani/leethub/blob/main/scripts/oauth2.js): `scripts/oauth2.js`
- [OAuth Callback](https://github.com/qasimwani/leethub/blob/main/scripts/authorize.js): `scripts/authorize.js`
- [Auth Message Handler](https://github.com/qasimwani/leethub/blob/main/scripts/background.js): `scripts/background.js`
- [Extension State](https://github.com/qasimwani/leethub/blob/main/scripts/background.js): `scripts/background.js`

### Repository Setup

- [Repository Setup](https://github.com/qasimwani/leethub/blob/main/scripts/welcome.js): `scripts/welcome.js`

### Solution Sync

- [LeetCode Capture](https://github.com/qasimwani/leethub/blob/main/scripts/leetcode.js): `scripts/leetcode.js`
- [GFG Capture](https://github.com/qasimwani/leethub/blob/main/scripts/gfg.js): `scripts/gfg.js`
- [GitHub Sync](https://github.com/qasimwani/leethub/blob/main/scripts/leetcode.js): `scripts/leetcode.js`
- [Progress Stats](https://github.com/qasimwani/leethub/blob/main/scripts/leetcode.js): `scripts/leetcode.js`

### Extension UI

- [Extension Popup](https://github.com/qasimwani/leethub/blob/main/popup.js): `popup.js`
- [Onboarding UI](https://github.com/qasimwani/leethub/blob/main/scripts/welcome.js): `scripts/welcome.js`

### Other components

- **Developer**
- **LeetCode**
- **GeeksforGeeks**
- **GitHub**

## Connections

- Developer → Extension Popup: opens (evidence: `README.md`)
- Extension Popup → OAuth Launcher: starts auth (evidence: `popup.js`)
- OAuth Launcher → GitHub: requests authorization (evidence: `scripts/oauth2.js`)
- GitHub → OAuth Callback: redirects (evidence: `scripts/authorize.js`)
- OAuth Callback → GitHub: exchanges code (evidence: `scripts/authorize.js`)
- OAuth Callback → Auth Message Handler: sends result (evidence: `scripts/authorize.js`)
- Auth Message Handler → Extension State: stores credentials (evidence: `scripts/background.js`)
- Auth Message Handler → Onboarding UI: opens (evidence: `scripts/background.js`)
- Developer → Onboarding UI: sets up repo (evidence: `README.md`)
- Onboarding UI → Repository Setup: configures (evidence: `scripts/welcome.js`)
- Repository Setup → GitHub: creates or links (evidence: `scripts/welcome.js`)
- Repository Setup → Extension State: stores repo settings (evidence: `scripts/welcome.js`)
- Developer → LeetCode: solves problem (evidence: `README.md`)
- LeetCode → LeetCode Capture: submits solution (evidence: `scripts/leetcode.js`)
- LeetCode Capture → GitHub Sync: uploads solution (evidence: `scripts/leetcode.js`)
- Developer → GeeksforGeeks: solves problem
- GeeksforGeeks → GFG Capture: submits solution (evidence: `scripts/gfg.js`)
- GFG Capture → GitHub Sync: calls uploadGit (evidence: `scripts/gfg.js`)
- GitHub Sync → GitHub: writes files (evidence: `scripts/leetcode.js`)
- GitHub Sync → Extension State: reads and updates stats (evidence: `scripts/leetcode.js`)
- Extension Popup → Extension State: reads status (evidence: `popup.js`)
- Extension Popup → GitHub: validates token (evidence: `popup.js`)
- Onboarding UI → Progress Stats: displays stats (evidence: `scripts/welcome.js`)
