A real-time multiplayer web implementation of the classic Chain Reaction board game. Create cascading reactions, dominate the board, and outsmart your opponents in this intense strategy game.
Live Demo: https://chain-reaction-tau.vercel.app/
- Chain Reaction Mechanics: Classic board game rules with cascading explosions
- Multiple Game Modes: Play locally on the same device or online with friends
- Real-time Multiplayer: Up to 4 players in online rooms with instant synchronization
- Strategic Gameplay: Plan your moves carefully and anticipate opponent strategies
- Room-based Matchmaking: Create or join game rooms with unique room codes
- Voice Chat: Integrated peer-to-peer voice communication using WebRTC
- Google Authentication: Quick sign-in with Google OAuth
- Player Reconnection: Rejoin active games after disconnection
- Game State Persistence: MongoDB-backed game state management
- Real-time Synchronization: Socket.IO for lag-free multiplayer experience
- Responsive Design: Modern UI with smooth animations and transitions
- Sound Effects: Immersive audio feedback for explosions and game events
- Comprehensive Testing: Jest test suite with coverage reporting
This project consists of two main components:
-
Next.js Frontend (
/src)- React-based UI with TypeScript
- Game engine and state management
- Socket.IO client for real-time communication
- NextAuth for authentication
-
Socket Server (
/socket-server)- Node.js/Express server
- Socket.IO for WebSocket connections
- Game state synchronization
- WebRTC signaling for voice chat
- Node.js 20 or higher
- npm or yarn or pnpm
- MongoDB Atlas account (or local MongoDB instance)
- Google OAuth credentials (for authentication)
- PeerJS account (for voice chat, optional)
git clone <repository-url>
cd chainreactionFrontend:
npm installSocket Server:
cd socket-server
npm install
cd ..Create a .env.local file in the root directory:
# Next.js Configuration
NEXTAUTH_URL=http://localhost:3003
NEXTAUTH_SECRET=your-secret-key-here
# Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# MongoDB
MONGODB_URI=your-mongodb-connection-string
# Socket Server
NEXT_PUBLIC_SOCKET_URL=http://localhost:3001
# PeerJS (for voice chat)
NEXT_PUBLIC_PEERJS_HOST=your-peerjs-host
NEXT_PUBLIC_PEERJS_PORT=443
NEXT_PUBLIC_PEERJS_PATH=/peerjsCreate a .env file in the socket-server directory:
SOCKET_PORT=3001
CLIENT_URL=http://localhost:3003Terminal 1 - Frontend:
npm run devTerminal 2 - Socket Server:
cd socket-server
npm run devThe application will be available at:
- Frontend: http://localhost:3003
- Socket Server: http://localhost:3001
chainreaction/
├── src/
│ ├── app/ # Next.js app directory
│ │ ├── api/ # API routes
│ │ │ ├── auth/ # NextAuth configuration
│ │ │ └── rooms/ # Room management API
│ │ ├── game/ # Game page
│ │ ├── lobby/ # Lobby page
│ │ └── local/ # Local multiplayer page
│ ├── components/
│ │ ├── game/ # Game components
│ │ │ ├── ChainReactionEngine.ts
│ │ │ ├── GameBoard.tsx
│ │ │ ├── OnlineMultiplayerGame.tsx
│ │ │ └── VoiceChatPanel.tsx
│ │ └── Header.tsx
│ ├── hooks/ # Custom React hooks
│ │ ├── useGameState.ts
│ │ ├── useOnlineGameState.ts
│ │ ├── useSocket.ts
│ │ └── useVoiceChat.ts
│ ├── lib/ # Utilities
│ │ ├── mongodb.ts
│ │ └── botPlayer.ts
│ └── types/ # TypeScript definitions
├── socket-server/ # Socket.IO server
│ ├── index.js # Main server file
│ └── config.js # Server configuration
├── coverage/ # Test coverage reports
└── public/ # Static assets
- Next.js 15 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first styling
- Zustand - State management
- Socket.IO Client - Real-time communication
- NextAuth - Authentication
- PeerJS - WebRTC for voice chat
- Node.js - Runtime environment
- Express - Web framework
- Socket.IO - WebSocket server
- MongoDB - Database
- Jest - Testing framework
- ESLint - Code linting
- TypeScript - Type checking
Run the test suite:
# Run all tests
npm test
# Watch mode
npm run test:watch
# With coverage
npm run test:coveragenpm run dev- Start development server (port 3003)npm run build- Build for productionnpm start- Start production servernpm run lint- Run ESLintnpm test- Run testsnpm run test:watch- Run tests in watch modenpm run test:coverage- Generate test coverage report
npm start- Start production servernpm run dev- Start development server with auto-reload
Chain Reaction is a strategy board game where players place orbs on a grid. When a cell reaches its maximum capacity (based on its position), it explodes and distributes orbs to adjacent cells. The goal is to eliminate all opponents and be the last player standing.
- Corner cells: Max 1 orb
- Edge cells: Max 2 orbs
- Center cells: Max 3 orbs
- Explosions: Distribute orbs to adjacent cells (up, down, left, right)
- Chain Reactions: Explosions can trigger other explosions
- Player Elimination: Players are eliminated when they lose all their orbs
The application is currently deployed at: https://chain-reaction-tau.vercel.app/lobby
The socket server can be deployed to any Node.js hosting service (Azure, Railway, Render, etc.). See socket-server/README.md for detailed deployment instructions.