A real-time multiplayer chess game built with Node.js, Express, Socket.IO, and Chess.js.
Repository Description: Real-time multiplayer chess game with drag-and-drop functionality, built using Node.js, Express, Socket.IO, and Chess.js. Features live game synchronization, player roles (white/black/spectator), and a responsive chessboard UI.
- Real-time Multiplayer - Play chess with another player in real-time using WebSockets
- Drag and Drop - Intuitive piece movement with drag-and-drop functionality
- Player Roles - Automatic assignment of white/black roles; additional users join as spectators
- Board Flipping - Board automatically flips for the black player
- Move Validation - All moves are validated using Chess.js library
- Live Synchronization - Board state syncs instantly across all connected clients
- Backend: Node.js, Express.js
- Real-time Communication: Socket.IO
- Chess Logic: Chess.js
- Templating: EJS
- Styling: Tailwind CSS
-
Clone the repository
git clone https://github.com/yourusername/chess.com.git cd chess.com -
Install dependencies
npm install
-
Start the server
node app.js
Or with nodemon for development:
npx nodemon
-
Open your browser and navigate to
http://localhost:3000
- Open the game in two browser windows/tabs
- First player is assigned White, second player is assigned Black
- Additional connections become Spectators
- Drag and drop pieces to make moves
- Only valid chess moves are allowed
Chess.com/
├── app.js # Express server & Socket.IO logic
├── package.json # Dependencies
├── public/
│ ├── css/ # Stylesheets
│ └── js/
│ └── chessgame.js # Client-side game logic
└── views/
└── index.ejs # Main game view
MIT