# mikygt21/tictactoe architecture

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

- Interactive diagram: https://gitdiagram.com/mikygt21/tictactoe
- Repository: https://github.com/mikygt21/tictactoe

## Overview

TicTacToe is an SFML desktop game where a player chooses an AI difficulty, clicks cells to play as X, and sees the match result and replay/menu options. The runtime flows through Application and its active scene; the game scene delegates match logic to Match and maps clicks into moves, while the presentation layer draws the board and controls. The README documents Easy, Medium and Hard AI behavior. Source excerpts show the application loop and input mapping; some scene and match interactions are supported by the README and source index rather than inspected implementation details.

Main entry points: [`src/app/GameScene.cpp`](https://github.com/mikygt21/tictactoe/blob/master/src/app/GameScene.cpp) (Match scene), [`src/app/Application.cpp`](https://github.com/mikygt21/tictactoe/blob/master/src/app/Application.cpp) (Application loop), [`src/presentation/BoardView.cpp`](https://github.com/mikygt21/tictactoe/blob/master/src/presentation/BoardView.cpp) (Board rendering), [`src/presentation/Button.cpp`](https://github.com/mikygt21/tictactoe/blob/master/src/presentation/Button.cpp) (UI buttons)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and scenes"]
  node_main["Program entry<br/>[main.cpp]"]
  node_application["Application loop<br/>[Application.cpp]"]
  node_scene_contract["Scene contract<br/>[IScene.h]"]
  node_menu["Difficulty menu<br/>[MenuScene.cpp]"]
  node_game_scene["Match scene<br/>[GameScene.cpp]"]
end

subgraph group_core["Game domain"]
  node_board[("Board state<br/>[Board.cpp]")]
  node_rules["Win rules<br/>[Rules.cpp]"]
  node_game["Turn logic<br/>[Game.cpp]"]
  node_match["Match coordinator<br/>[Match.cpp]"]
  node_move["Move value<br/>[Move.h]"]
  node_player_interface["Player interface<br/>[IPlayer.h]"]
end

subgraph group_players["Player strategies"]
  node_human_player["Human strategy<br/>[HumanPlayer.h]"]
  node_ai_player["AI strategy<br/>[AIPlayer.cpp]"]
end

subgraph group_ui["Presentation"]
  node_input_mapper["Click mapping<br/>[InputMapper.h]"]
  node_board_view["Board rendering<br/>[BoardView.cpp]"]
  node_button["UI buttons<br/>[Button.cpp]"]
  node_layout["Board layout<br/>[BoardLayout.h]"]
  node_text["Text placement<br/>[TextUtil.h]"]
  node_ui_config["UI configuration<br/>[UiConfig.h]"]
end

node_player(("Human player"))
node_sfml_window["SFML window"]

node_player -.->|"starts game"| node_application
node_main -->|"runs"| node_application
node_application -->|"polls events"| node_sfml_window
node_application -->|"starts with"| node_menu
node_application -.->|"dispatches scene"| node_scene_contract
node_menu -->|"selects difficulty"| node_game_scene
node_menu -.->|"uses controls"| node_button
node_game_scene -.->|"coordinates match"| node_match
node_game_scene -.->|"maps clicks"| node_input_mapper
node_input_mapper -->|"produces move"| node_move
node_game_scene -.->|"draws board"| node_board_view
node_game_scene -.->|"uses controls"| node_button
node_game_scene -.->|"formats status"| node_text
node_match -.->|"coordinates turns"| node_game
node_match -.->|"polls players"| node_player_interface
node_game -->|"updates state"| node_board
node_game -->|"checks outcome"| node_rules
node_ai_player -->|"evaluates moves"| node_rules
node_human_player -->|"implements"| node_player_interface
node_ai_player -->|"implements"| node_player_interface
node_board_view -->|"reads state"| node_board
node_board_view -->|"uses geometry"| node_layout
node_input_mapper -->|"uses geometry"| node_layout
node_board_view -->|"uses styling"| node_ui_config
node_button -->|"uses styling"| node_ui_config
node_button -->|"centers labels"| node_text
node_application -->|"sets window"| node_ui_config

click node_main "https://github.com/mikygt21/tictactoe/blob/master/src/main.cpp"
click node_application "https://github.com/mikygt21/tictactoe/blob/master/src/app/Application.cpp"
click node_scene_contract "https://github.com/mikygt21/tictactoe/blob/master/src/app/IScene.h"
click node_menu "https://github.com/mikygt21/tictactoe/blob/master/src/app/MenuScene.cpp"
click node_game_scene "https://github.com/mikygt21/tictactoe/blob/master/src/app/GameScene.cpp"
click node_board "https://github.com/mikygt21/tictactoe/blob/master/src/core/Board.cpp"
click node_rules "https://github.com/mikygt21/tictactoe/blob/master/src/core/Rules.cpp"
click node_game "https://github.com/mikygt21/tictactoe/blob/master/src/core/Game.cpp"
click node_match "https://github.com/mikygt21/tictactoe/blob/master/src/core/Match.cpp"
click node_move "https://github.com/mikygt21/tictactoe/blob/master/src/core/Move.h"
click node_player_interface "https://github.com/mikygt21/tictactoe/blob/master/src/core/IPlayer.h"
click node_human_player "https://github.com/mikygt21/tictactoe/blob/master/src/players/HumanPlayer.h"
click node_ai_player "https://github.com/mikygt21/tictactoe/blob/master/src/players/AIPlayer.cpp"
click node_input_mapper "https://github.com/mikygt21/tictactoe/blob/master/src/presentation/InputMapper.h"
click node_board_view "https://github.com/mikygt21/tictactoe/blob/master/src/presentation/BoardView.cpp"
click node_button "https://github.com/mikygt21/tictactoe/blob/master/src/presentation/Button.cpp"
click node_layout "https://github.com/mikygt21/tictactoe/blob/master/src/presentation/BoardLayout.h"
click node_text "https://github.com/mikygt21/tictactoe/blob/master/src/presentation/TextUtil.h"
click node_ui_config "https://github.com/mikygt21/tictactoe/blob/master/src/presentation/UiConfig.h"

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,node_application,node_scene_contract,node_menu,node_game_scene toneBlue
class node_board,node_rules,node_game,node_match,node_move,node_player_interface toneAmber
class node_human_player,node_ai_player toneMint
class node_input_mapper,node_board_view,node_button,node_layout,node_text,node_ui_config toneRose
class node_player,node_sfml_window toneIndigo
```

## Components

### Application and scenes

- [Program entry](https://github.com/mikygt21/tictactoe/blob/master/src/main.cpp): `src/main.cpp`
- [Application loop](https://github.com/mikygt21/tictactoe/blob/master/src/app/Application.cpp): `src/app/Application.cpp`
- [Scene contract](https://github.com/mikygt21/tictactoe/blob/master/src/app/IScene.h): `src/app/IScene.h`
- [Difficulty menu](https://github.com/mikygt21/tictactoe/blob/master/src/app/MenuScene.cpp): `src/app/MenuScene.cpp`
- [Match scene](https://github.com/mikygt21/tictactoe/blob/master/src/app/GameScene.cpp): `src/app/GameScene.cpp`

### Game domain

- [Board state](https://github.com/mikygt21/tictactoe/blob/master/src/core/Board.cpp): `src/core/Board.cpp`
- [Win rules](https://github.com/mikygt21/tictactoe/blob/master/src/core/Rules.cpp): `src/core/Rules.cpp`
- [Turn logic](https://github.com/mikygt21/tictactoe/blob/master/src/core/Game.cpp): `src/core/Game.cpp`
- [Match coordinator](https://github.com/mikygt21/tictactoe/blob/master/src/core/Match.cpp): `src/core/Match.cpp`
- [Move value](https://github.com/mikygt21/tictactoe/blob/master/src/core/Move.h): `src/core/Move.h`
- [Player interface](https://github.com/mikygt21/tictactoe/blob/master/src/core/IPlayer.h): `src/core/IPlayer.h`

### Player strategies

- [Human strategy](https://github.com/mikygt21/tictactoe/blob/master/src/players/HumanPlayer.h): `src/players/HumanPlayer.h`
- [AI strategy](https://github.com/mikygt21/tictactoe/blob/master/src/players/AIPlayer.cpp): `src/players/AIPlayer.cpp`

### Presentation

- [Click mapping](https://github.com/mikygt21/tictactoe/blob/master/src/presentation/InputMapper.h): `src/presentation/InputMapper.h`
- [Board rendering](https://github.com/mikygt21/tictactoe/blob/master/src/presentation/BoardView.cpp): `src/presentation/BoardView.cpp`
- [UI buttons](https://github.com/mikygt21/tictactoe/blob/master/src/presentation/Button.cpp): `src/presentation/Button.cpp`
- [Board layout](https://github.com/mikygt21/tictactoe/blob/master/src/presentation/BoardLayout.h): `src/presentation/BoardLayout.h`
- [Text placement](https://github.com/mikygt21/tictactoe/blob/master/src/presentation/TextUtil.h): `src/presentation/TextUtil.h`
- [UI configuration](https://github.com/mikygt21/tictactoe/blob/master/src/presentation/UiConfig.h): `src/presentation/UiConfig.h`

### Other components

- **Human player**
- **SFML window**

## Connections

- Human player → Application loop: starts game
- Program entry → Application loop: runs (evidence: `src/main.cpp`)
- Application loop → SFML window: polls events (evidence: `src/app/Application.cpp`)
- Application loop → Difficulty menu: starts with (evidence: `src/app/Application.cpp`)
- Application loop → Scene contract: dispatches scene
- Difficulty menu → Match scene: selects difficulty
- Difficulty menu → UI buttons: uses controls
- Match scene → Match coordinator: coordinates match
- Match scene → Click mapping: maps clicks
- Click mapping → Move value: produces move (evidence: `src/presentation/InputMapper.h`)
- Match scene → Board rendering: draws board
- Match scene → UI buttons: uses controls
- Match scene → Text placement: formats status (evidence: `src/app/GameScene.cpp`)
- Match coordinator → Turn logic: coordinates turns
- Match coordinator → Player interface: polls players
- Turn logic → Board state: updates state (evidence: `src/core/Game.cpp`)
- Turn logic → Win rules: checks outcome (evidence: `src/core/Game.cpp`)
- AI strategy → Win rules: evaluates moves (evidence: `src/players/AIPlayer.cpp`)
- Human strategy → Player interface: implements (evidence: `src/players/HumanPlayer.h`)
- AI strategy → Player interface: implements
- Board rendering → Board state: reads state
- Board rendering → Board layout: uses geometry
- Click mapping → Board layout: uses geometry (evidence: `src/presentation/InputMapper.h`)
- Board rendering → UI configuration: uses styling (evidence: `src/presentation/BoardView.cpp`)
- UI buttons → UI configuration: uses styling (evidence: `src/presentation/Button.cpp`)
- UI buttons → Text placement: centers labels (evidence: `src/presentation/Button.cpp`)
- Application loop → UI configuration: sets window (evidence: `src/app/Application.cpp`)
