A two-player chess game for one laptop, built with TypeScript, Express, pnpm, and a custom animated browser UI.
Local Chess is a small full-stack chess project designed for face-to-face play on a single machine.
It combines:
- a custom browser interface
- animated movement, captures, and win states
- automatic board rotation after each move
- a lightweight in-memory game server
- documented REST endpoints with Swagger / OpenAPI
The result is a project that feels playful in the browser while still being structured like a real API-backed app.
| Area | What it includes |
|---|---|
| Gameplay | Standard starting position, legal moves, captures, check, checkmate, stalemate |
| Visuals | Animated piece movement, capture effects, victory overlay, rotating board, styled 3D-looking pieces |
| API | GET /api/game, POST /api/click, POST /api/reset |
| Docs | Swagger UI and raw OpenAPI JSON |
The UI is intentionally more expressive than a basic chess board.
Included visual touches:
- smooth piece travel between squares
- capture collapse animation
- animated win overlay with restart action
- rotating board so each player sees their own side after every turn
- layered 3D-style chess pieces instead of flat symbols
- moving background and stylized red / black / orange theme
- Standard initial chess setup
- Turn-based play for White and Black
- Legal move highlighting
- Piece captures
- Check detection
- Checkmate detection
- Stalemate detection
- Automatic pawn promotion to queen
- Victory screen with restart button
- Swagger documentation for the API
The game is playable, but a few chess rules are still not implemented:
- castling
- en passant
- choosing a promotion piece other than queen
- TypeScript
- Node.js
- pnpm
- Express
- Plain HTML, CSS, and JavaScript
- OpenAPI / Swagger
pnpm installpnpm startThis command:
- compiles TypeScript into
dist/ - starts the Express server
Default app URL:
http://localhost:3456
Custom port example:
PORT=4000 pnpm startThe current match state is stored in memory on the server.
Returns the full current game state.
Handles a board click. Depending on the square, it either:
- selects a piece
- changes the current selection
- performs a move
Request body example:
{
"x": 5,
"y": 2
}Resets the current match back to the initial position.
Interactive Swagger UI:
http://localhost:3456/api/docs
Raw OpenAPI document:
http://localhost:3456/api/openapi.json
src/
game.ts Game state, rules, and move handling
main.ts Express server and API routes
openapi.ts OpenAPI spec and Swagger HTML
phigures.ts Piece models and movement logic
public/
index.html Frontend UI, styles, animations, and client logic
docs/
media/ README visuals and repository media
dist/
... Compiled TypeScript output
- The game state is in memory, so restarting the server resets the current match.
- The frontend communicates with the backend only through the local REST API.
- The UI and the API are intentionally simple, which makes the project easy to extend.
- add castling
- add en passant
- allow promotion choice
- persist games between restarts
- add move history / notation
- support multiplayer beyond a shared laptop
pnpm start— compile and run the server
ISC
