# dkconnect/creator architecture

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

- Interactive diagram: https://gitdiagram.com/dkconnect/creator
- Repository: https://github.com/dkconnect/creator

## Overview

CREATOR is a desktop, turn-based board game in which players move pawns to form a selected pattern; it also supports AI opponents and networked multiplayer. The main loop in main.py coordinates menus, local play, and multiplayer play, then renders the active screen. Multiplayer adds room/lobby setup and synchronized game state. The graph includes core rules, AI, UI, and network layers. README documentation is only a title, so capability coverage relies on the source index and excerpts; unsampled relationships are omitted where they cannot be verified.

Main entry points: [`main.py`](https://github.com/dkconnect/creator/blob/main/main.py) (Game Loop), [`engine/game.py`](https://github.com/dkconnect/creator/blob/main/engine/game.py) (Game State and Turns), [`engine/movement.py`](https://github.com/dkconnect/creator/blob/main/engine/movement.py) (Legal Movement), [`network/multiplayer_client.py`](https://github.com/dkconnect/creator/blob/main/network/multiplayer_client.py) (Multiplayer Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app_ui["Application and UI"]
  node_main_loop["Game Loop<br/>[main.py]"]
  node_menu["Menus and Lobby UI<br/>[menu_renderer.py]"]
  node_menu_state["Menu State<br/>[menu_state.py]"]
  node_input["Input Mapping<br/>[input_manager.py]"]
  node_renderer["Game Renderer<br/>[renderer.py]"]
  node_viewport["Viewport<br/>[viewport.py]"]
  node_native_board["Native Board<br/>[native_board.py]"]
  node_native_hud["Native HUD<br/>[native_hud.py]"]
  node_multi_hud["Multiplayer HUD<br/>[multiplayer_hud.py]"]
  node_multi_result["Multiplayer Results"]
end

subgraph group_game_rules["Game Rules and AI"]
  node_game["Game State and Turns<br/>[game.py]"]
  node_movement["Legal Movement<br/>[movement.py]"]
  node_victory["Pattern Victory<br/>[victory.py]"]
  node_pattern["Pattern Definition<br/>[pattern.py]"]
  node_capture["Capture and Reserves<br/>[capture.py]"]
  node_pawn["Pawn Model<br/>[pawn.py]"]
  node_ai_basic["Basic AI<br/>[basic_ai.py]"]
  node_ai_learning["Learning AI<br/>[learning_ai.py]"]
  node_ai_advanced["Advanced AI<br/>[advanced_ai.py]"]
  node_ai_base["AI Interface<br/>[base_ai.py]"]
  node_protocol["Message Protocol<br/>[protocol.py]"]
end

subgraph group_client_network["Multiplayer Client"]
  node_client["Multiplayer Client"]
  node_adapter["Client Game Adapter"]
  node_client_state["Client Game State"]
  node_tcp_client["TCP Client<br/>[tcp_client.py]"]
end

subgraph group_server_network["Multiplayer Server"]
  node_server["TCP Server<br/>[tcp_server.py]"]
  node_router["Connection Router"]
  node_rooms["Room Manager<br/>[room_manager.py]"]
  node_session["Game Session<br/>[game_session.py]"]
  node_handler["Server Handler<br/>[server_handler.py]"]
end

node_player(("Player"))

node_player -->|"plays through"| node_main_loop
node_main_loop -->|"draws menus"| node_menu
node_main_loop -->|"updates state"| node_menu_state
node_main_loop -->|"reads clicks"| node_input
node_main_loop -->|"runs turns"| node_game
node_main_loop -->|"draws game"| node_renderer
node_main_loop -->|"translates events"| node_viewport
node_main_loop -->|"uses board view"| node_native_board
node_main_loop -->|"uses HUD"| node_native_hud
node_main_loop -->|"shows multiplayer"| node_multi_hud
node_main_loop -->|"shows results"| node_multi_result
node_main_loop -->|"sends requests"| node_client
node_menu -->|"renders state"| node_menu_state
node_menu -->|"uses coordinates"| node_viewport
node_renderer -->|"uses coordinates"| node_viewport
node_game -->|"checks moves"| node_movement
node_game -->|"checks victory"| node_victory
node_game -->|"resolves captures"| node_capture
node_game -->|"loads pattern"| node_pattern
node_game -->|"creates pawns"| node_pawn
node_game -->|"records learning"| node_ai_learning
node_ai_basic -->|"implements interface"| node_ai_base
node_ai_learning -->|"implements interface"| node_ai_base
node_ai_advanced -->|"implements interface"| node_ai_base
node_ai_basic -->|"queries legal moves"| node_movement
node_ai_learning -->|"queries legal moves"| node_movement
node_ai_advanced -->|"queries legal moves"| node_movement
node_ai_advanced -->|"evaluates victory"| node_victory
node_client -->|"builds messages"| node_protocol
node_client -->|"sends requests"| node_tcp_client
node_client -->|"updates state"| node_client_state
node_main_loop -->|"adapts game state"| node_adapter
node_adapter -->|"uses movement rules"| node_movement
node_server -.->|"routes connections"| node_router
node_router -->|"uses message types"| node_protocol
node_router -->|"dispatches room actions"| node_rooms
node_rooms -->|"creates and dispatches"| node_session
node_session -->|"runs game state"| node_game
node_session -->|"uses handlers"| node_handler
node_session -->|"formats messages"| node_protocol
node_handler -->|"uses message types"| node_protocol

click node_main_loop "https://github.com/dkconnect/creator/blob/main/main.py"
click node_menu "https://github.com/dkconnect/creator/blob/main/ui/menu_renderer.py"
click node_menu_state "https://github.com/dkconnect/creator/blob/main/ui/menu_state.py"
click node_input "https://github.com/dkconnect/creator/blob/main/ui/input_manager.py"
click node_renderer "https://github.com/dkconnect/creator/blob/main/ui/renderer.py"
click node_viewport "https://github.com/dkconnect/creator/blob/main/ui/viewport.py"
click node_native_board "https://github.com/dkconnect/creator/blob/main/ui/native_board.py"
click node_native_hud "https://github.com/dkconnect/creator/blob/main/ui/native_hud.py"
click node_multi_hud "https://github.com/dkconnect/creator/blob/main/ui/multiplayer_hud.py"
click node_multi_result "https://github.com/dkconnect/creator/blob/main/ui/multiplayer_result.py"
click node_game "https://github.com/dkconnect/creator/blob/main/engine/game.py"
click node_movement "https://github.com/dkconnect/creator/blob/main/engine/movement.py"
click node_victory "https://github.com/dkconnect/creator/blob/main/engine/victory.py"
click node_pattern "https://github.com/dkconnect/creator/blob/main/engine/pattern.py"
click node_capture "https://github.com/dkconnect/creator/blob/main/engine/capture.py"
click node_pawn "https://github.com/dkconnect/creator/blob/main/engine/pawn.py"
click node_ai_basic "https://github.com/dkconnect/creator/blob/main/engine/ai/basic_ai.py"
click node_ai_learning "https://github.com/dkconnect/creator/blob/main/engine/ai/learning_ai.py"
click node_ai_advanced "https://github.com/dkconnect/creator/blob/main/engine/ai/advanced_ai.py"
click node_ai_base "https://github.com/dkconnect/creator/blob/main/engine/ai/base_ai.py"
click node_client "https://github.com/dkconnect/creator/blob/main/network/multiplayer_client.py"
click node_adapter "https://github.com/dkconnect/creator/blob/main/network/client_game_adapter.py"
click node_client_state "https://github.com/dkconnect/creator/blob/main/network/client_game_state.py"
click node_tcp_client "https://github.com/dkconnect/creator/blob/main/network/tcp_client.py"
click node_protocol "https://github.com/dkconnect/creator/blob/main/engine/protocol.py"
click node_server "https://github.com/dkconnect/creator/blob/main/network/tcp_server.py"
click node_router "https://github.com/dkconnect/creator/blob/main/network/connection_router.py"
click node_rooms "https://github.com/dkconnect/creator/blob/main/network/room_manager.py"
click node_session "https://github.com/dkconnect/creator/blob/main/network/game_session.py"
click node_handler "https://github.com/dkconnect/creator/blob/main/network/server_handler.py"

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_main_loop,node_menu,node_menu_state,node_input,node_renderer,node_viewport,node_native_board,node_native_hud,node_multi_hud,node_multi_result toneBlue
class node_game,node_movement,node_victory,node_pattern,node_capture,node_pawn,node_ai_basic,node_ai_learning,node_ai_advanced,node_ai_base,node_protocol toneAmber
class node_client,node_adapter,node_client_state,node_tcp_client toneMint
class node_server,node_router,node_rooms,node_session,node_handler toneRose
class node_player toneIndigo
```

## Components

### Application and UI

- [Game Loop](https://github.com/dkconnect/creator/blob/main/main.py): `main.py`
- [Menus and Lobby UI](https://github.com/dkconnect/creator/blob/main/ui/menu_renderer.py): `ui/menu_renderer.py`
- [Menu State](https://github.com/dkconnect/creator/blob/main/ui/menu_state.py): `ui/menu_state.py`
- [Input Mapping](https://github.com/dkconnect/creator/blob/main/ui/input_manager.py): `ui/input_manager.py`
- [Game Renderer](https://github.com/dkconnect/creator/blob/main/ui/renderer.py): `ui/renderer.py`
- [Viewport](https://github.com/dkconnect/creator/blob/main/ui/viewport.py): `ui/viewport.py`
- [Native Board](https://github.com/dkconnect/creator/blob/main/ui/native_board.py): `ui/native_board.py`
- [Native HUD](https://github.com/dkconnect/creator/blob/main/ui/native_hud.py): `ui/native_hud.py`
- [Multiplayer HUD](https://github.com/dkconnect/creator/blob/main/ui/multiplayer_hud.py): `ui/multiplayer_hud.py`
- [Multiplayer Results](https://github.com/dkconnect/creator/blob/main/ui/multiplayer_result.py): `ui/multiplayer_result.py`

### Game Rules and AI

- [Game State and Turns](https://github.com/dkconnect/creator/blob/main/engine/game.py): `engine/game.py`
- [Legal Movement](https://github.com/dkconnect/creator/blob/main/engine/movement.py): `engine/movement.py`
- [Pattern Victory](https://github.com/dkconnect/creator/blob/main/engine/victory.py): `engine/victory.py`
- [Pattern Definition](https://github.com/dkconnect/creator/blob/main/engine/pattern.py): `engine/pattern.py`
- [Capture and Reserves](https://github.com/dkconnect/creator/blob/main/engine/capture.py): `engine/capture.py`
- [Pawn Model](https://github.com/dkconnect/creator/blob/main/engine/pawn.py): `engine/pawn.py`
- [Basic AI](https://github.com/dkconnect/creator/blob/main/engine/ai/basic_ai.py): `engine/ai/basic_ai.py`
- [Learning AI](https://github.com/dkconnect/creator/blob/main/engine/ai/learning_ai.py): `engine/ai/learning_ai.py`
- [Advanced AI](https://github.com/dkconnect/creator/blob/main/engine/ai/advanced_ai.py): `engine/ai/advanced_ai.py`
- [AI Interface](https://github.com/dkconnect/creator/blob/main/engine/ai/base_ai.py): `engine/ai/base_ai.py`
- [Message Protocol](https://github.com/dkconnect/creator/blob/main/engine/protocol.py): `engine/protocol.py`

### Multiplayer Client

- [Multiplayer Client](https://github.com/dkconnect/creator/blob/main/network/multiplayer_client.py): `network/multiplayer_client.py`
- [Client Game Adapter](https://github.com/dkconnect/creator/blob/main/network/client_game_adapter.py): `network/client_game_adapter.py`
- [Client Game State](https://github.com/dkconnect/creator/blob/main/network/client_game_state.py): `network/client_game_state.py`
- [TCP Client](https://github.com/dkconnect/creator/blob/main/network/tcp_client.py): `network/tcp_client.py`

### Multiplayer Server

- [TCP Server](https://github.com/dkconnect/creator/blob/main/network/tcp_server.py): `network/tcp_server.py`
- [Connection Router](https://github.com/dkconnect/creator/blob/main/network/connection_router.py): `network/connection_router.py`
- [Room Manager](https://github.com/dkconnect/creator/blob/main/network/room_manager.py): `network/room_manager.py`
- [Game Session](https://github.com/dkconnect/creator/blob/main/network/game_session.py): `network/game_session.py`
- [Server Handler](https://github.com/dkconnect/creator/blob/main/network/server_handler.py): `network/server_handler.py`

### Other components

- **Player**

## Connections

- Player → Game Loop: plays through (evidence: `main.py`)
- Game Loop → Menus and Lobby UI: draws menus (evidence: `main.py`)
- Game Loop → Menu State: updates state (evidence: `main.py`)
- Game Loop → Input Mapping: reads clicks (evidence: `main.py`)
- Game Loop → Game State and Turns: runs turns (evidence: `main.py`)
- Game Loop → Game Renderer: draws game (evidence: `main.py`)
- Game Loop → Viewport: translates events (evidence: `main.py`)
- Game Loop → Native Board: uses board view (evidence: `main.py`)
- Game Loop → Native HUD: uses HUD (evidence: `main.py`)
- Game Loop → Multiplayer HUD: shows multiplayer (evidence: `main.py`)
- Game Loop → Multiplayer Results: shows results (evidence: `main.py`)
- Game Loop → Multiplayer Client: sends requests (evidence: `main.py`)
- Menus and Lobby UI → Menu State: renders state (evidence: `ui/menu_renderer.py`)
- Menus and Lobby UI → Viewport: uses coordinates (evidence: `ui/menu_renderer.py`)
- Game Renderer → Viewport: uses coordinates (evidence: `ui/renderer.py`)
- Game State and Turns → Legal Movement: checks moves (evidence: `engine/game.py`)
- Game State and Turns → Pattern Victory: checks victory (evidence: `engine/game.py`)
- Game State and Turns → Capture and Reserves: resolves captures (evidence: `engine/game.py`)
- Game State and Turns → Pattern Definition: loads pattern (evidence: `engine/game.py`)
- Game State and Turns → Pawn Model: creates pawns (evidence: `engine/game.py`)
- Game State and Turns → Learning AI: records learning (evidence: `engine/game.py`)
- Basic AI → AI Interface: implements interface (evidence: `engine/ai/basic_ai.py`)
- Learning AI → AI Interface: implements interface (evidence: `engine/ai/learning_ai.py`)
- Advanced AI → AI Interface: implements interface (evidence: `engine/ai/advanced_ai.py`)
- Basic AI → Legal Movement: queries legal moves (evidence: `engine/ai/basic_ai.py`)
- Learning AI → Legal Movement: queries legal moves (evidence: `engine/ai/learning_ai.py`)
- Advanced AI → Legal Movement: queries legal moves (evidence: `engine/ai/advanced_ai.py`)
- Advanced AI → Pattern Victory: evaluates victory (evidence: `engine/ai/advanced_ai.py`)
- Multiplayer Client → Message Protocol: builds messages (evidence: `network/multiplayer_client.py`)
- Multiplayer Client → TCP Client: sends requests (evidence: `network/multiplayer_client.py`)
- Multiplayer Client → Client Game State: updates state (evidence: `network/multiplayer_client.py`)
- Game Loop → Client Game Adapter: adapts game state (evidence: `main.py`)
- Client Game Adapter → Legal Movement: uses movement rules (evidence: `network/client_game_adapter.py`)
- TCP Server → Connection Router: routes connections
- Connection Router → Message Protocol: uses message types (evidence: `network/connection_router.py`)
- Connection Router → Room Manager: dispatches room actions (evidence: `network/connection_router.py`)
- Room Manager → Game Session: creates and dispatches (evidence: `network/room_manager.py`)
- Game Session → Game State and Turns: runs game state (evidence: `network/game_session.py`)
- Game Session → Server Handler: uses handlers (evidence: `network/game_session.py`)
- Game Session → Message Protocol: formats messages (evidence: `network/game_session.py`)
- Server Handler → Message Protocol: uses message types (evidence: `network/server_handler.py`)
