# kensunjaya/chroma-war architecture

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

- Interactive diagram: https://gitdiagram.com/kensunjaya/chroma-war
- Repository: https://github.com/kensunjaya/chroma-war

## Overview

Chroma War is a browser-based chain-reaction strategy game. Players enter through a game-mode page, make moves on a grid, and see chain reactions, turn state, and win conditions; opponents may be another local player, a remote player, or AI. Shared game utilities provide move evaluation and winner checks, while separate routes provide AI-vs-AI and Monte Carlo simulation. The README documents real-time WebSocket multiplayer and Minimax with α-β pruning. Several route excerpts are partial, so unsampled internal call details are not inferred.

Main entry points: [`src/app/singleplayer/page.tsx`](https://github.com/kensunjaya/chroma-war/blob/master/src/app/singleplayer/page.tsx) (Versus AI), [`src/app/multiplayer/page.tsx`](https://github.com/kensunjaya/chroma-war/blob/master/src/app/multiplayer/page.tsx) (Online match), [`src/utils/FunctionUtils.tsx`](https://github.com/kensunjaya/chroma-war/blob/master/src/utils/FunctionUtils.tsx) (Game rules), [`src/components/Navigation.tsx`](https://github.com/kensunjaya/chroma-war/blob/master/src/components/Navigation.tsx) (Mode navigation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_modes["Game modes"]
  node_single["Versus AI<br/>[page.tsx]"]
  node_local["Local players<br/>[page.tsx]"]
  node_llm["Gemini match<br/>[page.tsx]"]
  node_battle["AI battle<br/>[page.tsx]"]
  node_simulation["Monte Carlo<br/>[page.tsx]"]
end

subgraph group_shared["Shared game logic"]
  node_gemini["Gemini opponent<br/>[GeminiBot.tsx]"]
  node_rules["Game rules<br/>[FunctionUtils.tsx]"]
  node_types["Game types<br/>[Types.tsx]"]
end

subgraph group_presentation["Game interface"]
  node_navigation["Mode navigation<br/>[Navigation.tsx]"]
  node_modal["Game dialogs<br/>[Modal.tsx]"]
  node_difficulty["Difficulty settings"]
  node_rulemodal["Rules dialog<br/>[RuleModal.tsx]"]
  node_dots["Cell markers<br/>[Dots.tsx]"]
  node_colorbar["Score display<br/>[ColorBar.tsx]"]
  node_animation["Burst effects<br/>[Animation.tsx]"]
end

subgraph group_online["Online play"]
  node_multi["Online match<br/>[page.tsx]"]
  node_lobby["Room lobby"]
  node_socket["WebSocket client<br/>[socket.ts]"]
end

node_player(("Player"))

node_player -->|"starts match"| node_single
node_player -->|"plays locally"| node_local
node_player -->|"joins match"| node_multi
node_player -->|"plays AI"| node_llm
node_navigation -->|"links to"| node_single
node_navigation -->|"links to"| node_local
node_navigation -->|"links to"| node_multi
node_single -->|"checks moves"| node_rules
node_local -->|"uses game logic"| node_rules
node_multi -->|"uses game logic"| node_rules
node_llm -->|"requests moves"| node_gemini
node_llm -->|"checks winner"| node_rules
node_battle -->|"chooses moves"| node_rules
node_simulation -->|"evaluates moves"| node_rules
node_multi -->|"uses lobby"| node_lobby
node_multi -->|"uses socket"| node_socket
node_single -->|"renders dialogs"| node_modal
node_single -->|"sets difficulty"| node_difficulty
node_single -->|"shows rules"| node_rulemodal
node_multi -->|"renders dialogs"| node_modal
node_single -->|"renders cells"| node_dots
node_single -->|"shows counts"| node_colorbar
node_multi -->|"shows counts"| node_colorbar
node_single -->|"renders bursts"| node_animation
node_single -->|"uses types"| node_types
node_rules -->|"uses types"| node_types

click node_single "https://github.com/kensunjaya/chroma-war/blob/master/src/app/singleplayer/page.tsx"
click node_local "https://github.com/kensunjaya/chroma-war/blob/master/src/app/twoplayers/page.tsx"
click node_multi "https://github.com/kensunjaya/chroma-war/blob/master/src/app/multiplayer/page.tsx"
click node_lobby "https://github.com/kensunjaya/chroma-war/blob/master/src/components/MultiplayerLobby.tsx"
click node_socket "https://github.com/kensunjaya/chroma-war/blob/master/src/utils/socket.ts"
click node_llm "https://github.com/kensunjaya/chroma-war/blob/master/src/app/vsllm/page.tsx"
click node_gemini "https://github.com/kensunjaya/chroma-war/blob/master/src/utils/GeminiBot.tsx"
click node_battle "https://github.com/kensunjaya/chroma-war/blob/master/src/app/aivsai/page.tsx"
click node_simulation "https://github.com/kensunjaya/chroma-war/blob/master/src/app/montecarlo/page.tsx"
click node_rules "https://github.com/kensunjaya/chroma-war/blob/master/src/utils/FunctionUtils.tsx"
click node_types "https://github.com/kensunjaya/chroma-war/blob/master/src/interfaces/Types.tsx"
click node_navigation "https://github.com/kensunjaya/chroma-war/blob/master/src/components/Navigation.tsx"
click node_modal "https://github.com/kensunjaya/chroma-war/blob/master/src/components/Modal.tsx"
click node_difficulty "https://github.com/kensunjaya/chroma-war/blob/master/src/components/DifficultyModal.tsx"
click node_rulemodal "https://github.com/kensunjaya/chroma-war/blob/master/src/components/RuleModal.tsx"
click node_dots "https://github.com/kensunjaya/chroma-war/blob/master/src/components/Dots.tsx"
click node_colorbar "https://github.com/kensunjaya/chroma-war/blob/master/src/components/ColorBar.tsx"
click node_animation "https://github.com/kensunjaya/chroma-war/blob/master/src/utils/Animation.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_single,node_local,node_llm,node_battle,node_simulation toneBlue
class node_gemini,node_rules,node_types toneAmber
class node_navigation,node_modal,node_difficulty,node_rulemodal,node_dots,node_colorbar,node_animation toneMint
class node_multi,node_lobby,node_socket toneRose
class node_player toneIndigo
```

## Components

### Game modes

- [Versus AI](https://github.com/kensunjaya/chroma-war/blob/master/src/app/singleplayer/page.tsx): `src/app/singleplayer/page.tsx`
- [Local players](https://github.com/kensunjaya/chroma-war/blob/master/src/app/twoplayers/page.tsx): `src/app/twoplayers/page.tsx`
- [Gemini match](https://github.com/kensunjaya/chroma-war/blob/master/src/app/vsllm/page.tsx): `src/app/vsllm/page.tsx`
- [AI battle](https://github.com/kensunjaya/chroma-war/blob/master/src/app/aivsai/page.tsx): `src/app/aivsai/page.tsx`
- [Monte Carlo](https://github.com/kensunjaya/chroma-war/blob/master/src/app/montecarlo/page.tsx): `src/app/montecarlo/page.tsx`

### Shared game logic

- [Gemini opponent](https://github.com/kensunjaya/chroma-war/blob/master/src/utils/GeminiBot.tsx): `src/utils/GeminiBot.tsx`
- [Game rules](https://github.com/kensunjaya/chroma-war/blob/master/src/utils/FunctionUtils.tsx): `src/utils/FunctionUtils.tsx`
- [Game types](https://github.com/kensunjaya/chroma-war/blob/master/src/interfaces/Types.tsx): `src/interfaces/Types.tsx`

### Game interface

- [Mode navigation](https://github.com/kensunjaya/chroma-war/blob/master/src/components/Navigation.tsx): `src/components/Navigation.tsx`
- [Game dialogs](https://github.com/kensunjaya/chroma-war/blob/master/src/components/Modal.tsx): `src/components/Modal.tsx`
- [Difficulty settings](https://github.com/kensunjaya/chroma-war/blob/master/src/components/DifficultyModal.tsx): `src/components/DifficultyModal.tsx`
- [Rules dialog](https://github.com/kensunjaya/chroma-war/blob/master/src/components/RuleModal.tsx): `src/components/RuleModal.tsx`
- [Cell markers](https://github.com/kensunjaya/chroma-war/blob/master/src/components/Dots.tsx): `src/components/Dots.tsx`
- [Score display](https://github.com/kensunjaya/chroma-war/blob/master/src/components/ColorBar.tsx): `src/components/ColorBar.tsx`
- [Burst effects](https://github.com/kensunjaya/chroma-war/blob/master/src/utils/Animation.tsx): `src/utils/Animation.tsx`

### Online play

- [Online match](https://github.com/kensunjaya/chroma-war/blob/master/src/app/multiplayer/page.tsx): `src/app/multiplayer/page.tsx`
- [Room lobby](https://github.com/kensunjaya/chroma-war/blob/master/src/components/MultiplayerLobby.tsx): `src/components/MultiplayerLobby.tsx`
- [WebSocket client](https://github.com/kensunjaya/chroma-war/blob/master/src/utils/socket.ts): `src/utils/socket.ts`

### Other components

- **Player**

## Connections

- Player → Versus AI: starts match (evidence: `README.md`)
- Player → Local players: plays locally (evidence: `README.md`)
- Player → Online match: joins match (evidence: `README.md`)
- Player → Gemini match: plays AI (evidence: `src/app/vsllm/page.tsx`)
- Mode navigation → Versus AI: links to (evidence: `src/components/Navigation.tsx`)
- Mode navigation → Local players: links to (evidence: `src/components/Navigation.tsx`)
- Mode navigation → Online match: links to (evidence: `src/components/Navigation.tsx`)
- Versus AI → Game rules: checks moves (evidence: `src/app/singleplayer/page.tsx`)
- Local players → Game rules: uses game logic (evidence: `src/app/twoplayers/page.tsx`)
- Online match → Game rules: uses game logic (evidence: `src/app/multiplayer/page.tsx`)
- Gemini match → Gemini opponent: requests moves (evidence: `src/app/vsllm/page.tsx`)
- Gemini match → Game rules: checks winner (evidence: `src/app/vsllm/page.tsx`)
- AI battle → Game rules: chooses moves (evidence: `src/app/aivsai/page.tsx`)
- Monte Carlo → Game rules: evaluates moves (evidence: `src/app/montecarlo/page.tsx`)
- Online match → Room lobby: uses lobby (evidence: `src/app/multiplayer/page.tsx`)
- Online match → WebSocket client: uses socket (evidence: `src/app/multiplayer/page.tsx`)
- Versus AI → Game dialogs: renders dialogs (evidence: `src/app/singleplayer/page.tsx`)
- Versus AI → Difficulty settings: sets difficulty (evidence: `src/app/singleplayer/page.tsx`)
- Versus AI → Rules dialog: shows rules (evidence: `src/app/singleplayer/page.tsx`)
- Online match → Game dialogs: renders dialogs (evidence: `src/app/multiplayer/page.tsx`)
- Versus AI → Cell markers: renders cells (evidence: `src/app/singleplayer/page.tsx`)
- Versus AI → Score display: shows counts (evidence: `src/app/singleplayer/page.tsx`)
- Online match → Score display: shows counts (evidence: `src/app/multiplayer/page.tsx`)
- Versus AI → Burst effects: renders bursts (evidence: `src/app/singleplayer/page.tsx`)
- Versus AI → Game types: uses types (evidence: `src/app/singleplayer/page.tsx`)
- Game rules → Game types: uses types (evidence: `src/utils/FunctionUtils.tsx`)
