Back to .md Directory

Chess Coach AI Agents

Defines a chess coaching app with AI agents that analyze positions, suggest moves, and provide strategic advice via a React frontend and Python backend.

May 2, 2026
0 downloads
2 views
ai agent llm rag eval openai copilot
View source

What this file does

Defines a chess coaching app with AI agents that analyze positions, suggest moves, and provide strategic advice via a React frontend and Python backend.

When to use it

  • Building a chess coaching tool with AI-powered analysis
  • Integrating a React chess board with an LLM-based agent
  • Creating a real-time AI assistant for game analysis
  • Setting up a CopilotKit frontend with a FastAPI agent backend

Assumes this stack

Next.jsReactPythonFastAPIOpenAICopilotKit

Chess Coach AI Agents

Overview

This project implements a chess coaching application with AI agents that can analyze chess positions, suggest moves, and provide strategic advice. The system combines a modern React frontend with a Python-based AI agent backend.

Architecture

Frontend (React/Next.js)

  • Framework: Next.js 15.3.2 with React 19
  • UI Library: CopilotKit for AI integration
  • Chess Board: react-chessboard for interactive chess interface
  • Game Logic: chess.js for move validation and game state management
  • Styling: Tailwind CSS

Backend (Python)

  • Framework: LlamaIndex with OpenAI integration
  • Agent: Chess assistant with FEN position understanding
  • Server: FastAPI with Uvicorn

AI Agents

Chess Assistant Agent

Purpose: Provides chess analysis, move suggestions, and strategic coaching

Capabilities:

  • Analyzes chess positions using FEN notation
  • Suggests optimal moves based on position evaluation
  • Explains chess concepts and strategies
  • Provides real-time analysis
  • Offers coaching advice for improvement

Technical Implementation:

  • LLM: OpenAI GPT-4.1
  • State Management: FEN position strings for game state
  • Integration: CopilotKit for real-time UI updates
  • Tools: Currently configured for chess analysis (frontend/backend tools disabled)

State Schema:

type ChessState = {
  position: string; // FEN notation of current board position
}

Key Components

ChessBoard Component

  • Library: react-chessboard
  • Features: Drag-and-drop piece movement, move validation
  • Integration: Syncs with AI agent state via FEN updates
  • Validation: Uses chess.js for legal move checking

State Management

  • Shared State: CopilotKit manages chess position between UI and agent
  • Real-time Updates: Position changes trigger AI analysis
  • Persistence: Game state maintained during session

Development Setup

Prerequisites

  • Node.js 18+
  • Python 3.8+
  • OpenAI API Key
  • uv package manager

Installation

# Install frontend dependencies
npm install

# Install Python agent dependencies
npm run install:agent

# Set environment variables
export OPENAI_API_KEY="your-api-key"

Running the Application

# Start both frontend and agent servers
npm run dev

# Or run separately
npm run dev:ui    # Frontend only
npm run dev:agent # Agent only

Current Status

Implemented

  • ✅ Interactive chess board with drag-and-drop
  • ✅ Move validation using chess.js
  • ✅ FEN position state management
  • ✅ AI agent integration with CopilotKit
  • ✅ Real-time position updates
  • ✅ Basic chess assistant functionality

Planned Enhancements

  • Advanced chess analysis tools
  • Opening book integration
  • Tactical puzzle generation
  • Game history and replay
  • Multiple difficulty levels
  • Tournament mode

Technical Notes

FEN Notation

The system uses standard FEN (Forsyth-Edwards Notation) for position representation:

  • Format: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
  • Enables precise position communication between frontend and AI
  • Standard format for chess engines and analysis

Agent Communication

  • Protocol: CopilotKit for seamless frontend-backend integration
  • State Sync: Real-time position updates between chess board and AI
  • Tool Integration: Ready for advanced chess analysis tools

File Structure

src/
├── app/
│   ├── page.tsx          # Main application component
│   └── api/copilotkit/   # CopilotKit API routes
├── components/
│   ├── ChessBoard.tsx    # Interactive chess board
│   └── WeatherCard.tsx   # Example component (legacy)
agent/
├── agent/
│   ├── agent.py          # Chess assistant agent
│   └── server.py         # FastAPI server
└── pyproject.toml        # Python dependencies

What's inside

Architecture overview, 2 AI agent descriptions, 3 key components, development setup, current status, technical notes, and file structure.

Change this for your project

  • Replace OPENAI_API_KEY with your own API key
  • Replace cedric-scheerlinck/chess-coach with your repository name
  • Replace WeatherCard.tsx with your own legacy component or remove it

Where it goes

Save as AGENTS.md in your repository root. Read by Codex, Cursor and other agents that follow the AGENTS.md convention.

Worth borrowing

  • Using FEN notation as a shared state format between frontend and AI agent
  • Separating frontend and agent servers with a single npm run dev command to start both

Related Documents