# mehereen-1/fusion-fields architecture

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

- Interactive diagram: https://gitdiagram.com/mehereen-1/fusion-fields
- Repository: https://github.com/mehereen-1/fusion-fields

## Overview

#### Purpose and Entrypoints
Color Wars is a desktop chain-reaction strategy game built as a React/TypeScript frontend packaged by Tauri. The browser UI mounts from `src/main.tsx` into the application root, with top-level screen/state orchestration in `src/App.tsx`. Native startup and Tauri integration are in `src-tauri/src/main.rs` and `src-tauri/src/lib.rs`.

#### Game UI and Navigation
The React application presents game, menu, start, results, AI/minimax, experiment, and trace views. `src/App.tsx` selects or coordinates screens; `src/GameBoard.tsx` renders the interactive board and `src/Cell.tsx` represents individual board positions. Supporting flows include `src/MenuScreen.tsx`, `src/StartScreen.tsx`, `src/ResultScreen.tsx`, and `src/MinimaxScreen.tsx`.

#### Core Game State and Rules
The game domain is defined in `src/types.ts` and updated through `src/gameLogic.ts`. Board interactions flow from cells/board UI into game-logic transitions, which determine legal placement, ownership, chain reactions, turn changes, and game outcome. This is the main boundary between React rendering and game-rule computation:
- `src/GameBoard.tsx`
- `src/Cell.tsx`
- `src/gameLogic.ts`
- `src/types.ts`

#### AI Decision Engines
The frontend contains two move-selection approaches. A minimax engine chooses search-based moves via `src/minimax/chooseMinimaxMove.ts`, exposed through `src/minimax/index.ts`; its UI is represented by `src/MinimaxScreen.tsx`. A fuzzy-logic engine derives board features, membership values, rules, and a move choice through:
- `src/fuzzy/features.ts`
- `src/fuzzy/membership.ts`
- `src/fuzzy/rules.ts`
- `src/fuzzy/chooseFuzzyMove.ts`

#### Experimentation and Decision Tracing
Experiment workflows are separated from ordinary gameplay in `src/ExperimentPanel.tsx` and `src/experiment.ts`. AI/game decision history is modeled or recorded in `src/decisionTrace.ts`, displayed through `src/TraceModal.tsx`, and exported by `src/traceExporter.ts`. This forms a diagnostic/reporting boundary around the decision engines rather than embedding analysis directly in board rendering.

#### Python Algorithm Reference/Alternate Implementation
A separate Python package implements board mechanics, explosions, evaluation, and minimax, likely for algorithm experimentation or comparison rather than the packaged React runtime. Its executable/module entry is `algorithms/main.py`; core stages reside in:
- `algorithms/board.py`
- `algorithms/explosion.py`
- `algorithms/evaluation.py`
- `algorithms/minimax.py`

Python dependencies are isolated in `algorithms/requirements.txt`.

#### Runtime and Packaging Boundaries
The frontend uses the Vite/React TypeScript runtime, configured by `vite.config.ts` and rooted at `index.html`. Tauri packages that web frontend into a native application using Rust manifests/configuration in `src-tauri/Cargo.toml` and `src-tauri/tauri.conf.json`. Tauri capability permissions are explicitly defined in `src-tauri/capabilities/default.json`. No backend service, database, or network integration is indicated by the repository structure.

