Skip to content

Latest commit

ย 

History

165 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Yovi โ€” Game Y at UniOvi

Release โ€” Test, Build, Publish, Deploy Quality Gate Status Coverage

A full-stack multiplayer implementation of the Hex board game, built for the ASW course at UniOvi.

โ–ถ Play now ยท Architecture docs ยท API reference


โœจ Features

  • ๐Ÿ” 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

๐Ÿ—๏ธ Architecture

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)

Services

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

๐Ÿ“ Repository Structure

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

๐Ÿš€ Running the Project

With Docker (recommended)

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.

Without Docker (development)

You need Node.js and Rust installed.

1 โ€” Users service

cd users && npm install && npm start
# โ†’ http://localhost:3000

2 โ€” Auth service

cd auth-service && npm install && npm start
# โ†’ http://localhost:3001

3 โ€” Gamey engine

cd gamey && cargo run
# โ†’ http://localhost:4000

4 โ€” WebSocket server

cd webapp/ws-server && npm install && node index.js
# โ†’ ws://localhost:8081

5 โ€” Webapp (starts Vite dev server + users service concurrently)

cd webapp && npm install && npm run start:all
# โ†’ http://localhost:5173

๐Ÿงช Testing

Unit tests

# 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 test

End-to-end tests (Playwright + Cucumber)

The 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:run

E2E 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

Gamey benchmarks

cd gamey && cargo bench

๐Ÿ”Œ WebSocket Multiplayer Protocol

The 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

๐Ÿ“œ Available Scripts

webapp/

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

users/

Script Description
npm start Start the users service
npm test Run tests (Vitest)

gamey/

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

๐Ÿงฐ Tech Stack

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

Releases

Packages

Contributors

Languages

Generated from Arquisoft/yovi_0