A universal AI-powered recommendation engine delivered as a Chrome Extension. RecoBase understands any webpage you're browsing and provides intelligent, context-aware recommendations in real time.
RecoBase is a full-stack AI recommendation system that works as a Chrome Extension. Unlike traditional recommendation engines that require pre-built product catalogs, RecoBase builds a real-time semantic understanding of your browsing session using transformer embeddings and FAISS vector search, augmented by Google Gemini's generative AI for comprehensive recommendations.
This is a standalone portfolio implementation demonstrating full-stack engineering across browser extensions, backend APIs, vector databases, and large language model integration. It captures context intelligently without intruding on the browsing experience.
Existing recommendation systems are fundamentally constrained by domain walls. They are:
- Platform-locked: Amazon recommends products on Amazon; Netflix recommends movies on Netflix.
- Data-hungry: They rely heavily on collaborative filtering which requires massive historical user data matrices.
- Siloed: Unable to synthesize intent across disparate browsing sessions or cross-domain content.
- Inaccessible: Not available to users as a proactive, browser-level assistant that travels with them.
RecoBase provides a universal recommendation layer that transcends domain boundaries. It:
- Works Universally: Operates on ANY webpage โ products, articles, videos, recipes, news.
- Intelligently Extracts: Employs a robust 4-layer DOM extraction engine to capture semantics regardless of site structure.
- Builds Ephemeral Memory: Creates per-session semantic memory dynamically using FAISS and
sentence-transformers. - Leverages LLMs: Synthesizes retrieved context with Gemini RAG for intelligent, natural-language recommendations.
- Integrates Smoothly: Delivers insights through a polished, non-intrusive React-based browser panel using Shadow DOM.
graph TD
subgraph Browser["Client (Chrome Extension)"]
CS[Content Script]
UI[React Shadow DOM Panel]
BG[Background Service Worker]
end
subgraph Backend["FastAPI Backend (Docker)"]
API[REST API Layer]
EXT[Extraction Engine]
RAG[Gemini RAG Pipeline]
VEC[Embedding Service]
end
subgraph Data["Storage Layer"]
REDIS[(Redis)]
FAISS[(FAISS Index)]
end
CS -->|1. Extract DOM Context| BG
BG -->|2. POST /track| API
API --> EXT
EXT -->|Structured Data| REDIS
EXT --> VEC
VEC --> FAISS
UI -->|3. GET /recommend| BG
BG --> API
API --> FAISS
FAISS -->|Similar Context| RAG
RAG -->|LLM Completion| API
API --> UI
The system follows a scalable layered architecture designed for separation of concerns and high performance:
- Presentation Layer: A React-based Chrome Extension injecting a floating panel. It uses Shadow DOM to prevent CSS conflicts with host pages.
- Extraction Layer: A 4-stage heuristic engine processing structured (JSON-LD, Open Graph) and unstructured HTML data into standardized schemas.
- API Layer: Fast, async FastAPI REST endpoints validating payloads with Pydantic v2.
- Storage Layer: Redis handles fast session tracking, rate limiting, and state, while FAISS maintains dense vector indexes.
- Intelligence Layer: Uses
sentence-transformers/all-MiniLM-L6-v2for localized embeddings, feeding into a Gemini-powered Retrieval-Augmented Generation (RAG) system.
- ๐ Universal Context Extraction: Gracefully degrades through JSON-LD, Open Graph, meta tags, and raw DOM heuristics.
- ๐ง Dynamic Semantic Memory: FAISS indices built on-the-fly per session. No pre-training needed.
- ๐ค Generative RAG: Google Gemini API integration to synthesize contextual recommendations.
- ๐จ Robust UI: React 18 frontend with Shadow DOM isolation, skeleton loaders, and error boundaries.
- โก Resilience: Automatic retry logic and graceful degradation if APIs are rate-limited.
- ๐ Secure Design: Environment variable configuration. No API keys shipped in extension code.
- ๐ณ Containerized Deployment: Docker Compose for deterministic, one-command local setup.
- ๐ Progressive Enrichment: Recommendations adapt in real-time as you browse more pages.
| Layer | Technology |
|---|---|
| Extension | React 18, Vite, CRXJS, Chrome Manifest V3, Shadow DOM CSS |
| Backend | Python 3.11, FastAPI, Uvicorn, Pydantic v2 |
| AI/ML | sentence-transformers/all-MiniLM-L6-v2, FAISS, Google Gemini |
| Storage | Redis 7 |
| Infrastructure | Docker, Docker Compose |
- Browsing: The user navigates to a webpage. The extension's content script quietly observes.
- Extraction: A multi-layered parsing script scans the page for metadata (JSON-LD, Open Graph, DOM heuristics) to build a semantic profile of the content.
- Tracking: The extracted profile is sent to the backend
/trackendpoint via the Background Service Worker. - Embedding: The backend vectorizes the text using
sentence-transformersand updates the active session's FAISS index. - Recommendation Request: When the user opens the RecoBase panel, a
/recommendrequest is dispatched. - RAG Pipeline: The backend retrieves top-k similar contexts from FAISS for the session, crafts a tailored prompt, and queries Google Gemini.
- Delivery: The synthesized recommendations are streamed back and beautifully rendered in the React UI.
The extension is built on Manifest V3, adhering to modern security standards. It consists of:
- Content Script: Injected into every page to perform DOM extraction without affecting page performance.
- Background Service Worker: Manages state, handles communication with the backend API, and routes messages.
- Shadow DOM UI: The React interface is mounted inside a Shadow DOM root. This guarantees that host page styles (like Wikipedia or Amazon) do not leak into the RecoBase UI, and vice versa.
Relying on a single source of truth is brittle. RecoBase employs a cascading 4-layer extraction strategy:
- JSON-LD: High precision, standardized schema data often found on modern e-commerce and media sites.
- Open Graph: Social sharing metadata (
og:title,og:description), reliable for news and blogs. - Meta Tags: Fallback standard HTML tags (
<title>,<meta name="description">). - DOM Heuristics: Custom logic extracting
<article>,<h1>, and main body paragraphs if structured data is absent.
RecoBase utilizes a dual-path architecture to ensure relevance and quality without needing a static database.
Instead of collaborative filtering across millions of users, RecoBase builds a personal semantic space per session. As you browse, FAISS creates dense vectors of page content. This allows the system to instantly recall structurally similar or semantically related pages you've visited recently to form context.
The raw vectors lack human intuition. We take the top results from FAISS and inject them into a structured prompt for Google Gemini. Gemini acts as the reasoning engine, understanding the explicit relationships (e.g., "The user is looking at hiking boots and previously viewed waterproof jackets") to generate actionable, cross-domain recommendations.
Redis acts as the high-speed caching and state management tier. It stores:
- Session IDs: Correlating requests to specific user sessions.
- Browsing History: A fast-access list of recently visited URLs and their basic metadata.
- Rate Limits: Preventing abuse of the AI endpoints.
- TTL: Sessions automatically expire, ensuring privacy and keeping memory footprint low.
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check with Redis and model status |
POST |
/api/v1/extension/track |
Track current page context and update session vectors |
GET |
/api/v1/extension/recommend |
Get contextual recommendations based on session memory |
(See docs/api.md for full request/response schemas)
reco-base/
โโโ backend/
โ โโโ app/
โ โ โโโ api/
โ โ โ โโโ routes/ # FastAPI route handlers
โ โ โโโ schemas/ # Pydantic request/response models
โ โ โโโ services/ # Redis, FAISS, Gemini, Embedding, Recommendation
โ โ โโโ utils/ # Input sanitization
โ โ โโโ config.py # pydantic-settings configuration
โ โ โโโ main.py # App entry point, lifespan, CORS
โ โโโ tests/ # pytest test suite
โ โโโ Dockerfile
โ โโโ requirements.txt
โโโ extension/
โ โโโ src/
โ โ โโโ background/ # Service worker (message routing)
โ โ โโโ content/ # React app mounted in Shadow DOM
โ โ โ โโโ components/ # RecoPanel, RecoCard, LoadingSkeleton, etc.
โ โ โ โโโ styles/ # Scoped panel CSS
โ โ โโโ extractors/ # 4-layer DOM extraction engine
โ โ โโโ popup/ # Extension popup UI (React)
โ โ โโโ services/ # API client, session management
โ โโโ manifest.json
โ โโโ package.json
โ โโโ vite.config.js
โโโ docker/ # Redis config
โโโ docs/ # API, architecture, extraction docs
โโโ data/ # Generated data (gitignored)
โโโ .env.example
โโโ docker-compose.yml
โโโ README.md
- Python 3.11+
- Node.js 18+
- Docker & Docker Compose
- Google Gemini API key
- Clone the repository
git clone https://github.com/yourusername/reco-base.git cd reco-base - Setup environment variables
cp .env.example .env # Edit .env and add your GEMINI_API_KEY - Start the backend services
docker-compose up -d
- Build the extension
cd extension npm install npm run build - Load in Chrome:
- Navigate to
chrome://extensions - Enable Developer Mode
- Click Load Unpacked
- Select the
extension/distfolder
- Navigate to
- Navigate to any webpage and click the RecoBase icon!
| Variable | Description | Default |
|---|---|---|
GEMINI_API_KEY |
Required. API key for Google Gemini | โ |
GEMINI_MODEL |
Gemini model to use | gemini-2.0-flash |
REDIS_HOST |
Redis server hostname | localhost |
REDIS_PORT |
Redis server port | 6379 |
REDIS_DB |
Redis database number | 0 |
REDIS_TTL_SECONDS |
Session TTL in seconds | 1800 |
BACKEND_HOST |
FastAPI bind host | 0.0.0.0 |
BACKEND_PORT |
FastAPI bind port | 8000 |
BACKEND_CORS_ORIGINS |
Allowed CORS origins (comma-separated) | chrome-extension://* |
EMBEDDING_MODEL |
Sentence Transformer model name | sentence-transformers/all-MiniLM-L6-v2 |
MAX_HISTORY_LENGTH |
Max pages tracked per session | 50 |
The backend features a comprehensive test suite using pytest.
cd backend
pip install -r requirements.txt
pytest -v- Open a clean Chrome profile.
- Load the extension.
- Browse 3 distinct e-commerce products.
- Verify backend logs for successful
/trackcalls. - Open the RecoBase panel; verify recommendations synthesize the 3 products.
Screenshots will be added after the extension UI is finalized.
Actual measurements to be recorded during load testing.
| Metric | Target |
|---|---|
| DOM extraction | < 100ms |
| Backend response (cached) | < 500ms |
| Gemini recommendation | 1-3s (depends on API) |
| Panel render | < 50ms |
- Extraction accuracy heavily depends on the target site adhering to web standards. Single Page Applications (SPAs) without SSR may yield sparse data.
- FAISS vectors are kept purely in memory/Redis per session and are volatile by design; long-term user profiling is intentionally out of scope for this version.
- LLM generation latency is bound by Google Gemini's API response times.
- Streaming RAG responses via WebSockets or Server-Sent Events (SSE) to reduce perceived latency.
- Expanding vector dimensions for more granular semantic capture.
- Adding site-specific extraction adapters for complex sites (e.g., YouTube video transcripts).
- Persisting anonymized semantic clusters for global trending recommendations.
Aditya Bansode
This is a standalone personal portfolio implementation of the RecoBase concept. I am the sole developer of every component โ Chrome Extension, DOM extraction, FastAPI backend, Redis integration, FAISS session memory, Gemini RAG pipeline, testing, Docker configuration, and documentation.
MIT License โ see LICENSE