# msagor/board_game architecture

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

- Interactive diagram: https://gitdiagram.com/msagor/board_game
- Repository: https://github.com/msagor/board_game

## Overview

This repository implements networked Kalah: two console clients connect to a server that sets up games and coordinates player turns, while each side uses a local game/board model. A separate standalone console game is also included. The sampled sources show board setup, move validation and execution, and turn coordination; excerpts omit some details of the server protocol and single-player behavior, so those links are limited to the documented setup and visible socket flow.

Main entry points: [`mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Mankala_kalah_server.java`](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Mankala_kalah_server.java) (Server coordinator), [`mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Mankala_kalah_client1.java`](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Mankala_kalah_client1.java) (Client 1), [`mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/Mankala_kalah_client2.java`](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/Mankala_kalah_client2.java) (Client 2), [`mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/kalah_game.java`](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/kalah_game.java) (Server game)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Player clients"]
  node_client1["Client 1"]
  node_client2["Client 2"]
  node_client1game["Client game<br/>[kalah_game.java]"]
  node_client2game["Client game<br/>[kalah_game.java]"]
  node_client1board["Client board<br/>[Board.java]"]
  node_client2board["Client board<br/>[Board.java]"]
end

subgraph group_server["Game server"]
  node_serverapp["Server coordinator"]
  node_servergame["Server game<br/>[kalah_game.java]"]
  node_serverboard["Server board<br/>[Board.java]"]
end

subgraph group_rules["Kalah rules"]
  node_client1checks["Move checks<br/>[Checks.java]"]
  node_client1moves["Move execution<br/>[Move.java]"]
  node_serverchecks["Move checks<br/>[Checks.java]"]
  node_servermoves["Move execution<br/>[Move.java]"]
end

subgraph group_standalone["Standalone game"]
  node_localgame["Console game<br/>[kalah_game.java]"]
  node_localboard["Game board<br/>[Board.java]"]
  node_localchecks["Move checks<br/>[Checks.java]"]
  node_localmoves["Move execution<br/>[Move.java]"]
end

node_player1(("Player 1"))
node_player2(("Player 2"))
node_socket["Client connections"]

node_player1 -->|"enters moves"| node_client1
node_player2 -->|"enters moves"| node_client2
node_client1 -->|"connects to"| node_socket
node_client2 -->|"connects to"| node_socket
node_serverapp -->|"accepts connections"| node_socket
node_serverapp -->|"sends setup"| node_client1
node_serverapp -->|"sends setup"| node_client2
node_client1 -->|"sends moves"| node_serverapp
node_client2 -->|"sends moves"| node_serverapp
node_client1 -->|"updates game"| node_client1game
node_client2 -->|"updates game"| node_client2game
node_client1game -->|"checks moves"| node_client1checks
node_client1game -->|"executes moves"| node_client1moves
node_client2game -.->|"checks moves"| node_client1checks
node_client2game -.->|"executes moves"| node_client1moves
node_client1 -->|"creates board"| node_client1board
node_client2 -->|"creates board"| node_client2board
node_serverapp -->|"creates board"| node_serverboard
node_serverapp -->|"creates game"| node_servergame
node_serverapp -->|"coordinates turns"| node_servergame
node_servergame -->|"checks moves"| node_serverchecks
node_servergame -->|"executes moves"| node_servermoves
node_localgame -->|"starts with board"| node_localboard
node_localgame -->|"checks moves"| node_localchecks
node_localgame -->|"executes moves"| node_localmoves

