# nguyentan10052006-cmyk/ai-p1 architecture

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

- Interactive diagram: https://gitdiagram.com/nguyentan10052006-cmyk/ai-p1
- Repository: https://github.com/nguyentan10052006-cmyk/ai-p1

## Overview

Bloxorz Solver combines a playable Bloxorz game, a Python game-rules and search engine, a browser client with an HTTP API, and an Ursina desktop GUI. The main user workflow is to choose a level, make moves that the server validates, and see the updated state; users can also request an AI solution. The solver package provides BFS, DFS, UCS, and A* variants, while the repository also includes experiment-running utilities. Some subsystem links are based on the SOURCE INDEX rather than full excerpts; optional browser-to-server wiring is left unasserted where direct evidence is absent.

Main entry points: [`Source/server/api.py`](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/server/api.py) (API handlers), [`Source/web/js/game.js`](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/game.js) (Browser player), [`Source/bloxorz/problem.py`](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/problem.py) (Search problem), [`Source/gui/app.py`](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/gui/app.py) (Ursina game)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_domain["Game domain"]
  node_leveldata["Level loading<br/>[level.py]"]
  node_state["Game state<br/>[state.py]"]
  node_rules["Move rules<br/>[rules.py]"]
  node_problem["Search problem<br/>[problem.py]"]
  node_serialization["State serialization<br/>[serialize.py]"]
  node_maze["Maze utilities<br/>[maze.py]"]
end

subgraph group_search["Search engine"]
  node_solverbase["Solver contract<br/>[base.py]"]
  node_algorithms["Search algorithms<br/>[__init__.py]"]
  node_heuristics["A* heuristics<br/>[heuristics.py]"]
  node_runner["Solver runner<br/>[runner.py]"]
  node_experiments["Solver experiments<br/>[run.py]"]
end

subgraph group_browser["Browser game"]
  node_webplayer["Browser player<br/>[game.js]"]
  node_webapi["API client<br/>[api.js]"]
  node_webview["Board and block views<br/>[board.js]"]
  node_webscreens["Menus and screens<br/>[screens.js]"]
  node_webinput["Input handling<br/>[input.js]"]
  node_webstorage[("Progress storage<br/>[storage.js]")]
end

subgraph group_service["API service"]
  node_serverapp["HTTP application<br/>[app.py]"]
  node_serverapi["API handlers<br/>[api.py]"]
end

subgraph group_desktop["Desktop GUI"]
  node_desktopapp["Ursina game<br/>[app.py]"]
  node_desktopboard["3D board view<br/>[board_view.py]"]
  node_desktopblock["3D block view<br/>[block_view.py]"]
end

node_player(("Player"))

node_player -->|"plays"| node_webplayer
node_webplayer -->|"requests moves"| node_webapi
node_webplayer -->|"updates view"| node_webview
node_webplayer -->|"controls screens"| node_webscreens
node_webplayer -->|"handles input"| node_webinput
node_webplayer -->|"stores progress"| node_webstorage
node_webapi -.->|"sends requests"| node_serverapi
node_serverapp -->|"routes to"| node_serverapi
node_serverapi -->|"loads levels"| node_leveldata
node_serverapi -->|"serializes data"| node_serialization
node_serverapi -->|"applies moves"| node_rules
node_serverapi -->|"builds problem"| node_problem
node_serverapi -->|"runs solver"| node_runner
node_problem -->|"evaluates moves"| node_rules
node_problem -->|"uses level"| node_leveldata
node_rules -->|"transforms state"| node_state
node_leveldata -->|"creates initial state"| node_state
node_runner -->|"runs jobs"| node_solverbase
node_runner -->|"selects algorithm"| node_algorithms
node_runner -->|"searches problem"| node_problem
node_algorithms -->|"implements contract"| node_solverbase
node_heuristics -->|"estimates search"| node_problem
node_heuristics -->|"uses maze"| node_maze
node_experiments -->|"constructs problems"| node_problem
node_experiments -->|"measures solvers"| node_solverbase
node_player -->|"plays"| node_desktopapp
node_desktopapp -->|"loads level"| node_leveldata
node_desktopapp -->|"applies move"| node_rules
node_desktopapp -->|"renders board"| node_desktopboard
node_desktopapp -->|"renders block"| node_desktopblock
node_desktopboard -->|"uses coordinates"| node_state
node_desktopblock -->|"renders state"| node_state

