# iee-ihu-gr-course1941/adise24_cubus architecture

> Architecture diagram of the GitHub repository iee-ihu-gr-course1941/adise24_cubus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iee-ihu-gr-course1941/adise24_cubus
- Repository: https://github.com/iee-ihu-gr-course1941/adise24_cubus

## Overview

Cubus is a turn-based Blokus game with a Laravel backend, React client, REST API, and WebSocket updates. Players authenticate, create or join a lobby, then request moves; the backend validates moves, updates game state, and broadcasts lobby or board changes for other players to display. The graph includes the documented profile, lobby, game, and real-time capabilities. Several client modules and route details were not excerpted, so their internal call relationships are omitted or marked unverified.

Main entry points: [`routes/web.php`](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/routes/web.php) (Web Routes), [`app/Http/Controllers/AuthService.php`](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/AuthService.php) (Authentication), [`app/Http/Controllers/GameSessionController.php`](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/GameSessionController.php) (Lobby API), [`app/Http/Controllers/GameController.php`](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/GameController.php) (Game API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend API"]
  node_routes["Web Routes<br/>[web.php]"]
  node_auth["Authentication<br/>[AuthService.php]"]
  node_profile["Profile API<br/>[UserController.php]"]
  node_lobby["Lobby API"]
  node_authorization["Authorization"]
end

subgraph group_game["Game State"]
  node_gameapi["Game API<br/>[GameController.php]"]
  node_sessions["Game Sessions<br/>[GameSession.php]"]
  node_users["User Model<br/>[User.php]"]
  node_database[("Database<br/>[database.php]")]
end

subgraph group_client["React Client"]
  node_appentry["Client Entry<br/>[app.tsx]"]
  node_pages["Game Pages<br/>[Game.tsx]"]
  node_experience["3D Experience<br/>[Experience.tsx]"]
  node_interface["Game Interface<br/>[Interface.tsx]"]
  node_board["Board Rendering<br/>[Board.tsx]"]
  node_boardstate["Board State<br/>[board_state.ts]"]
  node_network["Session Network<br/>[session_network.ts]"]
end

subgraph group_realtime["Realtime"]
  node_serverevents["Server Events<br/>[useServerEvents.ts]"]
  node_userevents["User Events<br/>[useUserEvents.ts]"]
  node_broadcastevents["Broadcast Events"]
  node_connectevent["Lobby Events<br/>[ConnectEvent.php]"]
  node_login_event["Login Event<br/>[LoginEvent.php]"]
end

node_player(("Player"))
node_iee{{"IEE Login"}}
node_websockets{{"WebSockets"}}

node_player -->|"requests API"| node_routes
node_routes -->|"routes profile"| node_profile
node_routes -->|"routes lobby"| node_lobby
node_routes -->|"routes game"| node_gameapi
node_routes -->|"applies middleware"| node_authorization
node_profile -->|"uses authentication"| node_auth
node_lobby -->|"gets user"| node_auth
node_gameapi -->|"gets user"| node_auth
node_auth -->|"requests login profile"| node_iee
node_auth -->|"finds or creates"| node_users
node_authorization -->|"checks identity"| node_auth
node_lobby -->|"creates and updates"| node_sessions
node_gameapi -->|"reads and updates"| node_sessions
node_users -->|"queries current session"| node_sessions
node_sessions -.->|"persists state"| node_database
node_lobby -->|"broadcasts lobby changes"| node_connectevent
node_gameapi -->|"broadcasts valid move"| node_broadcastevents
node_profile -->|"broadcasts login result"| node_login_event
node_connectevent -.->|"broadcasts"| node_websockets
node_broadcastevents -.->|"broadcasts"| node_websockets
node_login_event -.->|"broadcasts"| node_websockets
node_appentry -.->|"starts client pages"| node_pages
node_pages -.->|"renders game"| node_experience
node_pages -.->|"renders controls"| node_interface
node_experience -.->|"renders board"| node_board
node_board -.->|"reads game state"| node_boardstate
node_network -.->|"requests game API"| node_routes
node_userevents -->|"uses event listener"| node_serverevents
node_serverevents -.->|"listens for updates"| node_websockets
node_serverevents -.->|"updates client state"| node_boardstate

click node_routes "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/routes/web.php"
click node_auth "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/AuthService.php"
click node_profile "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/UserController.php"
click node_lobby "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/GameSessionController.php"
click node_gameapi "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/GameController.php"
click node_sessions "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Models/GameSession.php"
click node_users "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Models/User.php"
click node_database "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/config/database.php"
click node_authorization "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Middleware/ManageAuthorization.php"
click node_appentry "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/app.tsx"
click node_pages "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Pages/Game.tsx"
click node_experience "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Game/Experience.tsx"
click node_interface "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Game/Interface.tsx"
click node_board "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Game/Board/Board.tsx"
click node_boardstate "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Store/board_state.ts"
click node_network "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/network/session_network.ts"
click node_serverevents "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Connection/useServerEvents.ts"
click node_userevents "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Connection/useUserEvents.ts"
click node_broadcastevents "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Events/BoardUpdateEvent.php"
click node_connectevent "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Events/ConnectEvent.php"
click node_login_event "https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Events/LoginEvent.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routes,node_auth,node_profile,node_lobby,node_authorization toneBlue
class node_gameapi,node_sessions,node_users,node_database toneAmber
class node_appentry,node_pages,node_experience,node_interface,node_board,node_boardstate,node_network toneMint
class node_serverevents,node_userevents,node_broadcastevents,node_connectevent,node_login_event toneRose
class node_player,node_iee,node_websockets toneIndigo
```

## Components

### Backend API

- [Web Routes](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/routes/web.php): `routes/web.php`
- [Authentication](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/AuthService.php): `app/Http/Controllers/AuthService.php`
- [Profile API](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/UserController.php): `app/Http/Controllers/UserController.php`
- [Lobby API](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/GameSessionController.php): `app/Http/Controllers/GameSessionController.php`
- [Authorization](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Middleware/ManageAuthorization.php): `app/Http/Middleware/ManageAuthorization.php`

### Game State

- [Game API](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Http/Controllers/GameController.php): `app/Http/Controllers/GameController.php`
- [Game Sessions](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Models/GameSession.php): `app/Models/GameSession.php`
- [User Model](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Models/User.php): `app/Models/User.php`
- [Database](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/config/database.php): `config/database.php`

### React Client

- [Client Entry](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/app.tsx): `resources/js/app.tsx`
- [Game Pages](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Pages/Game.tsx): `resources/js/Pages/Game.tsx`
- [3D Experience](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Game/Experience.tsx): `resources/js/Game/Experience.tsx`
- [Game Interface](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Game/Interface.tsx): `resources/js/Game/Interface.tsx`
- [Board Rendering](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Game/Board/Board.tsx): `resources/js/Game/Board/Board.tsx`
- [Board State](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Store/board_state.ts): `resources/js/Store/board_state.ts`
- [Session Network](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/network/session_network.ts): `resources/js/network/session_network.ts`

### Realtime

- [Server Events](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Connection/useServerEvents.ts): `resources/js/Connection/useServerEvents.ts`
- [User Events](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/resources/js/Connection/useUserEvents.ts): `resources/js/Connection/useUserEvents.ts`
- [Broadcast Events](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Events/BoardUpdateEvent.php): `app/Events/BoardUpdateEvent.php`
- [Lobby Events](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Events/ConnectEvent.php): `app/Events/ConnectEvent.php`
- [Login Event](https://github.com/iee-ihu-gr-course1941/adise24_cubus/blob/main/app/Events/LoginEvent.php): `app/Events/LoginEvent.php`

### Other components

- **Player**
- **IEE Login**
- **WebSockets**

## Connections

- Player → Web Routes: requests API
- Web Routes → Profile API: routes profile (evidence: `routes/web.php`)
- Web Routes → Lobby API: routes lobby (evidence: `routes/web.php`)
- Web Routes → Game API: routes game (evidence: `routes/web.php`)
- Web Routes → Authorization: applies middleware (evidence: `routes/web.php`)
- Profile API → Authentication: uses authentication (evidence: `app/Http/Controllers/UserController.php`)
- Lobby API → Authentication: gets user (evidence: `app/Http/Controllers/GameSessionController.php`)
- Game API → Authentication: gets user (evidence: `app/Http/Controllers/GameController.php`)
- Authentication → IEE Login: requests login profile (evidence: `app/Http/Controllers/AuthService.php`)
- Authentication → User Model: finds or creates (evidence: `app/Http/Controllers/AuthService.php`)
- Authorization → Authentication: checks identity (evidence: `app/Http/Middleware/ManageAuthorization.php`)
- Lobby API → Game Sessions: creates and updates (evidence: `app/Http/Controllers/GameSessionController.php`)
- Game API → Game Sessions: reads and updates (evidence: `app/Http/Controllers/GameController.php`)
- User Model → Game Sessions: queries current session (evidence: `app/Models/User.php`)
- Game Sessions → Database: persists state
- Lobby API → Lobby Events: broadcasts lobby changes (evidence: `app/Http/Controllers/GameSessionController.php`)
- Game API → Broadcast Events: broadcasts valid move (evidence: `app/Http/Controllers/GameController.php`)
- Profile API → Login Event: broadcasts login result (evidence: `app/Http/Controllers/UserController.php`)
- Lobby Events → WebSockets: broadcasts
- Broadcast Events → WebSockets: broadcasts
- Login Event → WebSockets: broadcasts
- Client Entry → Game Pages: starts client pages
- Game Pages → 3D Experience: renders game
- Game Pages → Game Interface: renders controls
- 3D Experience → Board Rendering: renders board
- Board Rendering → Board State: reads game state
- Session Network → Web Routes: requests game API
- User Events → Server Events: uses event listener (evidence: `resources/js/Connection/useUserEvents.ts`)
- Server Events → WebSockets: listens for updates
- Server Events → Board State: updates client state
