Architecture
HAEVN is a Chrome Manifest V3 extension. The key architectural constraint is that MV3 service workers cannot spawn Web Workers — HAEVN works around this with a three-tier architecture.
Three-tier worker model
Section titled “Three-tier worker model”Service Worker (background.js) ↓ chrome.runtime messagesOffscreen Document (offscreen.html) ↓ postMessageWeb Workers (search.worker, stats.worker, ...)- Service Worker — handles all Chrome extension events (tab changes, alarms, messages from content scripts and popup)
- Offscreen Document — a hidden HTML page that lives for 30 seconds after last use; hosts the Web Workers
- Web Workers — CPU-intensive operations: search indexing, ZIP generation, stats calculation, thumbnail generation
Data pipeline
Section titled “Data pipeline”Every sync follows this path:
Platform (DOM/API) → Extractor → Transformer → HAEVN.Chat → Repository → Search Index- Extractor — platform-specific code that fetches raw data (API calls or DOM scraping)
- Transformer — normalizes raw data into the
HAEVN.Chatformat - Repository (SyncService) — persists to IndexedDB via Dexie, triggers OPFS writes for media
- Search Index — Lunr.js index updated via the search Web Worker
Key directories
Section titled “Key directories”| Path | Purpose |
|---|---|
src/providers/{platform}/ | Extractor + Transformer for each platform |
src/background/handlers/ | Message routing (82 handlers) |
src/services/ | ChatRepository, SearchIndexManager, SearchService |
src/offscreen/ | Offscreen document + worker pool |
src/popup/ | Extension popup UI |
src/options/ | Archive manager UI |
src/viewer/ | Standalone conversation viewer |
src/content/ | Content script injected into platform pages |
See the charter/architecture/ directory in the repo for detailed architecture documents and Mermaid diagrams.