Overview
AI Chess Assistant is a Chrome extension that demonstrates real-time chess engine integration with web-based chess platforms. The extension leverages the Stockfish chess engine to analyze board positions, evaluate moves, and provide intelligent suggestions directly on chess.com.
This project showcases modern browser extension development with TypeScript, real-time DOM manipulation, and WebWorker-based engine communication.
Key Features
| Feature | Description |
|---|---|
| Real-Time Analysis | Continuous board monitoring with FEN position extraction |
| Move Evaluation | Centipawn scoring with principal variation display |
| Visual Suggestions | Highlighted move recommendations on the board |
| Advantage Tracking | Dynamic progress bar showing position evaluation |
| Auto-Play Mode | Automated move execution for testing purposes |
| Draggable UI | Compact, minimizable panel that can be positioned anywhere |
Technical Architecture
The extension follows a modular, service-oriented architecture:
src/
├── types/ # TypeScript type definitions
│ ├── chess.types.ts # FEN, moves, scores
│ ├── engine.types.ts # Engine communication
│ └── ui.types.ts # UI component types
├── services/ # Core services
│ ├── board.service.ts # Board state & FEN generation
│ └── engine.service.ts # Stockfish WebWorker
├── components/ # UI components
│ ├── panel.component.ts # Main control panel
│ └── highlights.component.ts # Move highlighting
├── core/ # Business logic
│ ├── analysis.manager.ts # Analysis state management
│ └── autoplay.manager.ts # Automated move execution
└── content/ # Entry point
└── assistant.ts # Main orchestrator
Design Patterns
- Service Pattern - Encapsulated services for board and engine interaction
- Observer Pattern - Event-based engine updates with subscription model
- Singleton Pattern - Single instance services for state consistency
- Facade Pattern - ChessAssistant class orchestrates all subsystems
Technical Stack
| Technology | Purpose |
|---|---|
| TypeScript 5.4 | Type-safe development with strict mode |
| Vite 5.2 | Fast builds with HMR and optimized bundling |
| CRXJS | Chrome extension development with Vite |
| Chrome Extension MV3 | Modern manifest version with service workers |
| Stockfish | Chess engine for position analysis |
| ESLint + Prettier | Code quality and formatting |
| GitHub Actions | CI/CD pipeline |
Core Features
FEN Generation
The board service extracts piece positions from the DOM and generates standard FEN notation:Typescript
Engine Communication
Asynchronous communication with Stockfish via WebWorker:Typescript
Event-Driven Updates
Real-time analysis updates via subscription pattern:Typescript
UI Features
- Compact Design - 260px width, minimal footprint
- Draggable Panel - Position anywhere on screen
- Minimizable - Collapse to small "+" button at 50% opacity
- Color Selection - Analyze from White or Black's perspective
- Move History - Color-coded ratings (Excellent/Good/OK/Poor)
Technologies Summary
| Category | Technologies |
|---|---|
| Language | TypeScript 5.4, ES2022 |
| Build | Vite 5.2, CRXJS |
| Extension | Chrome Manifest V3 |
| Engine | Stockfish WASM |
| Quality | ESLint, Prettier |
| CI/CD | GitHub Actions |
