002ed92bea
This commit implements iOS/Android mobile app support using Capacitor and adds a comprehensive opening training feature with LLM-powered explanations. ## Mobile App Infrastructure - Add Capacitor configuration for iOS/Android builds - Create mobile build script that excludes API routes - Update Next.js config for conditional static export - Add layout components with generateStaticParams for static builds - Generate 500+ static pages for offline mobile use ## Chess Engine Abstraction - Create ChessEngine interface for pluggable implementations - Add LocalEngine (GPL - uses stockfish.js in browser) - Add RemoteEngine (proprietary - calls API server) - Factory pattern selects engine based on environment - Enables GPL compliance for web, proprietary for mobile ## Opening Training Feature - Interactive opening repertoire training - Move validation with engine-backed feedback - LLM explanations using Gemini API - Wikipedia integration for opening context - Opening family grouping (e4, d4, c4, etc.) - Session state management - Real-time move feedback with evaluation Components: - OpeningSelector: Browse and select openings by family - OpeningTrainer: Main training interface with chessboard - MoveFeedback: Display move quality and LLM explanations - WikipediaSummary: Show opening history and context - ErrorBoundary: Graceful error handling Services: - openingLoader: Load and filter opening database - engineService: Engine evaluation wrapper - moveValidator: Validate moves against repertoire - feedbackGenerator: Generate contextual feedback - wikipediaService: Fetch and cache Wikipedia data - sessionManager: Track training session state ## Wikipedia Integration - Automatic Wikipedia article fetching for openings - Client-side and server-side caching - Sanitized summaries with proper formatting - Link opening database to Wikipedia slugs - API endpoints for on-demand fetching ## Docker Improvements - Add entrypoint script for automatic data setup - Fetch Wikipedia data on first container startup - Generate opening move index automatically - Remove generated data from git (public/openings/*.json, public/wikipedia/*.json) - Add READMEs explaining data requirements - Update .gitignore for generated files ## Dual Licensing Strategy - Add LICENSING.md explaining dual licensing approach - GPL-3.0 for web builds (includes Stockfish) - Proprietary option for mobile builds (no GPL code) - Single codebase, multiple licensing models - Legal compliance documented ## API Endpoints - POST /api/v1/llm/opening-explanation - Get LLM move explanations - GET /api/v1/wikipedia/summary - Fetch Wikipedia summaries ## Type Updates - Add openingTraining types - Update Tutor component to use ChessEngine interface - Add Gemini error handling types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
65 lines
1.5 KiB
Markdown
65 lines
1.5 KiB
Markdown
# Opening Database
|
|
|
|
This directory contains the ECO (Encyclopedia of Chess Openings) database files.
|
|
|
|
## Required Files
|
|
|
|
The following files are required for opening training:
|
|
|
|
- `ecoA.json` - ECO codes A00-A99
|
|
- `ecoB.json` - ECO codes B00-B99
|
|
- `ecoC.json` - ECO codes C00-C99
|
|
- `ecoD.json` - ECO codes D00-D99
|
|
- `ecoE.json` - ECO codes E00-E99
|
|
- `moveIndex.json` - Generated move sequence index
|
|
|
|
## File Format
|
|
|
|
Each ECO file (ecoA-E.json) should be a JSON object mapping FEN positions to opening metadata:
|
|
|
|
```json
|
|
{
|
|
"fen_position": {
|
|
"eco": "A00",
|
|
"name": "Opening Name",
|
|
"moves": "e4 e5 Nf3 Nc6",
|
|
"wikipediaSlug": "opening-name" // optional
|
|
}
|
|
}
|
|
```
|
|
|
|
## Setup
|
|
|
|
### Option 1: Docker (Automatic)
|
|
|
|
When running via Docker, these files should be provided as a volume mount:
|
|
|
|
```bash
|
|
docker run -v ./openings:/app/public/openings ghcr.io/stefan-kp/chess-tutor
|
|
```
|
|
|
|
### Option 2: Local Development
|
|
|
|
1. Obtain ECO database files (ecoA-E.json)
|
|
2. Place them in this directory
|
|
3. Generate the move index:
|
|
|
|
```bash
|
|
npm run build:opening-index
|
|
```
|
|
|
|
This will create `moveIndex.json` from the ECO files.
|
|
|
|
### Option 3: Generate from PGN
|
|
|
|
If you have a PGN database, you can extract ECO codes using chess tools like:
|
|
- `pgn-extract`
|
|
- Custom scripts
|
|
|
|
## Notes
|
|
|
|
- These files are **not included in git** (too large, ~4MB total)
|
|
- Users must provide their own opening database
|
|
- Wikipedia integration is optional (see `public/wikipedia/README.md`)
|
|
- The move index is automatically generated during Docker startup
|