click node_leveldata "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/level.py"
click node_state "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/state.py"
click node_rules "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/rules.py"
click node_problem "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/problem.py"
click node_serialization "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/serialize.py"
click node_maze "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/maze.py"
click node_solverbase "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/solvers/base.py"
click node_algorithms "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/solvers/__init__.py"
click node_heuristics "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/solvers/heuristics.py"
click node_runner "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/solvers/runner.py"
click node_experiments "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/experiments/run.py"
click node_webplayer "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/game.js"
click node_webapi "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/api.js"
click node_webview "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/board.js"
click node_webscreens "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/screens.js"
click node_webinput "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/input.js"
click node_webstorage "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/storage.js"
click node_serverapp "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/server/app.py"
click node_serverapi "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/server/api.py"
click node_desktopapp "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/gui/app.py"
click node_desktopboard "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/gui/board_view.py"
click node_desktopblock "https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/gui/block_view.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_leveldata,node_state,node_rules,node_problem,node_serialization,node_maze toneBlue
class node_solverbase,node_algorithms,node_heuristics,node_runner,node_experiments toneAmber
class node_webplayer,node_webapi,node_webview,node_webscreens,node_webinput,node_webstorage toneMint
class node_serverapp,node_serverapi toneRose
class node_desktopapp,node_desktopboard,node_desktopblock,node_player toneIndigo
```

## Components

### Game domain

- [Level loading](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/level.py): `Source/bloxorz/level.py`
- [Game state](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/state.py): `Source/bloxorz/state.py`
- [Move rules](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/rules.py): `Source/bloxorz/rules.py`
- [Search problem](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/problem.py): `Source/bloxorz/problem.py`
- [State serialization](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/serialize.py): `Source/bloxorz/serialize.py`
- [Maze utilities](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/bloxorz/maze.py): `Source/bloxorz/maze.py`

### Search engine

- [Solver contract](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/solvers/base.py): `Source/solvers/base.py`
- [Search algorithms](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/solvers/__init__.py): `Source/solvers/__init__.py`
- [A* heuristics](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/solvers/heuristics.py): `Source/solvers/heuristics.py`
- [Solver runner](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/solvers/runner.py): `Source/solvers/runner.py`
- [Solver experiments](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/experiments/run.py): `Source/experiments/run.py`

### Browser game

- [Browser player](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/game.js): `Source/web/js/game.js`
- [API client](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/api.js): `Source/web/js/api.js`
- [Board and block views](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/board.js): `Source/web/js/board.js`
- [Menus and screens](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/screens.js): `Source/web/js/screens.js`
- [Input handling](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/input.js): `Source/web/js/input.js`
- [Progress storage](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/web/js/storage.js): `Source/web/js/storage.js`

### API service

- [HTTP application](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/server/app.py): `Source/server/app.py`
- [API handlers](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/server/api.py): `Source/server/api.py`

### Desktop GUI

- [Ursina game](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/gui/app.py): `Source/gui/app.py`
- [3D board view](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/gui/board_view.py): `Source/gui/board_view.py`
- [3D block view](https://github.com/nguyentan10052006-cmyk/ai-p1/blob/main/Source/gui/block_view.py): `Source/gui/block_view.py`

### Other components

- **Player**

## Connections

- Player → Browser player: plays (evidence: `Source/web/js/game.js`)
- Browser player → API client: requests moves (evidence: `Source/web/js/game.js`)
- Browser player → Board and block views: updates view (evidence: `Source/web/js/game.js`)
- Browser player → Menus and screens: controls screens (evidence: `Source/web/js/game.js`)
- Browser player → Input handling: handles input (evidence: `Source/web/js/game.js`)
- Browser player → Progress storage: stores progress (evidence: `Source/web/js/game.js`)
- API client → API handlers: sends requests
- HTTP application → API handlers: routes to (evidence: `Source/server/app.py`)
- API handlers → Level loading: loads levels (evidence: `Source/server/api.py`)
- API handlers → State serialization: serializes data (evidence: `Source/server/api.py`)
- API handlers → Move rules: applies moves (evidence: `Source/server/api.py`)
- API handlers → Search problem: builds problem (evidence: `Source/server/api.py`)
- API handlers → Solver runner: runs solver (evidence: `Source/server/api.py`)
- Search problem → Move rules: evaluates moves (evidence: `Source/bloxorz/problem.py`)
- Search problem → Level loading: uses level (evidence: `Source/bloxorz/problem.py`)
- Move rules → Game state: transforms state (evidence: `Source/bloxorz/rules.py`)
- Level loading → Game state: creates initial state (evidence: `Source/bloxorz/level.py`)
- Solver runner → Solver contract: runs jobs (evidence: `Source/solvers/runner.py`)
- Solver runner → Search algorithms: selects algorithm (evidence: `Source/solvers/runner.py`)
- Solver runner → Search problem: searches problem (evidence: `Source/solvers/runner.py`)
- Search algorithms → Solver contract: implements contract (evidence: `Source/solvers/__init__.py`)
- A* heuristics → Search problem: estimates search (evidence: `Source/solvers/heuristics.py`)
- A* heuristics → Maze utilities: uses maze (evidence: `Source/solvers/heuristics.py`)
- Solver experiments → Search problem: constructs problems (evidence: `Source/experiments/run.py`)
- Solver experiments → Solver contract: measures solvers (evidence: `Source/experiments/run.py`)
- Player → Ursina game: plays (evidence: `Source/gui/app.py`)
- Ursina game → Level loading: loads level (evidence: `Source/gui/app.py`)
- Ursina game → Move rules: applies move (evidence: `Source/gui/app.py`)
- Ursina game → 3D board view: renders board (evidence: `Source/gui/app.py`)
- Ursina game → 3D block view: renders block (evidence: `Source/gui/app.py`)
- 3D board view → Game state: uses coordinates (evidence: `Source/gui/board_view.py`)
- 3D block view → Game state: renders state (evidence: `Source/gui/block_view.py`)
