A modern, intelligent chess application built with Next.js that allows you to play against powerful AI opponents. Challenge yourself against multiple AI models ranging from beginner-friendly to grandmaster-level engines.
- Interactive Chess Board: Drag-and-drop or click-to-move pieces
- Real-time Game Status: Live updates on check, checkmate, and draw conditions
- Move History: Complete game record with algebraic notation
- Game Statistics: Track moves, game time, and current turn
- Multiple Color Options: Play as white or black pieces
- Stockfish 17: Professional chess engine with adjustable difficulty
- Grandmaster (~2750 ELO)
- Master (~2600 ELO)
- Expert (~2350 ELO)
- Advanced (~2000 ELO)
- Large Language Models:
- Llama 3.3 70B (Most Advanced)
- Llama 3.1 70B (Balanced)
- Mixtral 8x7B (Fast)
- Gemini 1.5 Pro (Strategic)
- Gemini 1.5 Flash (Quick)
- Responsive Design: Optimized for desktop and mobile devices
- Dark Theme: Elegant dark interface with smooth animations
- Real-time Notifications: Toast messages for moves and game events
- Game Settings: Customizable player names and AI model selection
- Mobile Sidebar: Collapsible game information panel
- Next.js 15 - React framework with App Router
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS - Utility-first styling
- Shadcn UI - Components that are ready to use.
- Chess.js - Chess game logic
- React Chessboard - Interactive board component
- Vercel AI SDK - AI model integration
- Groq - Fast LLM inference
- Google Generative AI - Gemini models
- Stockfish API - Professional chess engine
- Lucide React - Beautiful icons
- Sonner - Toast notifications
- Next Themes - Theme management
- Node.js 18+
- npm, yarn, pnpm, or bun
- API keys for AI services (optional for local development)
-
Clone the repository
git clone https://github.com/Avik-creator/chess.git cd chess -
Install dependencies
npm install # or yarn install # or pnpm install # or bun install
-
Set up environment variables
cp .env.example .env.local
Add your API keys to
.env.local:GROQ_API_KEY=your_groq_api_key_here GOOGLE_GENERATIVE_AI_API_KEY=your_google_api_key_here
-
Run the development server
npm run dev # or yarn dev # or pnpm dev # or bun dev
-
Open your browser Navigate to http://localhost:3000
- Enter your name in the settings modal
- Choose your piece color (white or black)
- Select an AI model opponent
- Click "Start Game" to begin
- Drag & Drop: Click and drag pieces to move them
- Click to Move: Click a piece, then click the destination square
- Legal Moves: Highlighted squares show available moves
- New Game: Reset the board and start fresh
- Settings: Change player name, color, or AI model
- Move History: View all moves in algebraic notation
- Game Stats: Monitor time played and move count
- Sign up at Groq Console
- Create an API key
- Add to your
.env.localfile
- Visit Google AI Studio
- Generate an API key
- Add to your
.env.localfile
- Uses the free Chess API
- No API key required
- Rate limits may apply
chess/
├── src/
│ ├── app/
│ │ ├── api/move/ # AI move generation endpoint
│ │ ├── game/ # Main game page
│ │ ├── globals.css # Global styles
│ │ ├── layout.tsx # Root layout
│ │ └── page.tsx # Landing page
│ ├── components/
│ │ ├── ui/ # Reusable UI components
│ │ ├── chessBoard.tsx # Chess board component
│ │ ├── gameStatus.tsx # Game status display
│ │ └── themeProvider.tsx # Theme context
│ └── lib/
│ └── utils.ts # Utility functions
├── public/ # Static assets
├── .env.local # Environment variables
├── package.json
├── tailwind.config.js
└── tsconfig.json
The app uses a dark theme by default. Modify globals.css to customize colors:
:root {
--background: oklch(0.141 0.005 285.823);
--foreground: oklch(0.985 0 0);
/* Add your custom colors */
}Customize the board appearance in chessBoard.tsx:
const chessboardOptions = {
customDarkSquareStyle: { backgroundColor: "#779556" },
customLightSquareStyle: { backgroundColor: "#eeeed2" },
// Add more customizations
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Use TypeScript for type safety
- Follow ESLint configuration
- Use Prettier for code formatting
- Write descriptive commit messages
This project is free to use but not for commercial purposes.
- Stockfish - The world's strongest chess engine
- Chess.js - Comprehensive chess library
- React Chessboard - Beautiful React chess component
- Vercel - Hosting and deployment platform
- OpenAI & Anthropic - AI model inspiration
If you have any questions or need help:
- 📧 Email: avikm744@gmail.com
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
Made with ♟️ and ⚡ by Avik Mukherjee
