# shiarauzo/rubik-cube-3d architecture

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

- Interactive diagram: https://gitdiagram.com/shiarauzo/rubik-cube-3d
- Repository: https://github.com/shiarauzo/rubik-cube-3d

## Overview

Rubik 3D is a browser cube simulator with mouse/keyboard and webcam hand-gesture controls. Users manipulate the rendered cube or trigger turns, scrambles, and solving; each turn animates the 3D cubies and then updates the logical cube state. AR adds camera tracking, gesture interpretation, overlays, and an automatic solve path. The graph follows documented and indexed relationships; unsampled modules are included where README capabilities warrant them, but uncertain wiring is omitted.

Main entry points: [`src/app/App.ts`](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/app/App.ts) (App shell), [`src/cv/gestures/TwoHandController.ts`](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/TwoHandController.ts) (Gesture coordinator), [`src/cube/MoveEngine.ts`](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/MoveEngine.ts) (Move animation), [`src/hud/Hud.ts`](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/hud/Hud.ts) (HUD)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App orchestration"]
  node_app["App shell<br/>[App.ts]"]
  node_events["Event bus<br/>[events.ts]"]
end

subgraph group_cube["Cube gameplay"]
  node_cube_model["Logical cube<br/>[CubeModel.ts]"]
  node_cube_view["3D cubies<br/>[CubeView.ts]"]
  node_move_engine["Move animation<br/>[MoveEngine.ts]"]
  node_notation["Move notation<br/>[Notation.ts]"]
  node_scrambler["Scramble generator<br/>[Scrambler.ts]"]
end

subgraph group_vision["Hand controls"]
  node_webcam["Webcam access<br/>[Webcam.ts]"]
  node_camera_modal["Camera permission UI"]
  node_tracker["Hand tracker<br/>[HandTracker.ts]"]
  node_classifier["Gesture classifier"]
  node_controller["Gesture coordinator"]
  node_rotation["Hand rotation<br/>[HandRotation.ts]"]
  node_face_control["Face control<br/>[FaceControl.ts]"]
  node_overlay["Hand overlay<br/>[HandOverlay.ts]"]
  node_mode_indicator["Mode indicator<br/>[ModeIndicator.ts]"]
end

subgraph group_display["Rendering and HUD"]
  node_renderer["WebGL renderer<br/>[Renderer.ts]"]
  node_scene["3D scene<br/>[Scene.ts]"]
  node_orbit["Orbit controls<br/>[OrbitCam.ts]"]
  node_hud["HUD<br/>[Hud.ts]"]
  node_timer["Timer<br/>[Timer.ts]"]
  node_move_counter["Move counter<br/>[MoveCounter.ts]"]
end

subgraph group_solver["Solver"]
  node_solver["Solver proxy<br/>[Solver.ts]"]
  node_worker["Solver worker<br/>[solver.worker.ts]"]
end

node_user(("Player"))

node_user -->|"operates"| node_app
node_app -->|"creates"| node_renderer
node_app -->|"creates"| node_scene
node_app -->|"creates"| node_orbit
node_app -->|"creates"| node_cube_view
node_app -->|"creates"| node_cube_model
node_app -->|"creates"| node_move_engine
node_app -.->|"creates"| node_hud
node_app -.->|"starts"| node_webcam
node_app -.->|"initializes"| node_tracker
node_app -->|"processes frames"| node_controller
node_app -->|"creates"| node_overlay
node_app -->|"creates"| node_mode_indicator
node_app -->|"creates"| node_camera_modal
node_app -->|"generates scramble"| node_scrambler
node_scrambler -.->|"queues moves"| node_move_engine
node_move_engine -->|"animates cubies"| node_cube_view
node_move_engine -->|"applies move"| node_cube_model
node_move_engine -->|"emits move events"| node_events
node_cube_view -->|"maps facelets"| node_cube_model
node_app -.->|"publishes state"| node_events
node_hud -->|"observes events"| node_events
node_hud -->|"uses"| node_timer
node_hud -->|"uses"| node_move_counter
node_user -.->|"selects actions"| node_hud
node_tracker -.->|"provides landmarks"| node_classifier
node_classifier -.->|"classifies gestures"| node_controller
node_controller -->|"delegates rotation"| node_rotation
node_controller -->|"delegates face control"| node_face_control
node_face_control -->|"highlights layer"| node_cube_view
node_face_control -.->|"queues turns"| node_move_engine
node_rotation -->|"rotates view"| node_cube_view
node_controller -->|"reads facelets"| node_cube_model
node_controller -->|"requests solution"| node_solver
node_controller -->|"queues solution"| node_move_engine
node_solver -->|"dispatches solve"| node_worker
node_worker -.->|"returns moves"| node_solver
node_app -->|"requests solution"| node_solver
node_user -.->|"grants access"| node_webcam
node_webcam -.->|"camera frames"| node_tracker
node_tracker -.->|"draws landmarks"| node_overlay
node_controller -.->|"sets mode feedback"| node_mode_indicator

