A modern, real-time online chess platform built with React, TypeScript, and WebSockets.
EeChess is a next-generation online chess application that enables players to compete in real-time matches through a beautiful, responsive web interface. Built with modern web technologies, it provides a seamless gaming experience with instant move synchronization.
- Real-time Gameplay: Instant move synchronization using WebSocket connections
- Reconnection Logic: Players can reconnect to an ongoing game if their connection drops
- Modern UI: Beautiful, responsive interface built with React and Tailwind CSS
- Type Safety: Full TypeScript implementation for better development experience
- Chess Engine: Powered by chess.js for accurate game logic and move validation
- Cross-platform: Works on desktop and mobile devices
- Spectator Mode: Allow users to watch ongoing games
- React - Modern UI framework
- TypeScript - Type-safe development
- Zustand - State management
- Tailwind CSS - Utility-first CSS framework
- React Chessboard - Professional chess board component
- Vite - Fast build tool and dev server
- Radix UI - Accessible UI components
- Node.js - JavaScript runtime
- WebSocket (ws) - Real-time communication
- chess.js - Chess game logic and validation
- Zod - Runtime type validation
- Monorepo - PNPM workspace for shared code
- Shared Package - Common types and constants
eechess/
├── apps/
│ ├── backend/ # WebSocket server and game logic
│ └── frontend/ # React application
├── packages/
│ └── shared/ # Shared types and constants
└── pnpm-workspace.yaml # Workspace configuration
- Node.js (v18 or higher)
- PNPM (v8 or higher)
-
Clone the repository
git clone <repository-url> cd eechess
-
Install dependencies
pnpm install
-
Start the development servers
In separate terminals:
# Build the shared package first (required for backend) cd packages/shared pnpm build # Build and start the backend server cd ../../apps/backend pnpm build pnpm start
# Start the frontend development server cd apps/frontend pnpm dev
-
Open your browser
- Frontend: http://localhost:5173
- Backend WebSocket: ws://localhost:8080
- Navigate to the application in your browser
- Click "Play Online" to start a new game
- Wait for an opponent to join
- Make moves by dragging pieces on the chessboard
- The game automatically validates moves and enforces chess rules
Backend:
pnpm build- Build TypeScript to JavaScriptpnpm start- Start the production server
Frontend:
pnpm dev- Start development serverpnpm build- Build for productionpnpm lint- Run ESLintpnpm preview- Preview production build
The application uses WebSocket messages for real-time communication:
Join Game:
Used by a player to join a new or existing game. If gameId is provided, they will join as a spectator.
{
"type": "joinGame",
"payload": {
"gameId": "some-game-id"
}
}Reconnect to Game: Used by a player to reconnect to a game they were previously in.
{
"type": "reconnect"
}Initialize Game: Sent to a player when they start a new game, assigning them a color.
{
"type": "initGame",
"payload": {
"color": "white",
"gameId": "some-game-id"
}
}Make a Move:
{
"type": "move",
"payload": {
"move": {
"from": "e2",
"to": "e4"
}
}
}Game Over:
{
"type": "gameOver",
"payload": {
"winner": "white"
}
}Game State: Sent to spectators to provide the current state of the game.
{
"type": "gameState",
"payload": {
"moves": [],
"turn": "w",
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
"gameId": "some-game-id"
}
}- Chess Clock - Add time controls for games
- Spectators - Allow users to watch ongoing games
- State Management - Implement proper game state management
- Authentication - User accounts and persistent sessions
- Reconnection - Handle connection drops gracefully
- Game History - Save and replay completed games
- Tournaments - Organize competitive events
- chess.js - Chess game logic
- react-chessboard - Chess board component
- Tailwind CSS - CSS framework

