Contribution Guide
Relevant source files
The following files were used as context for generating this wiki page:
Welcome to the Read Frog contribution guide! This document provides all the information you need to contribute to the project, from setting up your development environment to understanding the architecture and submitting your changes. Contributions of all types are welcome, including promoting the extension, reporting issues, and contributing code.
The project's vision is to provide an easy-to-use, intelligent, and personalized language learning experience. By contributing, you are helping to build a tool that could make the world less reliant on human language instructors.
Sources: README.md:21-24, README.md:104-107
Getting Started
To start contributing code, you'll need to set up the development environment on your local machine. The project uses pnpm as its package manager.
-
Clone the repository:
git clone https://github.com/mengxi-ream/read-frog.git cd read-frog -
Install dependencies:
pnpm installThis command also runs
wxt prepareto set up the necessary types for the WXT framework.
Sources: package.json:13, CLAUDE.md:120 -
Run the development server:
pnpm devThis command starts the development mode for Chrome by default. You can then load the extension in your browser from the
.output/chrome-mv3directory.
Sources: package.json:10, CLAUDE.md:113
Project Architecture
Read Frog is a browser extension built using the WXT framework, which provides a modern, Vite-based environment for developing Manifest V3 extensions. The architecture is organized around WXT's entrypoints pattern.
Sources: CLAUDE.md:103, CLAUDE.md:126
The following diagram illustrates the main entrypoints and their roles:
This diagram shows the different entrypoints of the extension and how they interact with each other and the web page.
Key Components
src/entrypoints/background/: The background service worker. It handles the extension lifecycle, message routing between different parts of the extension, and manages background tasks like translation queues and configuration backups.src/entrypoints/*.content/: A collection of content scripts that are injected into web pages. Each serves a specific purpose:host.content: The main UI for article reading and analysis.selection.content: The popup that appears for text selection translation.side.content: The side panel interface.guide.content: The overlay for the onboarding guide.
src/entrypoints/popup/: The React application for the extension's popup UI.src/entrypoints/options/: The multi-page React application for the extension's settings page.
Sources: CLAUDE.md:128-141
Design Principles
The project adheres to a set of core design principles to maintain code quality, scalability, and maintainability. Contributors are expected to follow these principles.
- SOLID:
- Single Responsibility Principle
- Open/Closed Principle (extension via composition)
- Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
- DRY, KISS, YAGNI:
- Don't Repeat Yourself
- Keep It Simple, Stupid
- You Ain't Gonna Need It
- Functional Lean:
- Prefer pure functions and immutability.
- Maintain clear boundaries using a ports and adapters (hexagonal) approach.
Sources: CLAUDE.md:7-20
Development Workflow
Development Commands
The package.json file contains various scripts for common development tasks.
| Command | Description |
|---|---|
pnpm dev | Starts the development server for Chrome. |
pnpm dev:edge | Starts the development server for Microsoft Edge. |
pnpm test | Runs all tests using Vitest. |
pnpm test:cov | Runs tests and generates a coverage report. |
pnpm lint | Lints the codebase for style and error checking. |
pnpm build | Creates a production build of the extension. |
pnpm zip | Creates a zipped package of the production build for distribution. |
pnpm type-check | Runs the TypeScript compiler to check for type errors. |
Sources: package.json:8-18, CLAUDE.md:112-124
Commit Conventions
The project follows the Conventional Commits specification. This is enforced by commitlint and husky pre-commit hooks.
Standard Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
Custom Types:
i18n: For updates to internationalization and locale files.ai: For changes related to AI prompts or models.
Examples:
feat: add openrouter provider supportfix: resolve translation state race conditioni18n: update Japanese translationsai: improve read article prompt for better analysis
Sources: CLAUDE.md:162-177
Testing
Tests are written using Vitest and are located alongside the source code in __tests__ directories. The project uses nx to cache test results, improving performance.
Example test file structure:
src/utils/
├── __tests__/
│ └── blog.test.ts
└── blog.ts
Sources: src/utils/tests/blog.test.ts, nx.json:29-36, CLAUDE.md:107
Internationalization (i18n)
Localization is managed by @wxt-dev/i18n. All translation strings are stored in YAML files within the src/locales/ directory. To add or update translations, you should edit the corresponding .yml file (e.g., en.yml for English, zh-CN.yml for Simplified Chinese).
Example from en.yml:
popup:
autoLang: Auto
sourceLang: Source
targetLang: Target
read: Read Article
Sources: src/locales/en.yml:5-9, CLAUDE.md:109
Requirements and Review Process
The project has a specific, structured process for confirming requirements and reviewing code, heavily influenced by the "Linus-style" of thinking. This is primarily used when interacting with the project's AI assistant but provides valuable insight for all contributors.
Requirements Confirmation
Before implementing a new feature, contributors should follow this thought process:
This diagram shows the required thinking process before starting work on a new feature.
The core idea is to challenge the requirement's validity, simplify the approach, and ensure no existing functionality is broken.
Sources: CLAUDE.md:22-30
Code Review
Code reviews focus on "taste" and fundamental design. Review feedback will often be direct and focused on:
- Data Structure Analysis: Good programmers worry about data structures first.
- Special Case Identification: Good code has no special cases. Aim to eliminate
if/elsebranches through better data structure design. - Complexity Review: If an implementation requires more than 3 levels of indentation, it should be redesigned.
- Destructive Analysis: Backward compatibility is an iron law. Never break userspace.
Sources: CLAUDE.md:37-70
Submitting Contributions
After you have made your changes and followed the development workflow:
- Commit your changes using the Conventional Commits format.
- Push your branch to your fork.
- Open a Pull Request against the
mainbranch of themengxi-ream/read-frogrepository. - The PR process follows the guidelines in
.claude/commands/create-pr.md.
Sources: CLAUDE.md:162, CLAUDE.md:179
Thank you for your interest in contributing to Read Frog! Your efforts help make language learning more accessible and effective for everyone.