# souvik-dey-2029/leetsync architecture

> Architecture diagram of the GitHub repository souvik-dey-2029/leetsync, 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/souvik-dey-2029/leetsync
- Repository: https://github.com/souvik-dey-2029/leetsync

## Overview

LeetSync is a local-first browser extension that syncs accepted LeetCode solutions to a user-owned GitHub repository. Its main flow detects or manually starts a sync, asks for confirmation, gathers problem and solution details, checks for existing files, then organizes and uploads solution, README, and statistics data. Options handle Device Flow authentication; the popup and dashboard expose session and repository status. The README documents topic indexing and multi-solution behavior. Unsampled background and GFG modules are represented as capabilities, but their internal links are omitted where source evidence is unavailable.

Main entry points: [`scripts/leetcode/leetcode.js`](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/leetcode.js) (Sync orchestration), [`scripts/githubDeviceAuth.js`](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/githubDeviceAuth.js) (Device Flow client), [`scripts/welcome.js`](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/welcome.js) (Repository dashboard), [`scripts/options.js`](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/options.js) (Authentication settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_submission["LeetCode submission"]
  node_manual["Manual sync button<br/>[submitBtn.js]"]
  node_submissionengine["Submission engine<br/>[leetcode.js]"]
  node_problemdata["Problem parsing<br/>[versions.js]"]
  node_syncmodal["Sync confirmation<br/>[modal.js]"]
  node_gfg["GeeksforGeeks support<br/>[gfg.js]"]
end

subgraph group_sync["Sync workflow"]
  node_duplicate["Existing solution choice<br/>[modal.js]"]
  node_syncengine["Sync orchestration<br/>[leetcode.js]"]
  node_formatting["Path and format utilities<br/>[util.js]"]
  node_topicindex["Topic README index<br/>[readmeTopics.js]"]
end

subgraph group_github["GitHub integration"]
  node_deviceauth["Device Flow client"]
  node_repository[("User repository")]
end

subgraph group_extension["Extension UI"]
  node_authui["Authentication settings<br/>[options.js]"]
  node_browserstorage[("Extension storage")]
  node_popup["Popup dashboard<br/>[popup.js]"]
  node_welcome["Repository dashboard<br/>[welcome.js]"]
  node_background["Background worker<br/>[background.js]"]
end

node_leetcode(("LeetCode page"))
node_githubuser(("GitHub user"))
node_githubapi["GitHub API"]

node_leetcode -.->|"provides submission"| node_submissionengine
node_manual -.->|"starts sync"| node_submissionengine
node_submissionengine -->|"requests consent"| node_syncmodal
node_submissionengine -.->|"extracts details"| node_problemdata
node_submissionengine -->|"runs sync"| node_syncengine
node_syncengine -->|"asks choice"| node_duplicate
node_syncengine -.->|"formats paths"| node_formatting
node_syncengine -->|"calls GitHub"| node_deviceauth
node_deviceauth -->|"stores tokens"| node_browserstorage
node_deviceauth -.->|"requests tokens"| node_githubapi
node_syncengine -.->|"uploads files"| node_repository
node_syncengine -.->|"updates topics"| node_topicindex
node_authui -->|"runs Device Flow"| node_deviceauth
node_authui -.->|"saves settings"| node_browserstorage
node_githubuser -.->|"configures client"| node_authui
node_githubuser -.->|"approves access"| node_githubapi
node_popup -->|"validates token"| node_deviceauth
node_popup -->|"reads session"| node_browserstorage
node_welcome -->|"uses GitHub access"| node_deviceauth
node_welcome -->|"creates or links"| node_repository
node_welcome -->|"reads statistics"| node_browserstorage

click node_manual "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/submitBtn.js"
click node_submissionengine "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/leetcode.js"
click node_problemdata "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/versions.js"
click node_syncmodal "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/modal.js"
click node_duplicate "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/modal.js"
click node_syncengine "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/leetcode.js"
click node_formatting "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/util.js"
click node_topicindex "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/readmeTopics.js"
click node_authui "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/options.js"
click node_deviceauth "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/githubDeviceAuth.js"
click node_popup "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/popup.js"
click node_welcome "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/welcome.js"
click node_background "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/background.js"
click node_gfg "https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/gfg.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_manual,node_submissionengine,node_problemdata,node_syncmodal,node_gfg,node_githubuser toneBlue
class node_duplicate,node_syncengine,node_formatting,node_topicindex toneAmber
class node_deviceauth,node_repository,node_githubapi toneMint
class node_authui,node_browserstorage,node_popup,node_welcome,node_background toneRose
class node_leetcode toneIndigo
```

## Components

### LeetCode submission

- [Manual sync button](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/submitBtn.js): `scripts/leetcode/submitBtn.js`
- [Submission engine](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/leetcode.js): `scripts/leetcode/leetcode.js`
- [Problem parsing](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/versions.js): `scripts/leetcode/versions.js`
- [Sync confirmation](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/modal.js): `scripts/leetcode/modal.js`
- [GeeksforGeeks support](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/gfg.js): `scripts/gfg.js`

### Sync workflow

- [Existing solution choice](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/modal.js): `scripts/leetcode/modal.js`
- [Sync orchestration](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/leetcode.js): `scripts/leetcode/leetcode.js`
- [Path and format utilities](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/util.js): `scripts/leetcode/util.js`
- [Topic README index](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/leetcode/readmeTopics.js): `scripts/leetcode/readmeTopics.js`

### GitHub integration

- [Device Flow client](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/githubDeviceAuth.js): `scripts/githubDeviceAuth.js`
- **User repository**

### Extension UI

- [Authentication settings](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/options.js): `scripts/options.js`
- **Extension storage**
- [Popup dashboard](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/popup.js): `scripts/popup.js`
- [Repository dashboard](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/welcome.js): `scripts/welcome.js`
- [Background worker](https://github.com/souvik-dey-2029/leetsync/blob/main/scripts/background.js): `scripts/background.js`

### Other components

- **LeetCode page**
- **GitHub user**
- **GitHub API**

## Connections

- LeetCode page → Submission engine: provides submission (evidence: `README.md`)
- Manual sync button → Submission engine: starts sync (evidence: `scripts/leetcode/submitBtn.js`)
- Submission engine → Sync confirmation: requests consent (evidence: `scripts/leetcode/leetcode.js`)
- Submission engine → Problem parsing: extracts details (evidence: `scripts/leetcode/leetcode.js`)
- Submission engine → Sync orchestration: runs sync (evidence: `scripts/leetcode/leetcode.js`)
- Sync orchestration → Existing solution choice: asks choice (evidence: `scripts/leetcode/leetcode.js`)
- Sync orchestration → Path and format utilities: formats paths (evidence: `scripts/leetcode/leetcode.js`)
- Sync orchestration → Device Flow client: calls GitHub (evidence: `scripts/leetcode/leetcode.js`)
- Device Flow client → Extension storage: stores tokens (evidence: `scripts/githubDeviceAuth.js`)
- Device Flow client → GitHub API: requests tokens (evidence: `README.md`)
- Sync orchestration → User repository: uploads files (evidence: `README.md`)
- Sync orchestration → Topic README index: updates topics (evidence: `README.md`)
- Authentication settings → Device Flow client: runs Device Flow (evidence: `scripts/options.js`)
- Authentication settings → Extension storage: saves settings (evidence: `scripts/options.js`)
- GitHub user → Authentication settings: configures client (evidence: `README.md`)
- GitHub user → GitHub API: approves access (evidence: `README.md`)
- Popup dashboard → Device Flow client: validates token (evidence: `scripts/popup.js`)
- Popup dashboard → Extension storage: reads session (evidence: `scripts/popup.js`)
- Repository dashboard → Device Flow client: uses GitHub access (evidence: `scripts/welcome.js`)
- Repository dashboard → User repository: creates or links (evidence: `scripts/welcome.js`)
- Repository dashboard → Extension storage: reads statistics (evidence: `scripts/welcome.js`)
