- Docker Desktop installed and running
- 8GB RAM available
- Ports 3000, 8080, and 5001 available
- Port 27017 open for local MongoDB (lock down in production)
- Player service is optional; leaderboard falls back to in-memory if
PLAYER_SERVICE_URLis unset
1. Open Terminal/Command Prompt
cd path/to/k-pong2. Start All Services
docker-compose up --buildThis single command will:
- Build Docker images for all 3 services
- Start containers in correct order
- Display logs from all services
- Start MongoDB on port 27017 with a local volume
- Allow local MongoDB access at
mongodb://localhost:27017
3. Wait for Services to Start
Watch the logs until you see:
frontend_1 | webpack compiled successfully
backend_1 | Server running on port 8080
player-service_1 | Player ranking service running on port 5001
mongo_1 | Replica set ready
4. Open Your Browser
Navigate to: http://localhost:3000
5. Play!
Enter your username and start playing!
What: Instant matchmaking with random online players
How to Use:
- Click "Quick Match" button
- Wait for an opponent
- Game starts automatically when matched
Best For: Quick games, practicing, meeting new players
What: Create a room with a shareable code to play with friends
How to Use:
- Click "Create Private Room"
- Share the 6-character code (e.g., "XY4K2N") with your friend
- Wait for them to join
- Game starts when both players connected
Best For: Playing with specific friends, tournaments, private matches
What: Join a friend's game using their room code
How to Use:
- Get the room code from your friend
- Click "Join Room"
- Enter the 6-character code
- Game starts immediately
Best For: Joining friend's games, accepting challenges
What: Watch live matches in real-time
How to Use:
- Scroll to "Live Games" section on home screen
- See list of active games showing:
- Player names
- Room code
- Number of spectators
- Game status (๐ฎ playing / โณ waiting)
- Click any game to spectate
- Watch the game live
- Click "Leave" button to stop spectating
Features:
- Real-time game updates
- See spectator count live
- Multiple people can spectate same game
- No lag or delays
- Rematches return you to the game screen (
/game) - Audio uses relative paths so hosting under a subpath still works
Fix:
docker-compose down
docker-compose up --buildFind what's using the port:
# Windows
netstat -ano | findstr :8080
# Mac/Linux
lsof -i :8080Stop Docker and try again:
docker-compose down
docker-compose upCheck Docker Desktop is running:
- Open Docker Desktop application
- Ensure it shows "Docker Desktop is running"
Clean restart:
docker-compose down -v
docker system prune -a
docker-compose up --buildReset Mongo data (if needed):
docker volume rm celo-pong_mongo-dataFix:
docker-compose restart mongoSet SOCKET_HEADER_LOGS=true in your .env to print sanitized headers (off by default).
Clear browser cache:
- Open browser DevTools (F12)
- Right-click refresh button
- Select "Empty Cache and Hard Reload"
Backend:
cd backend
pnpm install
pnpm devFrontend:
cd frontend
pnpm install
pnpm startPlayer Service:
cd player-service
pnpm install
pnpm devNote: When running locally (not Docker):
- Update
.envfiles to uselocalhostinstead of service names - Backend:
PLAYER_SERVICE_URL=http://localhost:5001 - Frontend:
REACT_APP_BACKEND_URL=http://localhost:8080 - If you skip
REACT_APP_BACKEND_URL, the frontend now falls back towindow.location.origin(orhttp://localhost:8080) and logs that decision in the browser console so you can still play locally. You can also defineREACT_APP_BACKEND_URL_FALLBACKto force a specific origin for unusual setups, or setREACT_APP_SHOW_BACKEND_URL_BANNER=falseto hide the helper banner in development. - Game History pagination now appends results; if โLoad Moreโ still repeats the first page, verify backend respects
offset. - My Wins pagination mirrors the same helper; check
limit/offsetif older wins never appear. - Backend CORS defaults to localhost when
FRONTEND_URLis missing; setFRONTEND_URLorFRONTEND_URL_FALLBACKin production. - As a last resort,
FRONTEND_URL_ALLOW_ALL=trueopens CORS to every origin (not recommended outside debugging). - Copy
.env.exampleto.envto quickly configure these variables. - Need a custom allowlist? set
FRONTEND_URL_DEV_ORIGINS=http://localhost:4173,http://localhost:3001.
Ctrl + C (in terminal running docker-compose)docker-compose downdocker-compose down -vAll services:
docker-compose logs -fSpecific service:
docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f player-serviceVisit health endpoints:
- Backend:
http://localhost:8080/health - Player Service:
http://localhost:5001/health
Expected response:
{
"status": "OK",
"service": "backend-service",
"timestamp": "2025-10-16T..."
}Limit Docker resources:
- Open Docker Desktop
- Settings โ Resources
- Set Memory to 4GB (minimum)
- Set CPUs to 2 (minimum)
Use cached layers:
docker-compose build --parallelTop Section:
- PONG-IT title with neon glow effect
- Three game mode buttons with icons
Live Games Section:
- Shows all active games
- Click any game to spectate
- Real-time spectator counts
- Game status indicators
Leaderboard:
- Top 10 players by ELO rating
- Win/Loss statistics
- Updates live after each game
Instructions:
- Controls explanation
- Game rules
Player View:
- Player names at top
- Live score board
- Room code display (private rooms only)
- 60 FPS gameplay
- Touch/mouse/keyboard controls
Spectator View:
- "SPECTATING" badge
- Spectator count
- Leave button
- Same smooth 60 FPS experience
- No control input (view only)
How it works:
- All players start at 1000 rating
- Win against higher-rated player: gain more points
- Win against lower-rated player: gain fewer points
- Minimum gain: 5 points per win
- Rating determines leaderboard position
Formula:
New Rating = Old Rating + K * (Actual - Expected)
K = 32 (standard chess ELO)
Expected = 1 / (1 + 10^((Opponent - Player)/400))
Architecture:
- Each game runs independently
- Separate 60 FPS loop per game
- Isolated game state
- No cross-game interference
- Unlimited concurrent games (limited by server resources)
How players stay in sync:
- Server calculates all game physics
- Broadcasts game state 60 times/second
- Clients render received state
- Player inputs sent to server immediately
- Server validates and applies inputs
Benefits:
- No cheating possible
- Perfect synchronization
- Fair gameplay for all players
Player Data:
- Stored in memory (Map data structure)
- Lost when services restart
- Fast access, no database overhead
Game Data:
- Temporary per-game session
- Deleted when game ends
- Results saved to Player Service
To add database:
- Add MongoDB/PostgreSQL to
docker-compose.yml - Update Player Service to connect to DB
- Replace
Mapwith database queries - No changes needed to Backend or Frontend
In Game:
โ/W- Move paddle upโ/S- Move paddle down
Browser:
F12- Open DevTools (see console logs)Ctrl + Shift + R- Hard refresh (clear cache)
Issues:
Logs Location:
- Docker logs:
docker-compose logs -f - Browser console: F12 โ Console tab
Common Log Patterns:
Good:
โ Server running on port 8080
โ Socket connected with ID: abc123
โ Game started for room: XY4K2N
Bad:
โ Connection error: ECONNREFUSED
โ Socket error: timeout
โ Failed to fetch player rating
- โ
Start the app:
docker-compose up --build - โ
Open browser:
http://localhost:3000 - โ Enter username
- โ Choose game mode
- โ Start playing!
Happy Gaming! ๐ฎ