click node_app "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/app/App.ts"
click node_events "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/app/events.ts"
click node_cube_model "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/CubeModel.ts"
click node_cube_view "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/CubeView.ts"
click node_move_engine "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/MoveEngine.ts"
click node_notation "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/Notation.ts"
click node_scrambler "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/Scrambler.ts"
click node_renderer "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/render/Renderer.ts"
click node_scene "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/render/Scene.ts"
click node_orbit "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/render/OrbitCam.ts"
click node_hud "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/hud/Hud.ts"
click node_timer "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/hud/Timer.ts"
click node_move_counter "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/hud/MoveCounter.ts"
click node_webcam "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/Webcam.ts"
click node_camera_modal "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/CameraPermissionModal.ts"
click node_tracker "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/HandTracker.ts"
click node_classifier "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/GestureClassifier.ts"
click node_controller "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/TwoHandController.ts"
click node_rotation "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/HandRotation.ts"
click node_face_control "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/FaceControl.ts"
click node_overlay "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/HandOverlay.ts"
click node_mode_indicator "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/ModeIndicator.ts"
click node_solver "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/solver/Solver.ts"
click node_worker "https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/solver/solver.worker.ts"

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_events toneBlue
class node_cube_model,node_cube_view,node_move_engine,node_notation,node_scrambler toneAmber
class node_webcam,node_camera_modal,node_tracker,node_classifier,node_controller,node_rotation,node_face_control,node_overlay,node_mode_indicator toneMint
class node_renderer,node_scene,node_orbit,node_hud,node_timer,node_move_counter toneRose
class node_solver,node_worker,node_user toneIndigo
```

## Components

### App orchestration

- [App shell](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/app/App.ts): `src/app/App.ts`
- [Event bus](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/app/events.ts): `src/app/events.ts`

### Cube gameplay

- [Logical cube](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/CubeModel.ts): `src/cube/CubeModel.ts`
- [3D cubies](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/CubeView.ts): `src/cube/CubeView.ts`
- [Move animation](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/MoveEngine.ts): `src/cube/MoveEngine.ts`
- [Move notation](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/Notation.ts): `src/cube/Notation.ts`
- [Scramble generator](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cube/Scrambler.ts): `src/cube/Scrambler.ts`

### Hand controls

- [Webcam access](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/Webcam.ts): `src/cv/Webcam.ts`
- [Camera permission UI](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/CameraPermissionModal.ts): `src/cv/CameraPermissionModal.ts`
- [Hand tracker](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/HandTracker.ts): `src/cv/HandTracker.ts`
- [Gesture classifier](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/GestureClassifier.ts): `src/cv/gestures/GestureClassifier.ts`
- [Gesture coordinator](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/TwoHandController.ts): `src/cv/gestures/TwoHandController.ts`
- [Hand rotation](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/HandRotation.ts): `src/cv/gestures/HandRotation.ts`
- [Face control](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/gestures/FaceControl.ts): `src/cv/gestures/FaceControl.ts`
- [Hand overlay](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/HandOverlay.ts): `src/cv/HandOverlay.ts`
- [Mode indicator](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/cv/ModeIndicator.ts): `src/cv/ModeIndicator.ts`

### Rendering and HUD

- [WebGL renderer](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/render/Renderer.ts): `src/render/Renderer.ts`
- [3D scene](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/render/Scene.ts): `src/render/Scene.ts`
- [Orbit controls](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/render/OrbitCam.ts): `src/render/OrbitCam.ts`
- [HUD](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/hud/Hud.ts): `src/hud/Hud.ts`
- [Timer](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/hud/Timer.ts): `src/hud/Timer.ts`
- [Move counter](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/hud/MoveCounter.ts): `src/hud/MoveCounter.ts`

### Solver

- [Solver proxy](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/solver/Solver.ts): `src/solver/Solver.ts`
- [Solver worker](https://github.com/shiarauzo/rubik-cube-3d/blob/main/src/solver/solver.worker.ts): `src/solver/solver.worker.ts`

### Other components

- **Player**

## Connections

- Player → App shell: operates (evidence: `README.md`)
- App shell → WebGL renderer: creates (evidence: `src/app/App.ts`)
- App shell → 3D scene: creates (evidence: `src/app/App.ts`)
- App shell → Orbit controls: creates (evidence: `src/app/App.ts`)
- App shell → 3D cubies: creates (evidence: `src/app/App.ts`)
- App shell → Logical cube: creates (evidence: `src/app/App.ts`)
- App shell → Move animation: creates (evidence: `src/app/App.ts`)
- App shell → HUD: creates (evidence: `src/app/App.ts`)
- App shell → Webcam access: starts (evidence: `src/app/App.ts`)
- App shell → Hand tracker: initializes (evidence: `src/app/App.ts`)
- App shell → Gesture coordinator: processes frames (evidence: `src/app/App.ts`)
- App shell → Hand overlay: creates (evidence: `src/app/App.ts`)
- App shell → Mode indicator: creates (evidence: `src/app/App.ts`)
- App shell → Camera permission UI: creates (evidence: `src/app/App.ts`)
- App shell → Scramble generator: generates scramble (evidence: `src/app/App.ts`)
- Scramble generator → Move animation: queues moves
- Move animation → 3D cubies: animates cubies (evidence: `src/cube/MoveEngine.ts`)
- Move animation → Logical cube: applies move (evidence: `src/cube/MoveEngine.ts`)
- Move animation → Event bus: emits move events (evidence: `src/cube/MoveEngine.ts`)
- 3D cubies → Logical cube: maps facelets (evidence: `src/cube/CubeView.ts`)
- App shell → Event bus: publishes state (evidence: `src/app/App.ts`)
- HUD → Event bus: observes events (evidence: `src/hud/Hud.ts`)
- HUD → Timer: uses (evidence: `src/hud/Hud.ts`)
- HUD → Move counter: uses (evidence: `src/hud/Hud.ts`)
- Player → HUD: selects actions
- Hand tracker → Gesture classifier: provides landmarks
- Gesture classifier → Gesture coordinator: classifies gestures
- Gesture coordinator → Hand rotation: delegates rotation (evidence: `src/cv/gestures/TwoHandController.ts`)
- Gesture coordinator → Face control: delegates face control (evidence: `src/cv/gestures/TwoHandController.ts`)
- Face control → 3D cubies: highlights layer (evidence: `src/cv/gestures/FaceControl.ts`)
- Face control → Move animation: queues turns (evidence: `src/cv/gestures/FaceControl.ts`)
- Hand rotation → 3D cubies: rotates view (evidence: `src/cv/gestures/HandRotation.ts`)
- Gesture coordinator → Logical cube: reads facelets (evidence: `src/cv/gestures/TwoHandController.ts`)
- Gesture coordinator → Solver proxy: requests solution (evidence: `src/cv/gestures/TwoHandController.ts`)
- Gesture coordinator → Move animation: queues solution (evidence: `src/cv/gestures/TwoHandController.ts`)
- Solver proxy → Solver worker: dispatches solve (evidence: `src/solver/Solver.ts`)
- Solver worker → Solver proxy: returns moves
- App shell → Solver proxy: requests solution (evidence: `src/app/App.ts`)
- Player → Webcam access: grants access
- Webcam access → Hand tracker: camera frames
- Hand tracker → Hand overlay: draws landmarks
- Gesture coordinator → Mode indicator: sets mode feedback (evidence: `src/cv/ModeIndicator.ts`)
