digital-brain
What was I working on yesterday related to RAG?
Which website did I spend the most time on last week?
What was that command I copied to clear the terminal?
Digital Brain captures your Chrome browsing activity β page visits, text selections, copy/paste events, page content, and time spent β stores it 100% locally, and lets you search and ask questions using AI. It combines keyword search (SQLite FTS5) with semantic search (ChromaDB vectors) through a RAG pipeline powered by a local LLM.
β¨ Features
Feature | Description |
π§© Chrome Extension | Captures page visits, selections, copy/paste, page content, and tab focus time |
β‘ FastAPI Backend | Receives, stores, and indexes events locally on |
π Full-Text Search | SQLite FTS5 keyword search with highlighted snippets and filters |
𧬠Vector Search | ChromaDB semantic indexing for meaning-based recall |
π€ RAG Q&A | Ask questions in plain English β uses local LLM to generate answers |
π Activity Stats | Top domains by time spent, daily breakdowns, and event timelines |
π» CLI Tool | Rich terminal interface with |
π MCP Server | Query your history from Claude Desktop, VS Code, or any MCP client |
π‘οΈ Privacy-First | All data stays on your machine β no cloud, no tracking |
π Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Chrome Browser β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Chrome Extension (Manifest V3) β β
β β βββββββββββββββ ββββββββββββββββββ βββββββββββββββββββββ β β
β β β Content.js β β Background.js β β Popup UI β β β
β β β β’ Selectionsβ β β’ Tab tracking β β β’ Toggle on/off β β β
β β β β’ Copy/Pasteβ β β’ Event queue β β β’ View stats β β β
β β β β’ Page text β β β’ Batch flush β β β’ Sync now β β β
β β ββββββββ¬βββββββ βββββββββ¬βββββββββ βββββββββββββββββββββ β β
β βββββββββββΌββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ β
ββββββββββββββΌββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β chrome.runtime β
ββββββββββ¬βββββββββ
β POST /api/events (batch every 30s)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Local Backend (Python) β
β β
β ββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β FastAPI ββββΆβ Event ββββΆβ SQLite+FTS5 β β
β β Server β β Processor β β (structured) β β
β β :8420 β β dedup+domain β ββββββββββββββββ β
β ββββββββββββ ββββββββ¬ββββββββ β
β β β ββββββββββββββββ β
β β βββββββββββΆβ ChromaDB β β
β β β (semantic) β β
β βΌ ββββββββ¬ββββββββ β
β ββββββββββββ β β
β β RAG βββββββ vector search ββββββββ β
β β Pipeline βββββββ FTS5 search βββββββββ β
β ββββββ¬ββββββ β
β β β
β βΌ β
β ββββββββββββ β
β β LLM β Ollama (local, free) or OpenRouter (cloud) β
β ββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β² β² β²
β β β
ββββββ΄βββββ βββββββ΄ββββββ βββββββ΄ββββββ
β CLI β β MCP Serverβ β REST API β
β $ brain β β Claude/ β β curl/apps β
β search β β VS Code β β β
βββββββββββ βββββββββββββ βββββββββββββπ Quick Start
Prerequisites
Python 3.10+
Google Chrome (latest)
Ollama (optional β for AI-powered answers)
1. Clone & Install
git clone https://github.com/ArpitaSethi-12/digital-brain.git
cd digital-brain
pip install -e .2. Start the Backend
python -m backend.mainDigital Brain backend is ready π§
Server running at http://localhost:84203. Install the Chrome Extension
Open
chrome://extensions/in ChromeEnable Developer mode (top-right toggle)
Click Load unpacked β select the
extension/directoryThe π§ icon appears in your toolbar
4. (Optional) Install Ollama for AI Answers
# Install Ollama from https://ollama.com
ollama serve
ollama pull llama3.2Without Ollama, Digital Brain still works β it returns retrieved results instead of generated answers.
5. Start Browsing!
Open any website. The extension captures your activity in the background. Then query it:
brain search "python tutorial"
brain ask "What was I reading about yesterday?"
brain statsπ» CLI Usage
Digital Brain ships with a CLI built on Typer + Rich:
Search
# Basic search
brain search "RAG pipeline"
# Filter by event type
brain search "terminal command" --type copy
# Filter by domain
brain search "react hooks" --domain github.com
# Filter by time window
brain search "python" --last 7d # last 7 days
brain search "docker" --last 24h # last 24 hours
brain search "AI paper" --last 2w # last 2 weeksAsk (RAG Q&A)
brain ask "What was I working on yesterday related to RAG?"
brain ask "What command did I copy to clear the terminal?" --type copy
brain ask "Which website did I spend the most time on?" --last 7d
brain ask "Summarize what I read about transformers" --no-llm # skip LLMStats & Activity
brain stats # top domains + weekly activity
brain stats --period month # monthly breakdown
brain activity # today's timeline
brain activity --date yesterday
brain activity --date 2026-06-01System
brain status # backend health + LLM availability
brain reindex # rebuild vector index from SQLiteπ MCP Server
Digital Brain includes an MCP (Model Context Protocol) server that lets AI assistants query your browsing history directly.
How It Works
You: "What was I working on yesterday related to RAG?"
Claude: β calls search_history("RAG", last="1d")
β Digital Brain searches local SQLite + ChromaDB
Claude: "Yesterday you visited 3 pages about RAG pipelines..."Available Tools
Tool | Description |
| Keyword search with type/domain/time filters |
| RAG-powered natural language Q&A |
| Top domains and activity breakdown |
| Day's chronological timeline |
| Detailed event feed with full content |
| Backend health + LLM status |
Setup with Claude Desktop
Start the backend:
python -m backend.mainAdd to
~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"digital-brain": {
"command": "python3",
"args": ["/absolute/path/to/digital-brain/mcp_server.py"]
}
}
}Restart Claude Desktop β the π§ tools appear automatically.
Setup with VS Code
Add to .vscode/settings.json:
{
"mcp": {
"servers": {
"digital-brain": {
"command": "python3",
"args": ["/absolute/path/to/digital-brain/mcp_server.py"]
}
}
}
}Test with MCP Inspector
npx -y @modelcontextprotocol/inspector python3 mcp_server.pyπ‘ API Reference
The backend exposes a REST API at http://localhost:8420:
Method | Endpoint | Description |
|
| Backend health status |
|
| Ingest event batch from extension |
|
| Full-text search with filters |
|
| RAG question answering |
|
| RAG via query string |
|
| Top domains by time spent |
|
| Daily event breakdown |
|
| Event timeline for a date |
|
| Rebuild vector index |
|
| Check LLM availability |
Example: Ask a Question
curl -X POST http://localhost:8420/api/ask \
-H "Content-Type: application/json" \
-d '{"question": "What did I copy about clearing the terminal?"}'Response:
{
"answer": "You copied the command 'clear && printf ...' from Stack Overflow.",
"sources": [
{
"event_type": "copy",
"domain": "stackoverflow.com",
"content": "clear && printf '\\e[3J'"
}
],
"llm_used": true,
"retrieval_count": 3
}Example: Search History
curl "http://localhost:8420/api/search?q=RAG&event_type=page_visit&limit=5"π Project Structure
digital-brain/
βββ extension/ # Chrome Extension (Manifest V3)
β βββ manifest.json # Permissions & config
β βββ background.js # Service worker β event batching, tab tracking
β βββ content.js # Content script β selections, copy/paste, page text
β βββ popup.html/js/css # Extension popup UI
β βββ icons/ # Extension icons
β
βββ backend/ # Python FastAPI Backend
β βββ main.py # App entry point with CORS & lifespan
β βββ config.py # Environment-based configuration
β βββ models.py # 13 Pydantic models (API contract)
β βββ database.py # SQLite + FTS5 (schema, CRUD, search)
β βββ routers/
β β βββ events.py # POST /api/events
β β βββ search.py # GET /api/search
β β βββ stats.py # GET /api/stats/*
β β βββ ask.py # POST /api/ask + index rebuild
β βββ services/
β βββ event_processor.py # Validate, dedup, extract domains
β βββ vector_store.py # ChromaDB operations
β βββ rag.py # RAG pipeline (vector + FTS β LLM)
β βββ llm.py # Ollama / OpenRouter client
β βββ indexer.py # Vector index rebuild
β
βββ cli/
β βββ brain.py # Typer + Rich CLI (6 commands)
β
βββ mcp_server.py # MCP server (6 tools for AI assistants)
β
βββ data/ # Local storage (auto-created, gitignored)
β βββ brain.db # SQLite database + FTS5 index
β βββ chroma/ # ChromaDB vector store
β
βββ .env.example # Environment variable template
βββ pyproject.toml # Project config & dependencies
βββ README.mdβοΈ Configuration
Copy the example and customize:
cp .env.example .envVariable | Default | Description |
|
| Backend host |
|
| Backend port |
|
| Storage directory |
|
|
|
|
| Ollama server URL |
|
| Ollama model name |
| β | OpenRouter API key (optional) |
|
| Number of results for RAG context |
𧬠How RAG Works
User: "What command did I copy to clear the terminal?"
β
ββββΆ ChromaDB Semantic Search
β Finds events with similar meaning
β (e.g., "bash clear screen" matches "terminal command")
β
ββββΆ SQLite FTS5 Keyword Search
β Finds events containing exact words
β (e.g., "clear" AND "terminal")
β
ββββΆ Merge & Deduplicate
β Combines both result sets by event ID
β
ββββΆ Format Context Block
β Prepares retrieved events as LLM context
β
ββββΆ LLM Generation (Ollama)
Generates natural language answer
grounded in your actual browsing data
Result: "You copied 'clear && printf \\e[3J' from stackoverflow.com on June 8th."π‘οΈ Privacy
Digital Brain is privacy-first by design:
β All data stored locally in
data/directoryβ Chrome extension only communicates with
localhost:8420β MCP server runs locally via stdio β no network requests
β LLM runs locally via Ollama β your data never leaves your machine
β No analytics, no telemetry, no cloud sync
β οΈ OpenRouter is optional and only used if you explicitly set
OPENROUTER_API_KEY
π οΈ Tech Stack
Layer | Technology |
Data Capture | Chrome Extension (Manifest V3) |
Backend | Python 3.10+ Β· FastAPI Β· Uvicorn |
Structured DB | SQLite 3 + FTS5 |
Vector DB | ChromaDB (all-MiniLM-L6-v2 embeddings) |
Local LLM | Ollama (llama3.2) |
Cloud LLM | OpenRouter (optional) |
CLI | Typer + Rich |
MCP | FastMCP (mcp SDK) |
Validation | Pydantic v2 |
HTTP Client | httpx (async) |
π Project Stats
Metric | Value |
Total Lines of Code | ~3,800 |
Python Files | 18 |
JavaScript Files | 3 |
API Endpoints | 10 |
CLI Commands | 6 |
MCP Tools | 6 |
Pydantic Models | 13 |
Event Types Captured | 6 |
Dependencies | 10 |
πΊοΈ Roadmap
π Web chat UI with streaming responses
π Smarter date parsing ("yesterday", "last week") in RAG
π Optional encryption at rest for
data/π MCP Registry listing
π± Firefox extension
π§ Multi-turn conversation memory
π¦ PyPI package (
pip install digital-brain)
π€ Contributing
Contributions are welcome! Here's how:
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
π License
This project is licensed under the MIT License β see the LICENSE file for details.