How jraversbcn21/hoverlingo works
HoverLingo is a browser extension that translates words or selected phrases in page-context tooltips. The main flow is hover detection, text extraction, cache lookup, background translation through Groq, and tooltip display; the popup configures settings and exposes controls and usage statistics. The graph also preserves sentence translation, highlighting, and persistent caching. Some wiring is only partially sampled, so unverified links are dashed and evidence is limited to the shown excerpts or README.
Main entry points: index.ts Content Orchestrator · service-worker.ts Background Worker · popup.ts Settings Popup · tooltip-renderer.ts Tooltip Renderer
Components 20
Page Translation
- Hover Detection
src/content/hover-detector.ts - Text Extraction
src/content/text-extractor.ts - Content Orchestrator
src/content/index.ts - Word Highlight
src/content/word-highlight.ts - Tooltip Renderer
src/content/tooltip-renderer.ts
Translation Runtime
- Memory Cache
src/content/cache-l1.ts - Background Worker
src/background/service-worker.ts - Persistent Cache
src/background/cache-l2.ts
Settings and Usage
- Settings Popup
src/popup/popup.ts - Popup Locales
public/_locales
Shared Logic
- Prompt Builder
src/shared/prompts.ts - Cache Key
src/shared/cache-key.ts - Response Parser
src/shared/extract-json.ts - Settings Validation
src/shared/settings-validation.ts - Translation Types
src/shared/types.ts - Runtime Constants
src/shared/constants.ts
Other components
- User
- Web Page
- Groq AI
- Browser Storage
Connections 22
- User → Web Page: hovers or selects
README.md - Web Page → Hover Detection: provides pointer events
- Content Orchestrator → Hover Detection: configures
src/content/index.ts - Content Orchestrator → Text Extraction: extracts text
src/content/index.ts - Content Orchestrator → Word Highlight: uses
src/content/index.ts - Content Orchestrator → Tooltip Renderer: renders results
src/content/index.ts - Content Orchestrator → Memory Cache: checks cache
src/content/index.ts - Content Orchestrator → Cache Key: builds keys
src/content/index.ts - Content Orchestrator → Background Worker: requests translations
- Tooltip Renderer → Memory Cache: reads pending results
src/content/tooltip-renderer.ts - Background Worker → Persistent Cache: checks cache
src/background/service-worker.ts - Background Worker → Prompt Builder: builds prompts
src/background/service-worker.ts - Background Worker → Cache Key: builds keys
src/background/service-worker.ts - Background Worker → Groq AI: sends translation requests
src/background/service-worker.ts - Background Worker → Response Parser: parses responses
src/background/service-worker.ts - Background Worker → Browser Storage: reads settings
src/background/service-worker.ts - Settings Popup → Browser Storage: loads and saves
src/popup/popup.ts - Settings Popup → Settings Validation: validates imports
src/popup/popup.ts - Settings Popup → Popup Locales: uses localized messages
README.md - Content Orchestrator → Browser Storage: reads settings and records stats
src/content/index.ts - User → Settings Popup: configures extension
README.md - Content Orchestrator → Tooltip Renderer: translates sentences on demand
README.md