A modern, real-time multiplayer Teen Patti (Indian Poker) game built with React, Node.js, and WebSocket technology.
- ๐ฎ Real-time Multiplayer: Play with 2-6 players simultaneously
- ๐ WebSocket Sync: Instant game state synchronization across all players
- ๐จ Modern UI: Beautiful, responsive design with TailwindCSS
- ๐ Complete Game Logic: Full Teen Patti rules implementation
- ๐ฅ Room System: Create or join game rooms with unique IDs
- ๐ฐ Chip Management: Track player chips and betting
- ๐๏ธ Blind/Seen Play: Play blind or see your cards
- ๐ Winner Detection: Automatic hand comparison and winner declaration
- Trio/Trail - Three cards of the same rank (AAA is highest)
- Pure Sequence - Three consecutive cards of the same suit
- Sequence - Three consecutive cards of different suits
- Color/Flush - Three cards of the same suit
- Pair - Two cards of the same rank
- High Card - Highest single card wins
- Each player is dealt 3 cards face down
- Players can play blind (without seeing cards) or seen (after viewing)
- Blind players bet half the amount of seen players
- Players take turns betting or folding
- Game continues until only one player remains or players show their cards
- Winner takes the pot
- React - UI framework
- Vite - Build tool
- TailwindCSS - Styling
- React Router - Navigation
- Socket.io Client - WebSocket communication
- Lucide React - Icons
- Node.js - Runtime
- Express - Web framework
- Socket.io - WebSocket server
- UUID - Unique ID generation
- Node.js (v16 or higher)
- npm or yarn
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Start the server:
npm startThe backend server will run on http://localhost:3001
For development with auto-reload:
npm run dev- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will run on http://localhost:5173
-
Start the Application
- Make sure both backend and frontend servers are running
- Open your browser to
http://localhost:5173
-
Create or Join a Room
- Enter your name
- Click "Create New Room" to start a new game
- Or enter a Room ID and click "Join Room" to join an existing game
-
Wait for Players
- Share the Room ID with friends
- Need at least 2 players to start
- Maximum 6 players per room
-
Start the Game
- Once ready, click "Start Game"
- Each player receives 3 cards
-
Play Your Turn
- See Cards: View your cards (converts you from blind to seen player)
- Chaal/Bet: Place a bet (amount depends on blind/seen status)
- Pack/Fold: Give up your hand and exit the round
-
Win the Game
- Last player standing wins
- Or compare hands when only 2 players remain
teen-patti/
โโโ backend/
โ โโโ server.js # WebSocket server and game orchestration
โ โโโ gameLogic.js # Core game logic, rules, and hand evaluation
โ โโโ package.json # Backend dependencies
โ
โโโ frontend/
โ โโโ src/
โ โ โโโ components/ # Reusable UI components
โ โ โ โโโ Button.jsx
โ โ โ โโโ Card.jsx
โ โ โ โโโ Input.jsx
โ โ โ โโโ PlayingCard.jsx
โ โ โ โโโ PlayerSeat.jsx
โ โ โโโ hooks/ # Custom React hooks
โ โ โ โโโ useSocket.js
โ โ โโโ lib/ # Utility functions
โ โ โ โโโ utils.js
โ โ โโโ pages/ # Page components
โ โ โ โโโ Home.jsx
โ โ โ โโโ GameRoom.jsx
โ โ โโโ App.jsx # Main app component
โ โ โโโ main.jsx # Entry point
โ โ โโโ index.css # Global styles
โ โโโ index.html
โ โโโ package.json # Frontend dependencies
โ โโโ vite.config.js # Vite configuration
โ
โโโ README.md
createRoom- Create a new game roomjoinRoom- Join an existing roomstartGame- Start the gameseeCards- View your cardsplayerAction- Perform an action (bet, fold)leaveRoom- Leave the current room
roomCreated- Room creation confirmationroomJoined- Room join confirmationplayerJoined- Another player joinedgameStarted- Game has startedyourCards- Your dealt cardsplayerSawCards- A player viewed their cardsactionPerformed- A player performed an actionturnChanged- Turn moved to next playergameEnded- Game finished with winnerplayerLeft- A player left the roomerror- Error message
cd backend
npm run dev # Uses nodemon for auto-reloadcd frontend
npm run dev # Vite dev server with HMRFrontend:
cd frontend
npm run build
npm run preview # Preview production build- Add sideshow functionality (compare cards with another player)
- Implement show/reveal cards at the end
- Add chat functionality
- Player avatars and customization
- Game statistics and leaderboards
- Sound effects and animations
- Mobile responsive improvements
- Reconnection handling
- Spectator mode
- Multiple game variations (AK47, Muflis, etc.)
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this project for learning or personal use.
Built with โค๏ธ using modern web technologies.
Game rules reference: Casino Pride - Teen Patti Rules