# jp987654/omok-lab architecture

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

- Interactive diagram: https://gitdiagram.com/jp987654/omok-lab
- Repository: https://github.com/jp987654/omok-lab

## Overview

This is a PHP Omok (Gomoku) web service. A client requests game information or creates a game, then submits moves using a game ID; the service applies the player's move, asks the selected strategy for a computer reply when needed, and persists the updated board as JSON. The graph covers the documented endpoints and the sampled game, board, and strategy layers. The README only gives launch commands, so no client-to-endpoint integration is asserted.

Main entry points: [`lib/Game.php`](https://github.com/jp987654/omok-lab/blob/main/lib/Game.php) (Game Logic), [`lib/Strategies.php`](https://github.com/jp987654/omok-lab/blob/main/lib/Strategies.php) (Strategy Registry), [`lib/Board.php`](https://github.com/jp987654/omok-lab/blob/main/lib/Board.php) (Board Rules), [`info/index.php`](https://github.com/jp987654/omok-lab/blob/main/info/index.php) (Game Info)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_info["Game Info<br/>[index.php]"]
  node_new["New Game<br/>[index.php]"]
  node_play["Play Move<br/>[index.php]"]
  node_common["JSON Helpers<br/>[common.php]"]
end

subgraph group_game["Game State"]
  node_game["Game Logic<br/>[Game.php]"]
  node_board["Board Rules<br/>[Board.php]"]
  node_jsonstore[("JSON Save Files<br/>[Game.php]")]
end

subgraph group_strategy["Move Strategies"]
  node_registry["Strategy Registry<br/>[Strategies.php]"]
  node_strategyinterface["Move Contract<br/>[MoveStrategy.php]"]
  node_random["Random Strategy<br/>[RandomStrategy.php]"]
  node_smart["Smart Strategy<br/>[SmartStrategy.php]"]
end

node_caller(("HTTP Caller"))

node_caller -->|"requests info"| node_info
node_caller -->|"creates game"| node_new
node_caller -->|"submits move"| node_play
node_info -->|"loads helpers"| node_common
node_info -->|"reports size"| node_board
node_info -->|"lists strategies"| node_registry
node_new -->|"loads helpers"| node_common
node_new -->|"validates strategy"| node_registry
node_new -->|"creates and saves"| node_game
node_play -->|"loads helpers"| node_common
node_play -->|"loads and moves"| node_game
node_play -->|"checks vacancy"| node_board
node_game -->|"updates and checks"| node_board
node_game -->|"creates strategy"| node_registry
node_game -->|"reads and writes"| node_jsonstore
node_registry -->|"instantiates"| node_random
node_registry -->|"instantiates"| node_smart
node_random -->|"implements"| node_strategyinterface
node_random -->|"chooses empty cell"| node_board
node_smart -->|"falls back to"| node_random
node_smart -->|"evaluates lines"| node_board

click node_info "https://github.com/jp987654/omok-lab/blob/main/info/index.php"
click node_new "https://github.com/jp987654/omok-lab/blob/main/new/index.php"
click node_play "https://github.com/jp987654/omok-lab/blob/main/play/index.php"
click node_common "https://github.com/jp987654/omok-lab/blob/main/lib/common.php"
click node_game "https://github.com/jp987654/omok-lab/blob/main/lib/Game.php"
click node_board "https://github.com/jp987654/omok-lab/blob/main/lib/Board.php"
click node_jsonstore "https://github.com/jp987654/omok-lab/blob/main/lib/Game.php"
click node_registry "https://github.com/jp987654/omok-lab/blob/main/lib/Strategies.php"
click node_strategyinterface "https://github.com/jp987654/omok-lab/blob/main/lib/MoveStrategy.php"
click node_random "https://github.com/jp987654/omok-lab/blob/main/lib/RandomStrategy.php"
click node_smart "https://github.com/jp987654/omok-lab/blob/main/lib/SmartStrategy.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_info,node_new,node_play,node_common toneBlue
class node_game,node_board,node_jsonstore toneAmber
class node_registry,node_strategyinterface,node_random,node_smart toneMint
class node_caller toneIndigo
```

## Components

### HTTP API

- [Game Info](https://github.com/jp987654/omok-lab/blob/main/info/index.php): `info/index.php`
- [New Game](https://github.com/jp987654/omok-lab/blob/main/new/index.php): `new/index.php`
- [Play Move](https://github.com/jp987654/omok-lab/blob/main/play/index.php): `play/index.php`
- [JSON Helpers](https://github.com/jp987654/omok-lab/blob/main/lib/common.php): `lib/common.php`

### Game State

- [Game Logic](https://github.com/jp987654/omok-lab/blob/main/lib/Game.php): `lib/Game.php`
- [Board Rules](https://github.com/jp987654/omok-lab/blob/main/lib/Board.php): `lib/Board.php`
- [JSON Save Files](https://github.com/jp987654/omok-lab/blob/main/lib/Game.php): `lib/Game.php`

### Move Strategies

- [Strategy Registry](https://github.com/jp987654/omok-lab/blob/main/lib/Strategies.php): `lib/Strategies.php`
- [Move Contract](https://github.com/jp987654/omok-lab/blob/main/lib/MoveStrategy.php): `lib/MoveStrategy.php`
- [Random Strategy](https://github.com/jp987654/omok-lab/blob/main/lib/RandomStrategy.php): `lib/RandomStrategy.php`
- [Smart Strategy](https://github.com/jp987654/omok-lab/blob/main/lib/SmartStrategy.php): `lib/SmartStrategy.php`

### Other components

- **HTTP Caller**

## Connections

- HTTP Caller → Game Info: requests info (evidence: `info/index.php`)
- HTTP Caller → New Game: creates game (evidence: `new/index.php`)
- HTTP Caller → Play Move: submits move (evidence: `play/index.php`)
- Game Info → JSON Helpers: loads helpers (evidence: `info/index.php`)
- Game Info → Board Rules: reports size (evidence: `info/index.php`)
- Game Info → Strategy Registry: lists strategies (evidence: `info/index.php`)
- New Game → JSON Helpers: loads helpers (evidence: `new/index.php`)
- New Game → Strategy Registry: validates strategy (evidence: `new/index.php`)
- New Game → Game Logic: creates and saves (evidence: `new/index.php`)
- Play Move → JSON Helpers: loads helpers (evidence: `play/index.php`)
- Play Move → Game Logic: loads and moves (evidence: `play/index.php`)
- Play Move → Board Rules: checks vacancy (evidence: `play/index.php`)
- Game Logic → Board Rules: updates and checks (evidence: `lib/Game.php`)
- Game Logic → Strategy Registry: creates strategy (evidence: `lib/Game.php`)
- Game Logic → JSON Save Files: reads and writes (evidence: `lib/Game.php`)
- Strategy Registry → Random Strategy: instantiates (evidence: `lib/Strategies.php`)
- Strategy Registry → Smart Strategy: instantiates (evidence: `lib/Strategies.php`)
- Random Strategy → Move Contract: implements (evidence: `lib/RandomStrategy.php`)
- Random Strategy → Board Rules: chooses empty cell (evidence: `lib/RandomStrategy.php`)
- Smart Strategy → Random Strategy: falls back to (evidence: `lib/SmartStrategy.php`)
- Smart Strategy → Board Rules: evaluates lines (evidence: `lib/SmartStrategy.php`)
