A full-stack multiplayer implementation of the Hex board game, built for the ASW course at UniOvi.
- ๐ Auth โ JWT-based login and registration with a dedicated auth microservice
- ๐ค Bot game โ Play against an AI bot (random, greedy, or minimax strategies)
- ๐ Multiplayer โ Real-time PvP via WebSocket rooms with a 6-character room code
- ๐ฌ Live chat โ In-game chat between players during multiplayer matches
- ๐ Leaderboard โ Global ranking by win rate
- ๐ค Profile โ Per-user stats: win rate, streaks, history, bots beaten
- ๐ Monitoring โ Prometheus metrics + Grafana dashboards
The system is composed of independent microservices communicating through a central gateway:
Browser
โ
โโโโ HTTPS โโโถ nginx (TLS termination ยท port 443/80)
โ โ
โ โโโโโโโโโผโโโโโโโโโโโโโโโ
โ โผ โผ โผ
โ webapp ws-server gateway (Spring Boot ยท 8080)
โ (React) (WebSocket โ
โ ยท 8081) โโโโถ auth-service (Node.js ยท 3001)
โ โโโโถ users (Node.js ยท 3000)
โ โโโโถ gamey (Rust ยท 4000)
โ โ
โ mysql (3306)
โ
โโโโ Monitoring: Prometheus (9090) ยท Grafana (9091)
| Service | Tech | Responsibility |
|---|---|---|
nginx |
Nginx | TLS termination, reverse proxy, WebSocket upgrade |
gateway |
Spring Boot + Java | JWT validation, routing to backend services |
auth-service |
Node.js | Login / registration, JWT issuance |
users |
Node.js + Express | User CRUD, game history, leaderboard, stats |
gamey |
Rust | Game engine, move validation, bot AI (random / greedy / minimax) |
ws-server |
Node.js + ws |
WebSocket multiplayer rooms (create / join by code) |
webapp |
React + Vite + TypeScript | Single-page frontend |
mysql |
MySQL 8 | Persistent storage (users, games) |
prometheus |
Prometheus | Metrics scraping |
grafana |
Grafana | Metrics dashboards |
yovi_es4c/
โโโ webapp/ # React SPA (Vite + TypeScript + MUI)
โ โโโ src/
โ โ โโโ components/
โ โ โ โโโ auth/ # LoginForm, RegisterForm, Logout
โ โ โ โโโ game/ # Game, HexBoard, GameModeSelector,
โ โ โ โ # MultiplayerLobby, MultiplayerGame, GameHistory
โ โ โ โโโ layout/ # NavBar, LandingView, ProfileView, LeaderboardView
โ โ โโโ hooks/ # useWebSocketRoom (WS multiplayer logic)
โ โ โโโ api/ # gameyClient, api helpers
โ โโโ ws-server/ # WebSocket room server (Node.js)
โ โโโ test/e2e/ # BDD end-to-end tests (Playwright + Cucumber)
โ โโโ features/ # Gherkin feature files
โ โโโ steps/ # Step definitions
โ
โโโ auth-service/ # JWT auth microservice (Node.js)
โโโ users/ # User & game data service (Node.js + Express)
โ โโโ monitoring/ # Prometheus & Grafana config
โโโ gamey/ # Rust game engine & bot server
โ โโโ src/
โ โ โโโ core/ # Game state, coords, actions, players
โ โ โโโ bot/ # random, greedy, minimax, ybot strategies
โ โ โโโ bot_server/ # HTTP bot API
โ โ โโโ notation/ # YEN / YGN notation
โ โโโ tests/ # Integration tests
โ โโโ benches/ # Benchmarks
โโโ gateway/ # Spring Boot API gateway (JWT filter, CORS, routing)
โโโ nginx/ # Reverse proxy + TLS config
โโโ mysql/ # DB init scripts
โโโ docs/ # Arc42 architecture documentation
Requires Docker and Docker Compose.
docker-compose up --build| Endpoint | URL |
|---|---|
| Web application | https://localhost |
| Users API | http://localhost:3000 |
| Gamey API | http://localhost:4000 |
| Prometheus | http://localhost:9090 |
| Grafana | http://localhost:9091 |
Note: The first time you run this, Docker will build all images which may take a few minutes.
You need Node.js and Rust installed.
1 โ Users service
cd users && npm install && npm start
# โ http://localhost:30002 โ Auth service
cd auth-service && npm install && npm start
# โ http://localhost:30013 โ Gamey engine
cd gamey && cargo run
# โ http://localhost:40004 โ WebSocket server
cd webapp/ws-server && npm install && node index.js
# โ ws://localhost:80815 โ Webapp (starts Vite dev server + users service concurrently)
cd webapp && npm install && npm run start:all
# โ http://localhost:5173# Webapp (Vitest)
cd webapp && npm test
# Webapp with coverage
cd webapp && npm run test:coverage
# Auth service (Vitest)
cd auth-service && npm test
# Auth service with coverage
cd auth-service && npm run test:coverage
# Users service
cd users && npm test
# Users service
cd users && npm run test:coverage
# Gamey (Rust)
cd gamey && cargo testThe E2E suite covers the full user journey: registration, login, bot game, multiplayer lobby, WebSocket flow, chat, leaderboard and profile.
cd webapp
# Install Playwright browsers (first time only)
npm run test:e2e:install-browsers
# Run all E2E tests (auto-starts dev servers)
npm run test:e2e
# Run only E2E tests (dev servers must already be running)
npm run test:e2e:runE2E feature files:
| Feature | Scenarios |
|---|---|
register.feature |
User registration |
registration.feature |
Login form validation |
game-mode.feature |
Game mode selection, board size, bot starts |
bot-game.feature |
Bot gameplay, win condition, back to menu |
multiplayer-websocket.feature |
Full WebSocket lifecycle (create/join room, game, chat, errors) |
multiplayer-lobby.feature |
Lobby UI |
navigation-profile.feature |
NavBar, logout, leaderboard, profile |
cd gamey && cargo benchThe ws-server manages multiplayer rooms. Messages are JSON.
Client โ Server
| Message | Fields | Description |
|---|---|---|
create |
username, boardSize, userId? |
Create a new room |
join |
username, roomCode, userId? |
Join an existing room by code |
board_update |
layout, turn |
Broadcast a move to the opponent |
game_over |
layout, winner |
Broadcast game end |
chat |
text |
Send a chat message |
Server โ Client
| Message | Fields | Description |
|---|---|---|
room_created |
roomCode, boardSize |
Room created successfully |
game_start |
opponentName, opponentUserId, playerIndex, boardSize |
Both players connected, game starts |
board_update |
layout, turn |
Forwarded move from opponent |
game_over |
layout, winner |
Forwarded game end from opponent |
chat |
from, text |
Chat message with sender name added |
error |
message |
Error description |
| Script | Description |
|---|---|
npm run dev |
Start Vite dev server |
npm run build |
TypeScript compile + Vite build |
npm test |
Run unit tests (Vitest) |
npm run test:coverage |
Unit tests with coverage report |
npm run test:e2e |
Run E2E tests (auto-starts servers) |
npm run test:e2e:run |
Run E2E tests (servers must be running) |
npm run start:all |
Start webapp + users service concurrently |
| Script | Description |
|---|---|
npm start |
Start the users service |
npm test |
Run tests (Vitest) |
| Command | Description |
|---|---|
cargo build |
Build the game engine |
cargo test |
Run unit + integration tests |
cargo bench |
Run benchmarks |
cargo run |
Start the bot HTTP server |
cargo doc |
Generate API documentation |
| Layer | Technology |
|---|---|
| Frontend | React 18, TypeScript, Vite, MUI |
| Bot engine | Rust, Axum |
| Backend services | Node.js, Express |
| API gateway | Spring Boot, Java |
| Database | MySQL 8 |
| Real-time | WebSockets (ws library) |
| Proxy / TLS | Nginx |
| Monitoring | Prometheus, Grafana |
| Testing | Vitest, Playwright, Cucumber (BDD), Rust test + criterion |
| CI/CD | GitHub Actions |
| Code quality | SonarCloud |
| Containerisation | Docker, Docker Compose, GHCR |