AI-powered tutoring overlay for LeetCode. Get step-by-step solutions, explanations, and learning insights while you solve problems on leetcode.com
. Built with React 19, TypeScript, Vite, and CRXJS.
- On-page tutor: Floating chat opens on LeetCode problem pages (
https://leetcode.com/problems/*
). - Understands context: Reads the page description and your current editor code to personalize help.
- Gemini streaming: Uses Google Gemini 2.5 Flash via
@ai-sdk/google
andai
for streamed responses. - Reasoning UI: Shows a collapsible “reasoning” trace plus a clean final answer.
- Session persistence: Messages are saved in
sessionStorage
for the current tab. - Modern UI: Tailwind V4 + Radix UI +
react-markdown
with KaTeX and code highlighting.
- Node.js 18+ (recommended)
- A Google Generative AI API key with access to Gemini
Create a .env
file in the project root:
# .env
VITE_GOOGLE_API_KEY=your_google_api_key
Never commit your real API key. .env
is read at build time by Vite.
- Clone the repository
# HTTPS
git clone https://github.com/lwshakib/algo-run-leetcode-tutor.git
cd algo-run-leetcode-tutor
# or SSH
# git clone git@github.com:lwshakib/algo-run-leetcode-tutor.git
# cd algo-run-leetcode-tutor
- Install dependencies
npm install
- Configure environment
echo VITE_GOOGLE_API_KEY=your_google_api_key > .env
- Develop and load in Chrome
npm run dev
- In Chrome, open
chrome://extensions/
- Enable Developer mode
- Click “Load unpacked” and select the
dist
folder - Open any LeetCode problem page and click the chat button (bottom-right)
- Build production
npm run build
This produces a production dist/
and a distributable zip at release/crx-<name>-<version>.zip
.
manifest.config.ts
defines the MV3 manifest using CRXJS. It injectssrc/content/main.tsx
onhttps://leetcode.com/problems/*
and exposeslogo.svg
as a web resource. The extension name/description come frompackage.json
.src/content/main.tsx
mounts the app container into the page.src/content/views/App.tsx
renders the chat toggle button and passes the problem statement from the page’s<meta name="description">
.src/components/FloatingChatBox.tsx
streams responses from Gemini usingstreamText
, with toolsgoogle_search
andurl_context
. It builds a system prompt fromsrc/lib/prompt.ts
and collects:- Problem statement (page meta)
- Current programming language (detected from the language switch button)
- Your current code from the LeetCode editor (
.view-line
nodes viaextractCode
insrc/lib/utils.ts
)
src/lib/model.ts
initializes Google GenAI withVITE_GOOGLE_API_KEY
and selectsgemini-2.5-flash
.src/hooks/useSessionStorage.tsx
debounces and saves messages tosessionStorage
.vite.config.ts
sets alias@
→src
, enables React, CRXJS, Tailwind V4, and emits a versioned release zip.
- permissions:
contentSettings
- content_scripts: matches
https://leetcode.com/problems/*
- web_accessible_resources:
logo.svg
These are configured in manifest.config.ts
and generated by CRXJS at build time.
- dev: Vite watch build for the extension
- build: Type-check + Vite production build
- preview: Vite static preview (useful for popup/sidepanel HTML testing)
npm run dev
npm run build
npm run preview
src/content/
– Injected content UI for LeetCode pagessrc/components/
– Chat UI, AI elements, and UI primitivessrc/lib/
– Model setup, prompts, types, utilitiessrc/hooks/
– Custom hooks (session storage)src/popup/
– Popup app (not injected by default in production)src/sidepanel/
– Side panel app (optional)manifest.config.ts
– MV3 manifest builderpublic/
– Extension icons and assets
- Ensure you’re on a problem page. The chat button appears bottom-right.
- If responses are empty or not streaming, double-check
VITE_GOOGLE_API_KEY
and Chrome console for errors. - If your code isn’t detected, make sure the LeetCode editor is visible. The extension scrapes
.view-line
elements. - Page structure changes on LeetCode can break selectors. Update them in
FloatingChatBox.tsx
andutils.ts
if needed.
- The alias
@
points tosrc
(seevite.config.ts
). - Tailwind V4 is enabled via
@tailwindcss/vite
plugin. - Streaming uses
ai
SDK’sstreamText
. Markdown is rendered via a hardenedreact-markdown
with KaTeX support.
- Currently scoped to LeetCode problem pages only.
- Depends on LeetCode DOM; minor upstream changes may require selector updates.
- No backend; everything runs in the browser with your API key.
Add your preferred license here (e.g., MIT). If you include a LICENSE
file, reference it here.