♟️ Chess King
AI-Powered Chess Coach in Your Browser
Train like a Grandmaster using Stockfish 18 + AI coaching (Gemini & GPT-4o).
Analyze positions, solve puzzles, study openings, and get human-like explanations for every move.
No installation. No servers required. Runs entirely in your browser.
⭐ If you like this project, please consider starring the repository.

♟️ Chess King
Chess King is an AI-powered chess training platform designed to help players understand chess deeply rather than just memorize moves.
Most chess apps show the best move.
Chess King explains why it is the best move.
By combining Stockfish engine analysis with large language models, the system behaves like a real chess coach, helping players improve their thinking process.
The application runs entirely in the browser, using WebAssembly for engine analysis and modern AI models for natural explanations.
🚀 Key Highlights
- ♟ Stockfish 18 running entirely in-browser (WASM)
- 🤖 AI chess coach powered by Gemini + GPT-4o
- 📊 Real-time engine evaluation bar
- 🧠 Human-like explanations for positions
- 🎯 Puzzle, opening, and endgame training
- 📈 Full game analysis with move classification
- ⚡ No backend required — fully browser based
🤖 AI Coaching Engine
Chess King includes a conversational AI coach designed to guide players through positions like a human trainer.
Features include:
- Real-time AI explanations
- Conversational chess analysis
- Skill-level adaptive coaching
- Move suggestions with reasoning
The coach explains:
- Candidate moves
- Tactical ideas
- Strategic plans
- Calculation trees
Instead of simply telling the best move, it teaches how strong players think.
♟️ Stockfish 18 Integration
The project integrates Stockfish 18 compiled to WebAssembly, allowing deep engine analysis directly inside the browser.
Capabilities include:
- Multi-PV analysis
- Evaluation bar
- Best move suggestions
- Threat detection
- Position evaluation
All analysis runs locally in your browser without server calls.
🎓 Training Modules
The platform includes multiple training systems designed to improve chess skills.
Tactical Puzzles
Improve calculation and pattern recognition.
- 44 curated puzzles
- Tactical motif detection
- Guided hints
Opening Drill
Practice opening theory.
- 54 opening lines
- Move-by-move explanations
- ECO opening recognition
Endgame Training
Learn fundamental endgame techniques.
- 21 classic endgame scenarios
- Position-based training
- Engine verification
Blunder Review Mode
Review mistakes from previous games.
- Blunder detection
- Tactical explanation
- Improvement suggestions
📊 Game Analysis
Chess King analyzes entire games and provides detailed insights.
Analysis includes:
- Move quality classification
- Accuracy percentage
- Tactical pattern detection
- Opening recognition
Each move is categorized as:
- Excellent
- Good
- Inaccuracy
- Mistake
- Blunder
This helps players understand where and why mistakes happen.
🛠 Board & Gameplay Features
The application includes a full interactive chess board system.
Features include:
- Drag-and-drop move input
- Legal move highlighting
- Arrow annotations
- Move history with PGN
- Position setup via FEN
- Save/load games using IndexedDB
- Board flipping
- Dark mode support
You can also play against a custom minimax chess engine with multiple difficulty levels.
⚙️ Getting Started
Prerequisites
Installation
Clone the repository:
git clone https://github.com/Iamsdt/chess.git
cd chess
Install dependencies:
npm install
Start the development server:
npm run dev
Open:
http://localhost:5173
🔑 Environment Variables
To enable AI coaching features, create a .env file:
VITE_GOOGLE_AI_API_KEY=your_google_gemini_api_key
VITE_OPENAI_API_KEY=your_openai_api_key
Note:
The project still works fully offline for chess analysis and training without API keys.
🏗 Build for Production
npm run build
npm run preview
Release gates
CI (.github/workflows/ci.yml) holds the production build to these budgets:
| Gate |
Budget |
Where |
| Initial JS / CSS |
200 KB / 60 KB gzip |
npm run size |
| JS added per route |
200 KB gzip each, engine excluded |
npm run size |
| Lighthouse (mobile) |
TBT < 150 ms, CLS < 0.1, LCP target 2.0 s (hard cap 3 s) |
lighthouserc.json |
| Accessibility |
zero axe violations on the main routes |
src/app/a11y.test.tsx |
| Coverage |
floors on src/domain, src/chess, src/engine |
vitest.config.ts |
| Headers |
COOP/COEP present, inline script hash-allowed by the CSP |
scripts/check-headers.mjs |
Deployment
Cloudflare. Publishing a GitHub release deploys to Cloudflare Workers static assets
through .github/workflows/deploy-cloudflare.yml.
Merging to main does not deploy. Cloudflare reads public/_headers, so the site is served
with COOP/COEP (cross-origin isolation, which multi-threaded Stockfish needs) and a strict
CSP. Setup, the two required secrets and the smoke test are in docs/deploy.md.
🧠 Tech Stack
| Layer |
Technology |
| Frontend |
React 19 + Vite 7 |
| Styling |
Tailwind CSS + Radix UI |
| Chess Logic |
chess.js |
| Chess Board |
react-chessboard |
| Engine |
Stockfish 19 lite (WASM) |
| AI Models |
Gemini + GPT-4o |
| State Management |
Zustand |
| Storage |
IndexedDB (idb) |
| Custom Engine |
Minimax + Alpha-Beta pruning |
📂 Project Structure
src/
├── components/
│ ├── board-panel.jsx
│ ├── chat-panel.jsx
│ ├── training-panel.jsx
│ ├── puzzle-mode.jsx
│ ├── opening-drill-mode.jsx
│ ├── endgame-mode.jsx
│ └── blunder-review-mode.jsx
│
├── hooks/
│ ├── use-engine-coach.js
│ ├── use-ai-chat.js
│ └── use-chess-clock.js
│
├── lib/
│ ├── engine.js
│ ├── stockfish.js
│ ├── intelligence.js
│ ├── analyzer.js
│ └── openings.js
│
├── store/
│ └── use-game-store.js
│
└── data/
├── puzzles.js
└── endgames.js
🗺 Roadmap
Planned improvements:
- Online multiplayer
- Chess database
- Opening explorer
- Game import from Lichess / Chess.com
- ELO rating system
- AI game commentary
- Advanced training modules
🤝 Contributing
Contributions are welcome!
If you’d like to improve the project:
- Fork the repository
- Create a feature branch
- Commit your changes
- Submit a pull request
Ideas for contributions:
- Add more puzzles
- Expand opening database
- Improve UI/UX
- Add new training modes
🙏 Credits
- Puzzles: the Lichess open puzzle database, released under
CC0 1.0. Thank you to Lichess and its
community. Each puzzle links back to its page on lichess.org.
- Openings: lichess-org/chess-openings (CC0).
- Engine: Stockfish, GPLv3. The licence text ships at
/engine/Copying.txt.
- Piece sets (shared with Lichess, authors and licences from
lila’s COPYING.md):
Staunty and Maestro by sadsnake1, California by Jerry S. (all CC BY-NC-SA 4.0), and Alpha by
Eric Bentzen (“free for personal non commercial use”). These are non-commercial licences,
so the app must stay non-commercial while they ship. Full notes in docs/licences.md.
📜 License
MIT License
© Shudipto Trafder
Built with ♟️, AI, and a lot of ☕
Stop memorizing moves. Start understanding chess.
评论