Main entry points: [`src/App.tsx`](https://github.com/mehereen-1/fusion-fields/blob/main/src/App.tsx) (App coordinator), [`src/gameLogic.ts`](https://github.com/mehereen-1/fusion-fields/blob/main/src/gameLogic.ts) (Game rules), [`src/GameBoard.tsx`](https://github.com/mehereen-1/fusion-fields/blob/main/src/GameBoard.tsx) (Game board), [`src/ExperimentPanel.tsx`](https://github.com/mehereen-1/fusion-fields/blob/main/src/ExperimentPanel.tsx) (Experiment workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_react["React game client"]
  node_web_entry["Vite web entry<br/>HTML entry<br/>[index.html]"]
  node_react_mount["React mount<br/>TSX entry<br/>[main.tsx]"]
  node_app["App coordinator<br/>screen orchestration<br/>[App.tsx]"]
  node_game_board["Game board<br/>interactive board UI<br/>[GameBoard.tsx]"]
  node_cell["Board cell<br/>board position UI<br/>[Cell.tsx]"]
  node_screens["Game flow screens<br/>React screens<br/>[MenuScreen.tsx]"]
  node_domain_types["Game domain model<br/>TypeScript types<br/>[types.ts]"]
  node_game_logic["Game rules<br/>state transitions<br/>[gameLogic.ts]"]
end

subgraph group_ai["AI and analysis"]
  node_minimax["Minimax engine<br/>move search"]
  node_fuzzy_features["Fuzzy board features<br/>feature extraction<br/>[features.ts]"]
  node_fuzzy_membership["Fuzzy membership<br/>fuzzy inference<br/>[membership.ts]"]
  node_fuzzy_rules["Fuzzy rules<br/>fuzzy inference<br/>[rules.ts]"]
  node_fuzzy_move["Fuzzy move chooser<br/>move selection<br/>[chooseFuzzyMove.ts]"]
  node_experiments["Experiment workflow<br/>analysis UI and workflow"]
  node_trace["Decision tracing<br/>diagnostic history<br/>[decisionTrace.ts]"]
end

subgraph group_native["Native packaging"]
  node_tauri{{"Tauri host<br/>Rust native runtime<br/>[main.rs]"}}
end

subgraph group_python["Python reference"]
  node_python_entry["Python algorithm entry<br/>Python module entry<br/>[main.py]"]
  node_python_board["Python board mechanics<br/>board and explosions<br/>[board.py]"]
  node_python_eval["Python evaluation<br/>position evaluation<br/>[evaluation.py]"]
  node_python_minimax["Python minimax<br/>move search<br/>[minimax.py]"]
end

node_web_entry -->|"loads"| node_react_mount
node_react_mount -->|"mounts"| node_app
node_app -->|"renders gameplay"| node_game_board
node_app -->|"coordinates"| node_screens
node_app -->|"opens analysis"| node_experiments
node_app -->|"opens trace"| node_trace
node_game_board -->|"renders cells"| node_cell
node_cell -->|"submits move"| node_game_logic
node_game_board -->|"reads and updates state"| node_game_logic
node_game_logic -->|"uses model"| node_domain_types
node_screens -->|"requests move"| node_minimax
node_minimax -.->|"evaluates transitions"| node_game_logic
node_fuzzy_features -->|"feeds values"| node_fuzzy_membership
node_fuzzy_membership -->|"provides memberships"| node_fuzzy_rules
node_fuzzy_rules -->|"drives choice"| node_fuzzy_move
node_fuzzy_move -.->|"selects legal move"| node_game_logic
node_experiments -->|"runs experiments"| node_fuzzy_move
node_experiments -->|"records decisions"| node_trace
node_tauri -->|"packages frontend"| node_web_entry
node_python_entry -->|"runs mechanics"| node_python_board
node_python_entry -->|"runs search"| node_python_minimax
node_python_minimax -->|"scores positions"| node_python_eval
node_python_minimax -->|"simulates moves"| node_python_board

click node_web_entry "https://github.com/mehereen-1/fusion-fields/blob/main/index.html"
click node_react_mount "https://github.com/mehereen-1/fusion-fields/blob/main/src/main.tsx"
click node_app "https://github.com/mehereen-1/fusion-fields/blob/main/src/App.tsx"
click node_game_board "https://github.com/mehereen-1/fusion-fields/blob/main/src/GameBoard.tsx"
click node_cell "https://github.com/mehereen-1/fusion-fields/blob/main/src/Cell.tsx"
click node_screens "https://github.com/mehereen-1/fusion-fields/blob/main/src/MenuScreen.tsx"
click node_domain_types "https://github.com/mehereen-1/fusion-fields/blob/main/src/types.ts"
click node_game_logic "https://github.com/mehereen-1/fusion-fields/blob/main/src/gameLogic.ts"
click node_minimax "https://github.com/mehereen-1/fusion-fields/blob/main/src/minimax/chooseMinimaxMove.ts"
click node_fuzzy_features "https://github.com/mehereen-1/fusion-fields/blob/main/src/fuzzy/features.ts"
click node_fuzzy_membership "https://github.com/mehereen-1/fusion-fields/blob/main/src/fuzzy/membership.ts"
click node_fuzzy_rules "https://github.com/mehereen-1/fusion-fields/blob/main/src/fuzzy/rules.ts"
click node_fuzzy_move "https://github.com/mehereen-1/fusion-fields/blob/main/src/fuzzy/chooseFuzzyMove.ts"
click node_experiments "https://github.com/mehereen-1/fusion-fields/blob/main/src/ExperimentPanel.tsx"
click node_trace "https://github.com/mehereen-1/fusion-fields/blob/main/src/decisionTrace.ts"
click node_tauri "https://github.com/mehereen-1/fusion-fields/blob/main/src-tauri/src/main.rs"
click node_python_entry "https://github.com/mehereen-1/fusion-fields/blob/main/algorithms/main.py"
click node_python_board "https://github.com/mehereen-1/fusion-fields/blob/main/algorithms/board.py"
click node_python_eval "https://github.com/mehereen-1/fusion-fields/blob/main/algorithms/evaluation.py"
click node_python_minimax "https://github.com/mehereen-1/fusion-fields/blob/main/algorithms/minimax.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_web_entry,node_react_mount,node_app,node_game_board,node_cell,node_screens,node_domain_types,node_game_logic toneBlue
class node_minimax,node_fuzzy_features,node_fuzzy_membership,node_fuzzy_rules,node_fuzzy_move,node_experiments,node_trace toneAmber
class node_tauri toneMint
class node_python_entry,node_python_board,node_python_eval,node_python_minimax toneRose
```

## Components

### React game client

- [Vite web entry](https://github.com/mehereen-1/fusion-fields/blob/main/index.html): HTML entry · `index.html`
- [React mount](https://github.com/mehereen-1/fusion-fields/blob/main/src/main.tsx): TSX entry · `src/main.tsx`
- [App coordinator](https://github.com/mehereen-1/fusion-fields/blob/main/src/App.tsx): screen orchestration · Selects and coordinates application views and state. · `src/App.tsx`
- [Game board](https://github.com/mehereen-1/fusion-fields/blob/main/src/GameBoard.tsx): interactive board UI · `src/GameBoard.tsx`
- [Board cell](https://github.com/mehereen-1/fusion-fields/blob/main/src/Cell.tsx): board position UI · `src/Cell.tsx`
- [Game flow screens](https://github.com/mehereen-1/fusion-fields/blob/main/src/MenuScreen.tsx): React screens · Menu, start, result, and minimax views. · `src/MenuScreen.tsx`
- [Game domain model](https://github.com/mehereen-1/fusion-fields/blob/main/src/types.ts): TypeScript types · `src/types.ts`
- [Game rules](https://github.com/mehereen-1/fusion-fields/blob/main/src/gameLogic.ts): state transitions · Applies placements, reactions, turns, and outcomes. · `src/gameLogic.ts`

### AI and analysis

- [Minimax engine](https://github.com/mehereen-1/fusion-fields/blob/main/src/minimax/chooseMinimaxMove.ts): move search · Publicly exposed through src/minimax/index.ts. · `src/minimax/chooseMinimaxMove.ts`
- [Fuzzy board features](https://github.com/mehereen-1/fusion-fields/blob/main/src/fuzzy/features.ts): feature extraction · `src/fuzzy/features.ts`
- [Fuzzy membership](https://github.com/mehereen-1/fusion-fields/blob/main/src/fuzzy/membership.ts): fuzzy inference · `src/fuzzy/membership.ts`
- [Fuzzy rules](https://github.com/mehereen-1/fusion-fields/blob/main/src/fuzzy/rules.ts): fuzzy inference · `src/fuzzy/rules.ts`
- [Fuzzy move chooser](https://github.com/mehereen-1/fusion-fields/blob/main/src/fuzzy/chooseFuzzyMove.ts): move selection · `src/fuzzy/chooseFuzzyMove.ts`
- [Experiment workflow](https://github.com/mehereen-1/fusion-fields/blob/main/src/ExperimentPanel.tsx): analysis UI and workflow · `src/ExperimentPanel.tsx`
- [Decision tracing](https://github.com/mehereen-1/fusion-fields/blob/main/src/decisionTrace.ts): diagnostic history · Displayed by TraceModal and exported by traceExporter. · `src/decisionTrace.ts`

### Native packaging

- [Tauri host](https://github.com/mehereen-1/fusion-fields/blob/main/src-tauri/src/main.rs): Rust native runtime · Starts and integrates the packaged application. · `src-tauri/src/main.rs`

### Python reference

Separate algorithm implementation for experimentation or comparison.

- [Python algorithm entry](https://github.com/mehereen-1/fusion-fields/blob/main/algorithms/main.py): Python module entry · `algorithms/main.py`
- [Python board mechanics](https://github.com/mehereen-1/fusion-fields/blob/main/algorithms/board.py): board and explosions · `algorithms/board.py`
- [Python evaluation](https://github.com/mehereen-1/fusion-fields/blob/main/algorithms/evaluation.py): position evaluation · `algorithms/evaluation.py`
- [Python minimax](https://github.com/mehereen-1/fusion-fields/blob/main/algorithms/minimax.py): move search · `algorithms/minimax.py`

## Connections

- Vite web entry → React mount: loads
- React mount → App coordinator: mounts
- App coordinator → Game board: renders gameplay
- App coordinator → Game flow screens: coordinates
- App coordinator → Experiment workflow: opens analysis
- App coordinator → Decision tracing: opens trace
- Game board → Board cell: renders cells
- Board cell → Game rules: submits move
- Game board → Game rules: reads and updates state
- Game rules → Game domain model: uses model
- Game flow screens → Minimax engine: requests move
- Minimax engine → Game rules: evaluates transitions
- Fuzzy board features → Fuzzy membership: feeds values
- Fuzzy membership → Fuzzy rules: provides memberships
- Fuzzy rules → Fuzzy move chooser: drives choice
- Fuzzy move chooser → Game rules: selects legal move
- Experiment workflow → Fuzzy move chooser: runs experiments
- Experiment workflow → Decision tracing: records decisions
- Tauri host → Vite web entry: packages frontend
- Python algorithm entry → Python board mechanics: runs mechanics
- Python algorithm entry → Python minimax: runs search
- Python minimax → Python evaluation: scores positions
- Python minimax → Python board mechanics: simulates moves
