How mr-sanjai-offl/algovault works
Purpose and execution model
AlgoVault is a Chrome Manifest V3 extension that detects accepted LeetCode submissions, persists them locally, and synchronizes structured solutions plus a generated dashboard to a user-selected GitHub repository. Its runtime is split across a MV3 background service worker, LeetCode content scripts, React popup/options surfaces, and Chrome extension storage.
Extension entry points
• Background orchestration starts in src/background/service-worker.ts, with cross-context request routing in src/background/messageHandler.ts.
• LeetCode page integration starts in src/content/index.ts; page changes and submission-state observation are handled by src/content/observer.ts.
• The browser-action UI is React-based at src/popup/main.tsx and src/popup/App.tsx.
• The options UI has an independent React entry at src/options/main.tsx.
• Static extension assets and manifest-related browser resources reside in public/manifest.json and public/content-loader.js.
Submission capture pipeline
Content scripts observe LeetCode’s dynamic UI, extract accepted-submission data, and send it to the background layer:
• DOM/problem/submission parsing: src/content/extractor.ts
• SPA lifecycle and acceptance detection: src/content/observer.ts
• Shared message contracts: src/shared/types/messages.ts, src/shared/types/submission.ts
The content/background boundary is Chrome runtime messaging. This keeps site DOM access outside the privileged background process and lets the service worker own persistence, authentication, and outbound GitHub calls.
Background sync and GitHub boundary
The service worker coordinates the main control flow: receive submission, deduplicate/persist it, obtain repository configuration, then commit solution and dashboard updates through GitHub APIs.
• GitHub HTTP/API adapter: src/background/github/client.ts
• LeetCode API integration: src/background/leetcode/api.ts
• Repository manifest/state of synchronized files: src/background/manifest/manifestStore.ts
• Error classification shared across stages: src/shared/errors/taxonomy.ts
GitHub authentication uses OAuth Device Flow in src/background/auth/deviceFlow.ts. GitHub and optional OpenRouter-related contracts are represented by shared types, including src/shared/types/ai.ts.
Local state, durability, and recovery
State is intentionally separated by access pattern:
• High-volume submission/history persistence: src/background/storage/indexedDb.ts
• Extension configuration and lightweight state: src/background/storage/configStore.ts
• Encrypted local credential storage: src/background/storage/encryptedStorage.ts
This layer shields sync orchestration from browser service-worker restarts and retains unsynchronized work/history locally. Configuration, manifest, and sync message types define the durable state boundaries in src/shared/types/config.ts, src/shared/types/manifest.ts, and src/shared/types/sync.ts.
Repository generation and analytics
After successful synchronization, the extension derives portfolio-facing repository artifacts:
• Aggregate history/statistics: src/background/stats/aggregator.ts
• GitHub dashboard README generation: src/background/markdown/dashboardBuilder.ts
• Per-solution/readme content generation: src/background/markdown/readmeBuilder.ts
These builders transform persisted submission data into Markdown rather than exposing raw browser-captured data directly to GitHub.
User-facing control plane
The popup is the operational UI for login, repository settings, sync status, history, statistics, and theme preferences:
• Page composition: src/popup/pages/DashboardPage.tsx, src/popup/pages/SettingsPage.tsx, src/popup/pages/HistoryPage.tsx
• Background-facing state hooks: src/popup/hooks/useAuth.ts, src/popup/hooks/useSync.ts, src/popup/hooks/useHistory.ts
• Auth entry page: src/popup/pages/LoginPage.tsx
React/Vite/TypeScript build the UI and extension bundles; Chrome APIs, GitHub Device Flow/GitHub APIs, LeetCode pages/APIs, IndexedDB, and chrome.storage.local are the material platform dependencies.
Main entry points: service-worker.ts Service worker · messageHandler.ts Message router · indexedDb.ts Submission history · client.ts GitHub client
Components 19
Extension contexts
- LeetCode content script · Observes pages and captures accepted submissions.
src/content/index.ts - Submission observer · Tracks page lifecycle and acceptance state.
src/content/observer.ts - Submission extractor
src/content/extractor.ts - Popup control plane · Login, settings, sync status, history, and statistics.
src/popup/App.tsx - Options UI
src/options/main.tsx
Background orchestration
- Service worker · Owns capture handling, persistence, auth, and synchronization.
src/background/service-worker.ts - Message router · Routes cross-context Chrome runtime requests.
src/background/messageHandler.ts - GitHub device auth
src/background/auth/deviceFlow.ts - GitHub client
src/background/github/client.ts - LeetCode API
src/background/leetcode/api.ts
Local durable state
- Submission history · Durable high-volume submissions and unsynced work.
src/background/storage/indexedDb.ts - Configuration store · Repository configuration and lightweight extension state.
src/background/storage/configStore.ts - Credential store
src/background/storage/encryptedStorage.ts - Sync manifest · Tracks synchronized repository files.
src/background/manifest/manifestStore.ts
Repository generation
- Statistics aggregator
src/background/stats/aggregator.ts - Solution Markdown builder
src/background/markdown/readmeBuilder.ts - Dashboard builder
src/background/markdown/dashboardBuilder.ts
External platforms
- LeetCode
- GitHub repository · User-selected destination repository.
Connections 23
- LeetCode → LeetCode content script: renders problem UI
- LeetCode content script → Submission observer: starts observation
- Submission observer → Submission extractor: accepted submission
- Submission extractor → Message router: submission message · Chrome runtime messaging boundary.
- Popup control plane → Message router: auth and sync requests
- Options UI → Message router: configuration requests
- Message router → Service worker: routed requests
- Service worker → Submission history: persists and deduplicates
- Service worker → Configuration store: reads repository settings
- Service worker → Credential store: reads credentials
- Service worker → Sync manifest: reads and updates state
- Service worker → GitHub device auth: initiates login
- GitHub device auth → GitHub repository: Device Flow
- Service worker → LeetCode API: fetches supplemental data
- LeetCode API → LeetCode: API calls
- Submission history → Statistics aggregator: submission history
- Submission history → Solution Markdown builder: solution data
- Statistics aggregator → Dashboard builder: aggregate statistics
- Service worker → Solution Markdown builder: generates repository artifacts
- Service worker → Dashboard builder: generates dashboard
- Solution Markdown builder → GitHub client: solution files
- Dashboard builder → GitHub client: dashboard README
- GitHub client → GitHub repository: commits artifacts