A Chrome extension and Node.js backend for LeetCode hints with semantic retrieval.
- Real-time problem analysis
- Smart hint generation with Google Gemini Flash
- RAG retrieval with Gemini embeddings and Redis HNSW vector indexing
- Top-k similar problem injection into prompts
- Clean and modern UI
- Cloud Run deployment via Docker and GitHub Actions
- Node.js (v18 or higher)
- npm (v7 or higher)
- Clone the repository:
git clone https://github.com/yourusername/algo.git
cd algo- Install dependencies:
npm install
cd algo-backend && npm install- Build the extension:
npm run build- Load the extension in Chrome:
- Open Chrome and go to
chrome://extensions/ - Enable "Developer mode"
- Click "Load unpacked"
- Select the
distdirectory
- Run in development mode with hot reloading:
npm run dev- Type checking:
npm run type-check- Linting:
npm run lint- Testing:
npm run test- Backend tests:
cd algo-backend
npm test- Run backend benchmark:
cd algo-backend
npm run benchmarkalgo/
├── src/
│ ├── content.ts # Content script
│ ├── background.ts # Background script
│ ├── popup.ts # Popup script
│ ├── config.ts # API base URL config
│ ├── types.ts # Shared types
│ └── test/ # Test files
├── algo-backend/
│ ├── server.js # Express API
│ ├── src/services/cache.js # Redis hint cache
│ ├── src/services/vectorStore.js # Redis HNSW vector search
│ ├── Dockerfile
│ ├── docker-compose.yml
│ └── scripts/benchmark.js
├── dist/ # Compiled files
├── manifest.json # Extension manifest
├── popup.html # Popup HTML
├── styles.css # Styles
└── icons/ # Extension icons
Set the backend API URL at build time.
ALGO_API_BASE_URL=https://YOUR_CLOUD_RUN_URL npm run buildRequired backend environment variables:
- GEMINI_API_KEY
- REDIS_HOST
- REDIS_PORT
Optional backend environment variables:
- REDIS_PASSWORD
- EMBEDDING_DIM (default: 3072)
- RAG_TOP_K (default: 3)
- GET /healthz
- GET /readyz
- POST /api/index-problem
- POST /api/rag/search
- POST /api/hints
- Clean the build directory:
npm run clean- Build the extension:
npm run buildThe compiled files will be in the dist directory.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT