A two-player chess game with full move validation and database persistence.
Chesster/
├── backend/ # Node.js + Express API
│ ├── config/ # Supabase config
│ ├── controllers/ # Request handlers
│ ├── models/ # Database operations
│ ├── routes/ # API endpoints
│ ├── services/ # Chess engine logic
│ └── database/ # SQL schemas
└── frontend/ # React + TypeScript
└── src/
└── components/ # ChessBoard, GameLobby
- Go to supabase.com and create a project
- In SQL Editor, run the schema from
backend/database/schema.sql - Copy your project URL and anon key
cd backend
cp .env.example .env
# Edit .env and add your Supabase credentials
npm install
npm run devBackend runs on http://localhost:3000
cd frontend
npm install
npm run devFrontend runs on http://localhost:5173
- Player 1: Click "Create New Game" → Share the game code
- Player 2: Enter game code → Click "Join as Black"
- Click a piece to select it, then click destination square to move
- All moves are validated and stored in Supabase
✅ Full chess move validation (pawns, rooks, knights, bishops, queens, kings) ✅ Two-player turn-based gameplay ✅ Real-time board updates (polling every 2s) ✅ Move history stored in database ✅ Scalable architecture for adding more games ✅ Clean separation of concerns (MVC pattern)
POST /api/games- Create new gamePOST /api/games/:code/join- Join gameGET /api/games/:code- Get game statePOST /api/games/:code/move- Make moveGET /api/games/:code/moves- Get move history
games table: Stores game state, board position, turn, status moves table: Records every move with position, piece, and resulting board state
The architecture supports multiple game types:
- Add new engine in
services/(e.g.,checkersEngine.js) - Update
gameModel.jsto handle different game types - Create new frontend component for the game board
- Use same API endpoints with different
gameTypeparameter