# sivatha/tic-tac-toe architecture

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

- Interactive diagram: https://gitdiagram.com/sivatha/tic-tac-toe
- Repository: https://github.com/sivatha/tic-tac-toe

## Overview

This is a browser-based Tic-Tac-Toe game with classic and larger boards, computer and local play, simulated quick matches, and cross-tab private rooms. The user selects a mode and board, plays moves, and sees win/draw and score results. App.tsx owns game state and invokes game rules, AI, and room messaging; React components present controls and game status. The README documents audio, undo, persistent stats, and other UI capabilities. Some component wiring is supported by the SOURCE INDEX; unsampled implementation details are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/sivatha/tic-tac-toe/blob/main/src/App.tsx) (Game Controller), [`src/utils/audio.ts`](https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/audio.ts) (Sound Effects), [`src/components/GameBoard.tsx`](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/GameBoard.tsx) (Board Renderer), [`src/utils/multiplayer.ts`](https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/multiplayer.ts) (Room Messaging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Game Play"]
  node_app["Game Controller<br/>[App.tsx]"]
  node_rules["Win Detection<br/>[gameLogic.ts]"]
  node_ai["Computer Opponent<br/>[ai.ts]"]
  node_types["Game Types<br/>[game.ts]"]
end

subgraph group_ui["Game Interface"]
  node_navbar["Game Header<br/>[Navbar.tsx]"]
  node_mode["Mode Selector<br/>[ModeSelector.tsx]"]
  node_board["Board Renderer<br/>[GameBoard.tsx]"]
  node_cell["Animated Cell<br/>[GameCell.tsx]"]
  node_score["Scoreboard<br/>[ScoreBoard.tsx]"]
  node_gameover["Game Over Dialog<br/>[GameOverModal.tsx]"]
  node_multimodal["Multiplayer Dialog"]
  node_rulesmodal["Rules Dialog<br/>[RulesModal.tsx]"]
  node_about["Developer Page"]
  node_icon["Icon Renderer<br/>[Icon.tsx]"]
end

subgraph group_online["Online Play"]
  node_multiplayer["Room Messaging<br/>[multiplayer.ts]"]
  node_browserchannel["BroadcastChannel"]
end

subgraph group_support["Game Services"]
  node_audio["Sound Effects<br/>[audio.ts]"]
  node_storage[("Browser Storage")]
  node_entry["React Entry<br/>[main.tsx]"]
end

node_player(("Player"))

node_player -->|"opens game"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"renders"| node_navbar
node_app -->|"renders"| node_mode
node_app -->|"renders"| node_board
node_app -->|"renders"| node_score
node_app -->|"renders"| node_gameover
node_app -->|"renders"| node_multimodal
node_app -->|"renders"| node_rulesmodal
node_app -->|"renders"| node_about
node_board -->|"renders"| node_cell
node_app -->|"checks moves"| node_rules
node_app -->|"requests move"| node_ai
node_ai -->|"evaluates positions"| node_rules
node_app -->|"sends room messages"| node_multiplayer
node_multimodal -->|"generates opponent"| node_multiplayer
node_multiplayer -->|"posts messages"| node_browserchannel
node_app -->|"persists stats"| node_storage
node_audio -->|"loads preference"| node_storage
node_navbar -->|"toggles sound"| node_audio
node_board -->|"plays effects"| node_audio
node_gameover -->|"plays effects"| node_audio
node_mode -->|"plays clicks"| node_audio
node_about -->|"uses sound"| node_audio
node_navbar -->|"renders icons"| node_icon
node_mode -->|"renders icons"| node_icon
node_board -->|"renders icons"| node_icon
node_cell -->|"uses game types"| node_types
node_rules -->|"uses game types"| node_types
node_multiplayer -->|"uses message types"| node_types

click node_app "https://github.com/sivatha/tic-tac-toe/blob/main/src/App.tsx"
click node_rules "https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/gameLogic.ts"
click node_ai "https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/ai.ts"
click node_types "https://github.com/sivatha/tic-tac-toe/blob/main/src/types/game.ts"
click node_navbar "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/Navbar.tsx"
click node_mode "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/ModeSelector.tsx"
click node_board "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/GameBoard.tsx"
click node_cell "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/GameCell.tsx"
click node_score "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/ScoreBoard.tsx"
click node_gameover "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/GameOverModal.tsx"
click node_multimodal "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/MultiplayerModal.tsx"
click node_rulesmodal "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/RulesModal.tsx"
click node_about "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/AboutDeveloperPage.tsx"
click node_icon "https://github.com/sivatha/tic-tac-toe/blob/main/src/components/Icon.tsx"
click node_multiplayer "https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/multiplayer.ts"
click node_audio "https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/audio.ts"
click node_entry "https://github.com/sivatha/tic-tac-toe/blob/main/src/main.tsx"

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_app,node_rules,node_ai,node_types toneBlue
class node_navbar,node_mode,node_board,node_cell,node_score,node_gameover,node_multimodal,node_rulesmodal,node_about,node_icon toneAmber
class node_multiplayer,node_browserchannel toneMint
class node_audio,node_storage,node_entry toneRose
class node_player toneIndigo
```

## Components

### Game Play

- [Game Controller](https://github.com/sivatha/tic-tac-toe/blob/main/src/App.tsx): `src/App.tsx`
- [Win Detection](https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/gameLogic.ts): `src/utils/gameLogic.ts`
- [Computer Opponent](https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/ai.ts): `src/utils/ai.ts`
- [Game Types](https://github.com/sivatha/tic-tac-toe/blob/main/src/types/game.ts): `src/types/game.ts`

### Game Interface

- [Game Header](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/Navbar.tsx): `src/components/Navbar.tsx`
- [Mode Selector](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/ModeSelector.tsx): `src/components/ModeSelector.tsx`
- [Board Renderer](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/GameBoard.tsx): `src/components/GameBoard.tsx`
- [Animated Cell](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/GameCell.tsx): `src/components/GameCell.tsx`
- [Scoreboard](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/ScoreBoard.tsx): `src/components/ScoreBoard.tsx`
- [Game Over Dialog](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/GameOverModal.tsx): `src/components/GameOverModal.tsx`
- [Multiplayer Dialog](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/MultiplayerModal.tsx): `src/components/MultiplayerModal.tsx`
- [Rules Dialog](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/RulesModal.tsx): `src/components/RulesModal.tsx`
- [Developer Page](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/AboutDeveloperPage.tsx): `src/components/AboutDeveloperPage.tsx`
- [Icon Renderer](https://github.com/sivatha/tic-tac-toe/blob/main/src/components/Icon.tsx): `src/components/Icon.tsx`

### Online Play

- [Room Messaging](https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/multiplayer.ts): `src/utils/multiplayer.ts`
- **BroadcastChannel**

### Game Services

- [Sound Effects](https://github.com/sivatha/tic-tac-toe/blob/main/src/utils/audio.ts): `src/utils/audio.ts`
- **Browser Storage**
- [React Entry](https://github.com/sivatha/tic-tac-toe/blob/main/src/main.tsx): `src/main.tsx`

### Other components

- **Player**

## Connections

- Player → React Entry: opens game (evidence: `README.md`)
- React Entry → Game Controller: renders (evidence: `src/main.tsx`)
- Game Controller → Game Header: renders (evidence: `src/App.tsx`)
- Game Controller → Mode Selector: renders (evidence: `src/App.tsx`)
- Game Controller → Board Renderer: renders (evidence: `src/App.tsx`)
- Game Controller → Scoreboard: renders (evidence: `src/App.tsx`)
- Game Controller → Game Over Dialog: renders (evidence: `src/App.tsx`)
- Game Controller → Multiplayer Dialog: renders (evidence: `src/App.tsx`)
- Game Controller → Rules Dialog: renders (evidence: `src/App.tsx`)
- Game Controller → Developer Page: renders (evidence: `src/App.tsx`)
- Board Renderer → Animated Cell: renders (evidence: `src/components/GameBoard.tsx`)
- Game Controller → Win Detection: checks moves (evidence: `src/App.tsx`)
- Game Controller → Computer Opponent: requests move (evidence: `src/App.tsx`)
- Computer Opponent → Win Detection: evaluates positions (evidence: `src/utils/ai.ts`)
- Game Controller → Room Messaging: sends room messages (evidence: `src/App.tsx`)
- Multiplayer Dialog → Room Messaging: generates opponent (evidence: `src/components/MultiplayerModal.tsx`)
- Room Messaging → BroadcastChannel: posts messages (evidence: `src/utils/multiplayer.ts`)
- Game Controller → Browser Storage: persists stats (evidence: `src/App.tsx`)
- Sound Effects → Browser Storage: loads preference (evidence: `src/utils/audio.ts`)
- Game Header → Sound Effects: toggles sound (evidence: `src/components/Navbar.tsx`)
- Board Renderer → Sound Effects: plays effects (evidence: `src/components/GameBoard.tsx`)
- Game Over Dialog → Sound Effects: plays effects (evidence: `src/components/GameOverModal.tsx`)
- Mode Selector → Sound Effects: plays clicks (evidence: `src/components/ModeSelector.tsx`)
- Developer Page → Sound Effects: uses sound (evidence: `src/components/AboutDeveloperPage.tsx`)
- Game Header → Icon Renderer: renders icons (evidence: `src/components/Navbar.tsx`)
- Mode Selector → Icon Renderer: renders icons (evidence: `src/components/ModeSelector.tsx`)
- Board Renderer → Icon Renderer: renders icons (evidence: `src/components/GameBoard.tsx`)
- Animated Cell → Game Types: uses game types (evidence: `src/components/GameCell.tsx`)
- Win Detection → Game Types: uses game types (evidence: `src/utils/gameLogic.ts`)
- Room Messaging → Game Types: uses message types (evidence: `src/utils/multiplayer.ts`)