click node_client1 "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Mankala_kalah_client1.java"
click node_client2 "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/Mankala_kalah_client2.java"
click node_client1game "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/kalah_game.java"
click node_client2game "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/kalah_game.java"
click node_client1board "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Board.java"
click node_client2board "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/Board.java"
click node_serverapp "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Mankala_kalah_server.java"
click node_servergame "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/kalah_game.java"
click node_serverboard "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Board.java"
click node_client1checks "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Checks.java"
click node_client1moves "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Move.java"
click node_serverchecks "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Checks.java"
click node_servermoves "https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Move.java"
click node_localgame "https://github.com/msagor/board_game/blob/master/mankala_board_game/game%20itself/kalah_game.java"
click node_localboard "https://github.com/msagor/board_game/blob/master/mankala_board_game/game%20itself/Board.java"
click node_localchecks "https://github.com/msagor/board_game/blob/master/mankala_board_game/game%20itself/Checks.java"
click node_localmoves "https://github.com/msagor/board_game/blob/master/mankala_board_game/game%20itself/Move.java"

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_client1,node_client2,node_client1game,node_client2game,node_client1board,node_client2board,node_socket toneBlue
class node_serverapp,node_servergame,node_serverboard toneAmber
class node_client1checks,node_client1moves,node_serverchecks,node_servermoves toneMint
class node_localgame,node_localboard,node_localchecks,node_localmoves toneRose
class node_player1,node_player2 toneIndigo
```

## Components

### Player clients

- [Client 1](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Mankala_kalah_client1.java): `mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Mankala_kalah_client1.java`
- [Client 2](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/Mankala_kalah_client2.java): `mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/Mankala_kalah_client2.java`
- [Client game](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/kalah_game.java): `mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/kalah_game.java`
- [Client game](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/kalah_game.java): `mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/kalah_game.java`
- [Client board](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Board.java): `mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Board.java`
- [Client board](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/Board.java): `mankala_board_game/Mankala_kalah_client2/src/mankala_kalah_client2/Board.java`

### Game server

- [Server coordinator](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Mankala_kalah_server.java): `mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Mankala_kalah_server.java`
- [Server game](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/kalah_game.java): `mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/kalah_game.java`
- [Server board](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Board.java): `mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Board.java`

### Kalah rules

- [Move checks](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Checks.java): `mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Checks.java`
- [Move execution](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Move.java): `mankala_board_game/Mankala_kalah_client1/src/mankala_kalah_client1/Move.java`
- [Move checks](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Checks.java): `mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Checks.java`
- [Move execution](https://github.com/msagor/board_game/blob/master/mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Move.java): `mankala_board_game/Mankala_kalah_server/src/mankala_kalah_server/Move.java`

### Standalone game

- [Console game](https://github.com/msagor/board_game/blob/master/mankala_board_game/game%20itself/kalah_game.java): `mankala_board_game/game itself/kalah_game.java`
- [Game board](https://github.com/msagor/board_game/blob/master/mankala_board_game/game%20itself/Board.java): `mankala_board_game/game itself/Board.java`
- [Move checks](https://github.com/msagor/board_game/blob/master/mankala_board_game/game%20itself/Checks.java): `mankala_board_game/game itself/Checks.java`
- [Move execution](https://github.com/msagor/board_game/blob/master/mankala_board_game/game%20itself/Move.java): `mankala_board_game/game itself/Move.java`

### Other components

- **Player 1**
- **Player 2**
- **Client connections**

## Connections

- Player 1 → Client 1: enters moves
- Player 2 → Client 2: enters moves
- Client 1 → Client connections: connects to
- Client 2 → Client connections: connects to
- Server coordinator → Client connections: accepts connections
- Server coordinator → Client 1: sends setup
- Server coordinator → Client 2: sends setup
- Client 1 → Server coordinator: sends moves
- Client 2 → Server coordinator: sends moves
- Client 1 → Client game: updates game
- Client 2 → Client game: updates game
- Client game → Move checks: checks moves
- Client game → Move execution: executes moves
- Client game → Move checks: checks moves
- Client game → Move execution: executes moves
- Client 1 → Client board: creates board
- Client 2 → Client board: creates board
- Server coordinator → Server board: creates board
- Server coordinator → Server game: creates game
- Server coordinator → Server game: coordinates turns
- Server game → Move checks: checks moves
- Server game → Move execution: executes moves
- Console game → Game board: starts with board
- Console game → Move checks: checks moves
- Console game → Move execution: executes moves
