A full-stack Texas Hold'em poker web application built with React, NestJS, and WebSockets.
- Texas Hold'em Rules: Full implementation with all betting rounds (Pre-flop, Flop, Turn, River, Showdown)
- Real-time Multiplayer: WebSocket-based communication for instant updates
- 2-10 Players: Support for multiplayer games
- Full Betting System: Fold, Check, Call, Raise, All-in
- Host Migration: Automatic host transfer when current host leaves
- Reconnection Support: 30-second grace period for disconnected players
- Hand Evaluation: Complete poker hand ranking system
- Modern UI: Built with React and Tailwind CSS
- WebSocket Gateway: Real-time communication with Socket.io
- Game Services: GameService, HandService, BettingService
- Storage Layer: Abstract storage interface with JSON file implementation
- Utilities: Deck management, hand evaluator, ID generation
- Shared Types: TypeScript interfaces shared between client and server
- React Context: SocketContext and GameContext for state management
- Real-time UI: Instant updates via WebSocket events
- Responsive Design: Tailwind CSS for styling
- Component-based: Modular Card, PlayerSeat, and GameRoom components
Poker/
โโโ poker-types/ # Shared TypeScript types
โ โโโ src/
โ โโโ card.types.ts
โ โโโ player.types.ts
โ โโโ room.types.ts
โ โโโ game.types.ts
โ โโโ events.types.ts
โโโ poker-server/ # NestJS backend
โ โโโ src/
โ โโโ common/
โ โ โโโ utils/ # Deck, hand evaluator, ID generator
โ โโโ storage/ # Storage layer
โ โโโ game/ # Game services
โ โโโ events/ # WebSocket gateway
โโโ poker-registry/ # Internal shadcn-compatible component registry
โโโ poker-client/ # React frontend
โโโ src/
โโโ components/ # React components
โโโ contexts/ # React contexts
โโโ pages/ # Page components
โโโ services/ # Socket service
- Node.js (v20.19+ or v22.12+ recommended, though v22.1.0 works)
- npm or yarn
-
Install poker-types package:
cd poker-types npm install npm run build -
Install and setup backend:
cd ../poker-server npm install -
Install and setup frontend:
cd ../poker-client npm install
-
Start the backend server:
cd poker-server npm run start:devServer runs on http://localhost:3000
-
Start the frontend (in a new terminal):
cd poker-client npm run devFrontend runs on http://localhost:5173
-
Open the app:
- Navigate to http://localhost:5173 in your browser
- Create a new room or join an existing one
- Share the room code with friends to play together!
cd poker-registry
npm install
npm run startRegistry default URL: http://localhost:3022/registry/index.json
Available endpoints:
/health/registry/index.json/registry/styles/poker-dark.json/registry/poker/:item.json/registry/files/*
This repository includes a production Docker setup where:
- NestJS serves both API/WebSocket traffic and the built SPA
- Room state is persisted with JSON files under
/app/data /app/datais mounted as a Docker volume so data survives container restarts
docker compose up --build -dThen open http://localhost:3000.
If port 3000 is already used locally, choose another host port:
HOST_PORT=3300 docker compose up --build -ddocker compose downdocker compose down -v-
Create/Join a Room:
- Enter your name
- Click "Create New Room" or "Join Existing Room"
- Share the room code with other players
-
Starting the Game:
- Wait for at least 2 players to join
- Host clicks "Start Game"
-
Playing:
- Each player receives 2 hole cards
- Betting rounds: Pre-flop โ Flop โ Turn โ River
- Actions: Fold, Check (if no bet), Call, Raise, All-in
- Community cards are revealed progressively
- Best 5-card hand wins the pot
-
Game Flow:
- Dealer button rotates clockwise each hand
- Small and big blinds are posted automatically
- Players act in turn (clockwise from dealer)
- Disconnected players have 30 seconds to reconnect
- Chat unread & latest-preview rules:
Backend includes comprehensive unit tests:
cd poker-server
npm testPre-game readiness (build + health + LAN URL + critical smoke checks):
cd /Users/kai/Developer/games/Poker
./scripts/pregame-readiness.shQuick mode (skip Playwright smoke):
./scripts/pregame-readiness.sh --fastRun comprehensive Playwright in parallel (worker count configurable):
cd poker-server
PW_FRONTEND_PORT=5188 PW_BACKEND_PORT=3015 PW_WORKERS=4 \
npm run test:e2e:playwright:comprehensive:parallelCurrent test coverage:
- โ Deck utilities (17/17 tests passing)
- โ Hand evaluator (20/21 tests passing)
- โ JSON storage (13/13 tests passing)
-
Backend:
- NestJS 10.x
- Socket.io 4.8.x
- TypeScript
- Jest (testing)
-
Frontend:
- React 19.x
- Vite 7.x
- Socket.io Client 4.8.x
- Tailwind CSS 4.x
- shadcn/ui-compatible primitives + tokens
- React Router DOM 7.x
-
Internal UI Registry:
- Node.js + Fastify
- shadcn-compatible registry JSON endpoints
-
Shared:
- TypeScript
- poker-types (local package)
PORT=3000
CORS_ORIGIN=http://localhost:5173
CLIENT_URL=http://localhost:5173
NODE_ENV=development
DATA_DIR=./data
FRONTEND_DIST_PATH=../poker-client/dist
Frontend socket target can be set with:
VITE_SERVER_URL=http://localhost:3000
VITE_SERVER_PROTOCOL=http
VITE_SERVER_HOST=localhost
VITE_SERVER_PORT=3000
If these are not set, the client falls back to runtime config and then a host/port fallback.
The Dockerfile accepts a client build-time socket URL override:
docker build --build-arg VITE_SERVER_URL=/ -t poker-app:latest .Backend:
cd poker-server
npm run build
npm run start:prodFrontend:
cd poker-client
npm run build
npm run preview- TypeScript strict mode enabled
- ESLint configured for both projects
- Prettier for code formatting
- Hand evaluator has a minor bug with 7-card royal flush detection (test skipped, doesn't affect 5-card gameplay)
- Node.js version warning with Vite (works despite warning)
- Database integration (PostgreSQL/MongoDB)
- Authentication and user accounts
- Tournament mode
- Chat functionality
- Sound effects and animations
- Mobile responsiveness improvements
- Spectator mode
- Hand history and statistics
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions, please open an issue in the repository.
Enjoy the game! ๐ฐ