Home
Relevant source files
The following files were used as context for generating this wiki page:Read Frog is an open-source, AI-powered browser extension designed for immersive language learning. It transforms web reading into an educational experience by providing in-context translation, detailed article analysis, and vocabulary explanations. The project's vision is to offer an intelligent, personalized language learning tool that reduces reliance on traditional instruction methods.
The extension is built with a modern tech stack, emphasizing modularity and extensibility. It supports a wide range of AI models and provides extensive configuration options, allowing users to tailor the experience to their needs. This document provides a high-level overview of the project's features, architecture, and core functionalities.
Key Features
Read Frog offers a suite of features to facilitate language learning directly within the browser.
| Feature | Description |
|---|---|
| Immersive Translation | Translates web page elements directly adjacent to the original text, offering bilingual or translation-only views. |
| Smart Content Extraction | Automatically identifies and extracts the main content from articles, filtering out ads and boilerplate. |
| Comprehensive Explanations | Uses AI to provide detailed explanations of words, phrases, and sentences tailored to the user's specified language level. |
| Contextual Learning | Enables users to learn languages through content they are genuinely interested in, such as news and articles. |
| Multiple AI Models | Integrates with over 20 AI providers, including OpenAI, DeepSeek, Google Gemini, and local models via Ollama. |
| AI Smart Context | Improves translation quality by providing the AI with the context of the entire article. |
| Text-to-Speech (TTS) | Allows users to listen to text being read aloud, with customizable voice and speed settings. |
Sources: README.md:63-70, src/locales/en.yml:20, 230, 244
Architecture
Read Frog is a Manifest V3 browser extension built using the WXT framework. The architecture is designed to be modular, following SOLID principles and a functional-leaning approach with clear boundaries.
Sources: CLAUDE.md:5-19, 100-101
Tech Stack
The project utilizes a modern set of technologies:
- Framework: WXT (Vite-based)
- UI: React 19, TailwindCSS 4, Radix UI, shadcn/ui
- Language: TypeScript
- State Management: Jotai with a custom storage adapter for
browser.storage - Local Database: Dexie.js (IndexedDB wrapper)
- AI Integration: Vercel AI SDK
- Testing: Vitest
Sources: CLAUDE.md:100-108, package.json:28-91
Extension Structure
The extension is organized into several entrypoints, each serving a specific purpose. This modular structure is defined by the WXT framework.
The diagram below illustrates the main entrypoints and their roles.
*background**: The service worker that manages the extension's lifecycle, message routing, and background tasks.
*.content: Content scripts injected into web pages. This includeshost.contentfor the main reading UI andside.contentfor the side panel.popup: The UI for the extension's popup window.options: The multi-page React app for all user settings.
Sources: CLAUDE.md:113-126, wxt.config.ts:6-8
Core Feature: Article Reading and Analysis
The "Read Article" feature is a central part of Read Frog. It involves extracting content from a webpage, analyzing it with an AI model, and then generating a detailed, sentence-by-sentence explanation.
Process Flow
The process is initiated when a user clicks the "Read" button in the side panel. It follows a multi-step, asynchronous flow managed by React Query mutations.
This sequence diagram shows the interaction between the UI, hooks, and the AI service.
The key hooks involved are:
useReadArticle: Orchestrates the entire process.useAnalyzeContent: Sends the article text to an AI to get a summary and determine if it's an article.useExplainArticle: Sends paragraphs in batches to the AI to generate detailed explanations. Content is batched to respect token limits and improve reliability, with a maximum of 1000 characters per batch request.
Sources: src/hooks/read/read.tsx:18-23, 150-184, src/entrypoints/side.content/components/side-content/content.tsx:29-41
Side Panel UI
The side.content entrypoint renders the main user interface for the article reading feature. It appears as a panel on the right side of the webpage.
Component Structure
The side panel is composed of several React components that manage state and display information.
This diagram shows the component hierarchy within the side panel.
*SideContent**: The root component that manages the panel's visibility, width, and resizing logic. It injects a <style> tag into the page to shift the <html> element's width, preventing the panel from overlapping content.
Metadata: Displays the page title, favicon, and the main "Read" / "Regenerate" button.Content: A state machine component that displays the current status of the reading process (e.g., "Extracting content...", "Analyzing...", "Generating...") and renders the finalExplanationcomponent.Explanation: Renders the structured explanation of the article, including original sentences, translations, key words, and grammar explanations.
Sources: src/entrypoints/side.content/components/side-content/index.tsx, src/entrypoints/side.content/components/side-content/content.tsx, src/entrypoints/side.content/components/side-content/metadata.tsx
Development
The project is managed with pnpm and includes a set of scripts for common development tasks.
| Command | Description |
|---|---|
pnpm dev | Starts the development server for Chrome. |
pnpm build | Creates a production build of the extension. |
pnpm test | Runs all tests using Vitest. |
pnpm test:cov | Runs tests and generates a coverage report. |
pnpm lint | Lints the codebase with ESLint. |
pnpm type-check | Performs a static type check with TypeScript. |
Sources: package.json:7-24, CLAUDE.md:110-141