# trhoaq/mms architecture

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

- Interactive diagram: https://gitdiagram.com/trhoaq/mms
- Repository: https://github.com/trhoaq/mms

## Overview

Micromouse Simulator is a PyQt5 application for editing mazes and trying two robot-control modes. In algorithm mode, a user-supplied algorithm receives a perfect-information maze view; the controller applies its moves to a grid turtle and reports progress. In physical mode, a user control function receives simulated IR, encoder, and yaw readings, then commands differential-drive motors; physics handles movement and collisions. The editor supports maze creation and JSON save/load, with edited mazes synchronized across both modes. The graph follows shown calls and README capabilities; dashboard internals and user algorithms are not sampled.

Main entry points: [`ui/main_window.py`](https://github.com/trhoaq/mms/blob/main/ui/main_window.py) (Main Window), [`core/maze.py`](https://github.com/trhoaq/mms/blob/main/core/maze.py) (Maze Model), [`sim_real/physics.py`](https://github.com/trhoaq/mms/blob/main/sim_real/physics.py) (Robot Physics), [`sim_algo/controller.py`](https://github.com/trhoaq/mms/blob/main/sim_algo/controller.py) (Algorithm Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_maze["Maze Model"]
  node_maze_data["Maze Model<br/>[maze.py]"]
  node_constants["Grid Constants<br/>[const.py]"]
  node_maze_files["Maze JSON Files"]
end

subgraph group_algo["Algorithm Mode"]
  node_algo_code["User Algorithm<br/>[my_algo.py]"]
  node_algo_api["Algorithm Interface<br/>[base.py]"]
  node_algo_control["Algorithm Controller<br/>[controller.py]"]
  node_turtle["Grid Turtle<br/>[turtle_qt.py]"]
end

subgraph group_physical["Physical Mode"]
  node_real_code["User Control<br/>[my_control.py]"]
  node_real_control["Robot Controller<br/>[controller.py]"]
  node_sensors["IR and IMU<br/>[sensors.py]"]
  node_physics["Robot Physics<br/>[physics.py]"]
  node_motors["Motors and Encoders<br/>[motors.py]"]
end

subgraph group_interface["Application UI"]
  node_app["Application Entry<br/>[main.py]"]
  node_window["Main Window<br/>[main_window.py]"]
  node_editor["Maze Editor<br/>[maze_editor.py]"]
  node_robot_view["Robot View<br/>[robot_view.py]"]
  node_dashboard["Telemetry Dashboard<br/>[dashboard.py]"]
end

node_user(("User"))

node_user -->|"launches"| node_app
node_app -->|"opens"| node_window
node_window -->|"creates and loads"| node_maze_data
node_window -->|"creates"| node_editor
node_editor -->|"toggles walls"| node_maze_data
node_window -->|"saves and opens"| node_maze_files
node_window -->|"loads dynamically"| node_algo_code
node_window -->|"configures"| node_algo_control
node_window -->|"creates"| node_turtle
node_algo_control -.->|"requests moves"| node_algo_code
node_algo_control -->|"builds maze view"| node_algo_api
node_algo_control -->|"applies actions"| node_turtle
node_turtle -->|"reads walls and flood"| node_maze_data
node_maze_data -->|"uses grid definitions"| node_constants
node_window -->|"loads dynamically"| node_real_code
node_window -->|"configures"| node_real_control
node_window -->|"creates robot"| node_physics
node_window -->|"creates"| node_robot_view
node_window -->|"creates"| node_dashboard
node_real_control -.->|"requests motor commands"| node_real_code
node_real_control -->|"reads sensor values"| node_sensors
node_real_control -->|"steps robot"| node_physics
node_physics -->|"builds wall segments"| node_sensors
node_physics -->|"updates motors and encoders"| node_motors
node_physics -.->|"builds collision geometry"| node_maze_data
node_robot_view -->|"draws IR readings"| node_sensors
node_robot_view -.->|"draws maze walls"| node_maze_data

click node_app "https://github.com/trhoaq/mms/blob/main/main.py"
click node_window "https://github.com/trhoaq/mms/blob/main/ui/main_window.py"
click node_maze_data "https://github.com/trhoaq/mms/blob/main/core/maze.py"
click node_constants "https://github.com/trhoaq/mms/blob/main/core/const.py"
click node_editor "https://github.com/trhoaq/mms/blob/main/ui/maze_editor.py"
click node_algo_code "https://github.com/trhoaq/mms/blob/main/user_code/my_algo.py"
click node_algo_api "https://github.com/trhoaq/mms/blob/main/core/algorithms/base.py"
click node_algo_control "https://github.com/trhoaq/mms/blob/main/sim_algo/controller.py"
click node_turtle "https://github.com/trhoaq/mms/blob/main/sim_algo/turtle_qt.py"
click node_real_code "https://github.com/trhoaq/mms/blob/main/user_code/my_control.py"
click node_real_control "https://github.com/trhoaq/mms/blob/main/sim_real/controller.py"
click node_sensors "https://github.com/trhoaq/mms/blob/main/sim_real/sensors.py"
click node_physics "https://github.com/trhoaq/mms/blob/main/sim_real/physics.py"
click node_motors "https://github.com/trhoaq/mms/blob/main/sim_real/motors.py"
click node_robot_view "https://github.com/trhoaq/mms/blob/main/ui/robot_view.py"
click node_dashboard "https://github.com/trhoaq/mms/blob/main/ui/dashboard.py"
click node_maze_files "https://github.com/trhoaq/mms/tree/main/mazes"

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_maze_data,node_constants,node_maze_files,node_user toneBlue
class node_algo_code,node_algo_api,node_algo_control,node_turtle toneAmber
class node_real_code,node_real_control,node_sensors,node_physics,node_motors toneMint
class node_app,node_window,node_editor,node_robot_view,node_dashboard toneRose
```

## Components

### Maze Model

- [Maze Model](https://github.com/trhoaq/mms/blob/main/core/maze.py): `core/maze.py`
- [Grid Constants](https://github.com/trhoaq/mms/blob/main/core/const.py): `core/const.py`
- [Maze JSON Files](https://github.com/trhoaq/mms/tree/main/mazes): `mazes`

### Algorithm Mode

- [User Algorithm](https://github.com/trhoaq/mms/blob/main/user_code/my_algo.py): `user_code/my_algo.py`
- [Algorithm Interface](https://github.com/trhoaq/mms/blob/main/core/algorithms/base.py): `core/algorithms/base.py`
- [Algorithm Controller](https://github.com/trhoaq/mms/blob/main/sim_algo/controller.py): `sim_algo/controller.py`
- [Grid Turtle](https://github.com/trhoaq/mms/blob/main/sim_algo/turtle_qt.py): `sim_algo/turtle_qt.py`

### Physical Mode

- [User Control](https://github.com/trhoaq/mms/blob/main/user_code/my_control.py): `user_code/my_control.py`
- [Robot Controller](https://github.com/trhoaq/mms/blob/main/sim_real/controller.py): `sim_real/controller.py`
- [IR and IMU](https://github.com/trhoaq/mms/blob/main/sim_real/sensors.py): `sim_real/sensors.py`
- [Robot Physics](https://github.com/trhoaq/mms/blob/main/sim_real/physics.py): `sim_real/physics.py`
- [Motors and Encoders](https://github.com/trhoaq/mms/blob/main/sim_real/motors.py): `sim_real/motors.py`

### Application UI

- [Application Entry](https://github.com/trhoaq/mms/blob/main/main.py): `main.py`
- [Main Window](https://github.com/trhoaq/mms/blob/main/ui/main_window.py): `ui/main_window.py`
- [Maze Editor](https://github.com/trhoaq/mms/blob/main/ui/maze_editor.py): `ui/maze_editor.py`
- [Robot View](https://github.com/trhoaq/mms/blob/main/ui/robot_view.py): `ui/robot_view.py`
- [Telemetry Dashboard](https://github.com/trhoaq/mms/blob/main/ui/dashboard.py): `ui/dashboard.py`

### Other components

- **User**

## Connections

- User → Application Entry: launches (evidence: `main.py`)
- Application Entry → Main Window: opens (evidence: `main.py`)
- Main Window → Maze Model: creates and loads (evidence: `ui/main_window.py`)
- Main Window → Maze Editor: creates (evidence: `ui/main_window.py`)
- Maze Editor → Maze Model: toggles walls (evidence: `ui/maze_editor.py`)
- Main Window → Maze JSON Files: saves and opens (evidence: `ui/main_window.py`)
- Main Window → User Algorithm: loads dynamically (evidence: `ui/main_window.py`)
- Main Window → Algorithm Controller: configures (evidence: `ui/main_window.py`)
- Main Window → Grid Turtle: creates (evidence: `ui/main_window.py`)
- Algorithm Controller → User Algorithm: requests moves
- Algorithm Controller → Algorithm Interface: builds maze view (evidence: `sim_algo/controller.py`)
- Algorithm Controller → Grid Turtle: applies actions (evidence: `sim_algo/controller.py`)
- Grid Turtle → Maze Model: reads walls and flood (evidence: `sim_algo/turtle_qt.py`)
- Maze Model → Grid Constants: uses grid definitions (evidence: `core/maze.py`)
- Main Window → User Control: loads dynamically (evidence: `ui/main_window.py`)
- Main Window → Robot Controller: configures (evidence: `ui/main_window.py`)
- Main Window → Robot Physics: creates robot (evidence: `ui/main_window.py`)
- Main Window → Robot View: creates (evidence: `ui/main_window.py`)
- Main Window → Telemetry Dashboard: creates (evidence: `ui/main_window.py`)
- Robot Controller → User Control: requests motor commands
- Robot Controller → IR and IMU: reads sensor values (evidence: `sim_real/controller.py`)
- Robot Controller → Robot Physics: steps robot (evidence: `sim_real/controller.py`)
- Robot Physics → IR and IMU: builds wall segments (evidence: `sim_real/physics.py`)
- Robot Physics → Motors and Encoders: updates motors and encoders (evidence: `sim_real/physics.py`)
- Robot Physics → Maze Model: builds collision geometry
- Robot View → IR and IMU: draws IR readings (evidence: `ui/robot_view.py`)
- Robot View → Maze Model: draws maze walls
