Skip to content

mxggle/Lingo-context

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

66 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LingoContext 🌐

LingoContext logo

LingoContext is a Chrome extension for language learners that turns selected text on any webpage into a context-aware study card: translation, adaptive explanation, grammar notes, pronunciation, and vocabulary capture in one flow.

It combines AI analysis, fast local Japanese helpers, and a review dashboard so learners can move from β€œwhat does this mean?” to β€œwhy does it mean that here?” without leaving the page.

Version License


✨ Features

  • πŸ“– Context-aware analysis: Understands selected text using the surrounding sentence and page context instead of translating in isolation.
  • 🧠 Adaptive explanations: Produces richer grammar and word-by-word explanations for shorter selections, while handling longer passages more naturally.
  • ⚑ Streaming responses: Uses server-sent events for responsive AI analysis flows.
  • πŸ€– Multi-provider AI: Supports user-selectable Gemini and DeepSeek analysis providers, with a provider-agnostic backend architecture.
  • πŸ” Quick definitions: Fetches lightweight definitions for selected terms before the full analysis finishes.
  • 🎌 Japanese study support: Generates local furigana for Japanese text and filters ruby annotations down to Kanji where appropriate.
  • πŸ”Š Better pronunciation: Uses Edge TTS for high-quality audio with browser TTS fallback, plus optional auto-play.
  • 🧠 Smart caching: Caches AI analysis, quick definitions, and TTS audio to reduce repeated latency and token usage.
  • πŸͺŸ Refined in-page popup: Draggable, pinnable, resizable popup UI with contained scrolling and updated cursor-trigger animations.
  • πŸ“Š Vocabulary dashboard: Review saved words, search your collection, inspect usage, and manage preferences.
  • 🌍 Internationalization: Ships with English, Japanese, Simplified Chinese, and Traditional Chinese locales.
  • πŸ” Google authentication: Syncs user data and preferences across sessions.
  • 🐳 Docker-ready backend: Includes a containerized Node.js + MySQL stack for local or self-hosted deployment.
LingoContext popup LingoContext dashboard

πŸ› οΈ Technology Stack

  • Extension: Vanilla JavaScript, Chrome Extension Manifest V3
  • Styling: Tailwind CSS
  • Backend: Node.js, Express 5, Server-Sent Events
  • Database: MySQL
  • AI: Gemini and DeepSeek, behind a pluggable provider layer
  • Speech: Edge TTS with Web Speech API fallback
  • Japanese processing: kuromoji
  • Deployment: Docker Compose and Vercel-compatible server configuration

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • Docker and Docker Compose
  • Google Cloud Console project for OAuth
  • At least one AI provider key:
    • GEMINI_API_KEY
    • or DEEPSEEK_API_KEY

1. Installation

# Install root dependencies
npm install

# Install server dependencies
cd server && npm install && cd ..

2. Configuration

Server (server/.env)

Create server/.env from the example file and fill in the values you need:

AI_PROVIDER=gemini
AI_MAX_OUTPUT_TOKENS=2048

GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=gemini-2.5-flash

DEEPSEEK_API_KEY=your_deepseek_api_key
DEEPSEEK_MODEL=deepseek-v4-flash

PORT=3303
DATABASE_URL=mysql://user:password@mysql:3306/LingoContext

GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
SESSION_SECRET=your_random_session_secret

Optional provider-related settings such as OpenRouter, Codex-compatible routing, Gemini explicit cache settings, CORS origins, and extension IDs are documented in server/.env.example.

Extension (config.js)

The extension uses CONFIG.BACKEND_URL as its API endpoint. For local development, point it at:

http://localhost:3303/api

For local development, override BACKEND_URL in chrome.storage.local or use a temporary local build. The checked-in extension defaults to the hosted backend so store builds are safe by default.

3. Run Locally

Option A: Full stack with Docker

docker-compose up --build

Option B: Manual development

  1. Start MySQL locally, or run only the MySQL service:
    docker-compose up mysql -d
  2. Start the backend:
    cd server
    node index.js
  3. Build extension styles:
    npm run build:css
    # or
    npm run watch:css

4. Load the Extension in Chrome

  1. Open chrome://extensions/
  2. Enable Developer mode
  3. Click Load unpacked
  4. Select the project root folder

πŸ–₯️ Usage

  1. Sign in from the popup with Google.
  2. Select text on any webpage to reveal the custom cursor trigger.
  3. Analyze the selection to receive translation, grammar/explanation, furigana when relevant, and quick definitions.
  4. Listen with the speaker control, optionally using auto-play pronunciation.
  5. Save useful terms to your vocabulary list.
  6. Review them later in the dashboard, where you can also change target language and AI provider preferences.

πŸ“¦ Packaging for Release

Quick build

npm run package

Creates the Chrome Web Store-ready lingocontext-production.zip in the repository root.

Production build

npm run build:prod

Creates lingocontext-production.zip with production configuration applied.

🌐 Chrome Web Store Deployment

Pre-submission checklist

  1. Bump the version in manifest.json and package.json
  2. Test selection flow, popup behavior, dashboard, sign-in, TTS, and provider switching
  3. Prepare a privacy policy page
  4. Prepare store screenshots
  5. Fill in the listing copy and metadata

Extension permissions

  • storage: saves user preferences
  • tts: enables browser text-to-speech fallback
  • Host access to the configured backend API

πŸ“‚ Project Structure

.
β”œβ”€β”€ manifest.json              # Chrome extension manifest
β”œβ”€β”€ content.js                 # In-page selection flow and popup UI
β”œβ”€β”€ background.js              # Background worker, streaming bridge, TTS routing
β”œβ”€β”€ popup.html / popup.js      # Login and quick actions
β”œβ”€β”€ dashboard.html / dashboard.js
β”‚                              # Vocabulary dashboard and user preferences
β”œβ”€β”€ icons/                     # Extension icons and cursor assets
β”œβ”€β”€ _locales/                  # Translation files
β”œβ”€β”€ server/                    # Express backend
β”‚   β”œβ”€β”€ routes/                # Analyze, TTS, furigana, dictionary, auth routes
β”‚   β”œβ”€β”€ services/              # AI, caching, TTS, furigana, normalization logic
β”‚   └── schema.sql             # Database schema
└── docker-compose.yml         # Local stack orchestration

πŸ“„ License

MIT License.

About

is a powerful Chrome Extension designed for language learners (English/Japanese). It provides instant, context-aware definitions, grammar explanations, and pronunciation guides using Google's **Gemini AI** and browser-native Text-to-Speech.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages