# khanlarazizov/domino-game architecture

> Architecture diagram of the GitHub repository khanlarazizov/domino-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khanlarazizov/domino-game
- Repository: https://github.com/khanlarazizov/domino-game

## Overview

This Laravel application exposes a domino game API: a player can authenticate, create a game against bots, and receive game state; bot turns and moves are also represented in services, jobs, and events. GameService coordinates player setup, tile dealing, first-player rules, state initialization, and move dispatch, while repository implementations persist domain records. The README describes Laravel generally, not this product. Edges reflect excerpts and SOURCE INDEX references; unshown route wiring and some runtime behavior are left out or marked unverified.

Main entry points: [`app/Services/GameService.php`](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GameService.php) (Game orchestration), [`app/Repositories/Contracts/IBaseRepository.php`](https://github.com/khanlarazizov/domino-game/blob/main/app/Repositories/Contracts/IBaseRepository.php) (Repository contracts), [`app/Http/Controllers/Api/V1/GameController.php`](https://github.com/khanlarazizov/domino-game/blob/main/app/Http/Controllers/Api/V1/GameController.php) (Game API), [`app/Jobs/MakeBotMoveJob.php`](https://github.com/khanlarazizov/domino-game/blob/main/app/Jobs/MakeBotMoveJob.php) (Bot move job)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_auth_controller["Auth API<br/>[AuthController.php]"]
  node_auth_service["Authentication<br/>[AuthService.php]"]
  node_game_controller["Game API<br/>[GameController.php]"]
  node_game_resource["Game response<br/>[GameResource.php]"]
end

subgraph group_gameplay["Game setup and rules"]
  node_game_service["Game orchestration<br/>[GameService.php]"]
  node_tile_service["Tile dealing<br/>[TileService.php]"]
  node_hand_service["Player hands"]
  node_rule_service["Opening rules"]
  node_state_service["Game state"]
end

subgraph group_moves["Turns and bots"]
  node_bot_service["Bot play API<br/>[BotService.php]"]
  node_bot_move_service["Bot move handling<br/>[BotMoveService.php]"]
  node_bot_logic["Bot strategy"]
  node_bot_job["Bot move job<br/>[MakeBotMoveJob.php]"]
  node_human_job["Human move job"]
  node_bot_event["Bot move event"]
end

subgraph group_persistence["Domain persistence"]
  node_game_player_model["Game participants<br/>[GamePlayer.php]"]
  node_hand_model["Player tile records<br/>[GamePlayerTile.php]"]
  node_repository_contracts["Repository contracts"]
  node_repositories["Eloquent repositories<br/>[BaseRepository.php]"]
end

node_player(("Player"))
node_database[("Application database")]

node_player -.->|"requests login"| node_auth_controller
node_auth_controller -->|"delegates login"| node_auth_service
node_auth_service -->|"issues token"| node_player
node_player -.->|"requests game"| node_game_controller
node_game_controller -->|"creates game"| node_game_service
node_game_controller -->|"requests bot move"| node_bot_service
node_game_controller -->|"formats response"| node_game_resource
node_game_service -->|"gets shuffled tiles"| node_tile_service
node_game_service -->|"assigns tiles"| node_hand_service
node_game_service -->|"selects first player"| node_rule_service
node_game_service -->|"initializes state"| node_state_service
node_game_service -->|"dispatches bot turn"| node_bot_job
node_game_service -->|"dispatches human turn"| node_human_job
node_bot_job -->|"uses strategy"| node_bot_logic
node_bot_job -->|"fires event"| node_bot_event
node_bot_service -.->|"coordinates move"| node_bot_move_service
node_game_service -->|"uses repositories"| node_repository_contracts
node_tile_service -->|"reads tiles"| node_repository_contracts
node_hand_service -->|"stores hands"| node_repository_contracts
node_rule_service -->|"reads hands"| node_repository_contracts
node_repository_contracts -->|"implemented by"| node_repositories
node_repositories -->|"queries records"| node_database
node_game_player_model -->|"owns tile records"| node_hand_model
node_hand_model -->|"belongs to player"| node_game_player_model

click node_auth_controller "https://github.com/khanlarazizov/domino-game/blob/main/app/Http/Controllers/Api/V1/AuthController.php"
click node_auth_service "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/AuthService.php"
click node_game_controller "https://github.com/khanlarazizov/domino-game/blob/main/app/Http/Controllers/Api/V1/GameController.php"
click node_game_resource "https://github.com/khanlarazizov/domino-game/blob/main/app/Http/Resources/GameResource.php"
click node_game_service "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GameService.php"
click node_tile_service "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/TileService.php"
click node_hand_service "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GamePlayerTileService.php"
click node_rule_service "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GameRuleService.php"
click node_state_service "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GameStateService.php"
click node_bot_service "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/BotService.php"
click node_bot_move_service "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/BotMoveService.php"
click node_bot_logic "https://github.com/khanlarazizov/domino-game/blob/main/app/Services/BotLogicService.php"
click node_bot_job "https://github.com/khanlarazizov/domino-game/blob/main/app/Jobs/MakeBotMoveJob.php"
click node_human_job "https://github.com/khanlarazizov/domino-game/blob/main/app/Jobs/MakeHumanMoveJob.php"
click node_bot_event "https://github.com/khanlarazizov/domino-game/blob/main/app/Events/BotPlayedTileEvent.php"
click node_game_player_model "https://github.com/khanlarazizov/domino-game/blob/main/app/Models/GamePlayer.php"
click node_hand_model "https://github.com/khanlarazizov/domino-game/blob/main/app/Models/GamePlayerTile.php"
click node_repository_contracts "https://github.com/khanlarazizov/domino-game/blob/main/app/Repositories/Contracts/IBaseRepository.php"
click node_repositories "https://github.com/khanlarazizov/domino-game/blob/main/app/Repositories/Eloquents/BaseRepository.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_auth_controller,node_auth_service,node_game_controller,node_game_resource toneBlue
class node_game_service,node_tile_service,node_hand_service,node_rule_service,node_state_service,node_database toneAmber
class node_bot_service,node_bot_move_service,node_bot_logic,node_bot_job,node_human_job,node_bot_event toneMint
class node_game_player_model,node_hand_model,node_repository_contracts,node_repositories toneRose
class node_player toneIndigo
```

## Components

### API and identity

- [Auth API](https://github.com/khanlarazizov/domino-game/blob/main/app/Http/Controllers/Api/V1/AuthController.php): `app/Http/Controllers/Api/V1/AuthController.php`
- [Authentication](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/AuthService.php): `app/Services/AuthService.php`
- [Game API](https://github.com/khanlarazizov/domino-game/blob/main/app/Http/Controllers/Api/V1/GameController.php): `app/Http/Controllers/Api/V1/GameController.php`
- [Game response](https://github.com/khanlarazizov/domino-game/blob/main/app/Http/Resources/GameResource.php): `app/Http/Resources/GameResource.php`

### Game setup and rules

- [Game orchestration](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GameService.php): `app/Services/GameService.php`
- [Tile dealing](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/TileService.php): `app/Services/TileService.php`
- [Player hands](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GamePlayerTileService.php): `app/Services/GamePlayerTileService.php`
- [Opening rules](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GameRuleService.php): `app/Services/GameRuleService.php`
- [Game state](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/GameStateService.php): `app/Services/GameStateService.php`

### Turns and bots

- [Bot play API](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/BotService.php): `app/Services/BotService.php`
- [Bot move handling](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/BotMoveService.php): `app/Services/BotMoveService.php`
- [Bot strategy](https://github.com/khanlarazizov/domino-game/blob/main/app/Services/BotLogicService.php): `app/Services/BotLogicService.php`
- [Bot move job](https://github.com/khanlarazizov/domino-game/blob/main/app/Jobs/MakeBotMoveJob.php): `app/Jobs/MakeBotMoveJob.php`
- [Human move job](https://github.com/khanlarazizov/domino-game/blob/main/app/Jobs/MakeHumanMoveJob.php): `app/Jobs/MakeHumanMoveJob.php`
- [Bot move event](https://github.com/khanlarazizov/domino-game/blob/main/app/Events/BotPlayedTileEvent.php): `app/Events/BotPlayedTileEvent.php`

### Domain persistence

- [Game participants](https://github.com/khanlarazizov/domino-game/blob/main/app/Models/GamePlayer.php): `app/Models/GamePlayer.php`
- [Player tile records](https://github.com/khanlarazizov/domino-game/blob/main/app/Models/GamePlayerTile.php): `app/Models/GamePlayerTile.php`
- [Repository contracts](https://github.com/khanlarazizov/domino-game/blob/main/app/Repositories/Contracts/IBaseRepository.php): `app/Repositories/Contracts/IBaseRepository.php`
- [Eloquent repositories](https://github.com/khanlarazizov/domino-game/blob/main/app/Repositories/Eloquents/BaseRepository.php): `app/Repositories/Eloquents/BaseRepository.php`

### Other components

- **Player**
- **Application database**

## Connections

- Player → Auth API: requests login
- Auth API → Authentication: delegates login (evidence: `app/Http/Controllers/Api/V1/AuthController.php`)
- Authentication → Player: issues token (evidence: `app/Services/AuthService.php`)
- Player → Game API: requests game
- Game API → Game orchestration: creates game (evidence: `app/Http/Controllers/Api/V1/GameController.php`)
- Game API → Bot play API: requests bot move (evidence: `app/Http/Controllers/Api/V1/GameController.php`)
- Game API → Game response: formats response (evidence: `app/Http/Controllers/Api/V1/GameController.php`)
- Game orchestration → Tile dealing: gets shuffled tiles (evidence: `app/Services/GameService.php`)
- Game orchestration → Player hands: assigns tiles (evidence: `app/Services/GameService.php`)
- Game orchestration → Opening rules: selects first player (evidence: `app/Services/GameService.php`)
- Game orchestration → Game state: initializes state (evidence: `app/Services/GameService.php`)
- Game orchestration → Bot move job: dispatches bot turn (evidence: `app/Services/GameService.php`)
- Game orchestration → Human move job: dispatches human turn (evidence: `app/Services/GameService.php`)
- Bot move job → Bot strategy: uses strategy (evidence: `app/Jobs/MakeBotMoveJob.php`)
- Bot move job → Bot move event: fires event (evidence: `app/Jobs/MakeBotMoveJob.php`)
- Bot play API → Bot move handling: coordinates move
- Game orchestration → Repository contracts: uses repositories (evidence: `app/Services/GameService.php`)
- Tile dealing → Repository contracts: reads tiles (evidence: `app/Services/TileService.php`)
- Player hands → Repository contracts: stores hands (evidence: `app/Services/GamePlayerTileService.php`)
- Opening rules → Repository contracts: reads hands (evidence: `app/Services/GameRuleService.php`)
- Repository contracts → Eloquent repositories: implemented by (evidence: `app/Repositories/Eloquents/BaseRepository.php`)
- Eloquent repositories → Application database: queries records (evidence: `app/Repositories/Eloquents/BaseRepository.php`)
- Game participants → Player tile records: owns tile records (evidence: `app/Models/GamePlayer.php`)
- Player tile records → Game participants: belongs to player (evidence: `app/Models/GamePlayerTile.php`)
