# moggieuk/happy-hare architecture

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

- Interactive diagram: https://gitdiagram.com/moggieuk/happy-hare
- Repository: https://github.com/moggieuk/happy-hare

## Overview

Happy Hare is a Klipper extension that controls modular filament-changing hardware and exposes operations through Klipper macros and UI integrations. The main workflow is operator or print-driven tool selection, gate mapping, filament movement and synchronized hardware control, with sensing and runout protection updating state. The README also documents calibration, spool identification, peripherals, diagnostics, and guided configuration. Edges are limited to README statements and relationships visible in the supplied excerpts or SOURCE INDEX; unsampled subsystems are represented without speculative internal wiring.

Main entry points: [`extras/mmu/mmu_controller.py`](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_controller.py) (MMU Controller), [`extras/mmu/commands/mmu_base_command.py`](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/commands/mmu_base_command.py) (G-code Commands), [`extras/mmu/mmu_sensor_manager.py`](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_sensor_manager.py) (Sensor Manager), [`extras/mmu/mmu_filament_movement.py`](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_filament_movement.py) (Filament Movement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["MMU Control"]
  node_commands["G-code Commands"]
  node_controller["MMU Controller<br/>[mmu_controller.py]"]
  node_unit["MMU Units<br/>[mmu_unit.py]"]
  node_diagnostics["Diagnostics and Tests<br/>[mmu_status.py]"]
end

subgraph group_motion["Filament Motion"]
  node_movement["Filament Movement"]
  node_sync["Drive Synchronization"]
  node_calibration["Calibration<br/>[mmu_calibrator.py]"]
end

subgraph group_mapping["Mapping and State"]
  node_maps["Gate and Tool Maps<br/>[mmu_gate_maps.py]"]
  node_printstate["Print State"]
  node_persistence[("Persistent State<br/>[mmu_utils.py]")]
end

subgraph group_hardware["Hardware Services"]
  node_sensors["Sensor Manager"]
  node_sensorlogic["Sensor Logic"]
  node_nfc["NFC / RFID<br/>[mmu_nfc_manager.py]"]
  node_td1["TD-1 Scanner<br/>[mmu_td1_manager.py]"]
  node_td1device["TD-1 Device<br/>[mmu_td1_device.py]"]
  node_leds["LED Services<br/>[mmu_led_manager.py]"]
  node_ledunit["Unit LEDs<br/>[mmu_leds.py]"]
  node_environment["Drying and Heaters"]
  node_spoolman["Spoolman Integration<br/>[mmu_spoolman.py]"]
end

subgraph group_setup["Setup and Configuration"]
  node_installer["Guided Configurator<br/>[build.py]"]
  node_configparser["Klipper Config Parser<br/>[parser.py]"]
end

node_operator(("Operator / Print"))
node_klipper["Klipper"]

node_operator -->|"uses macros"| node_klipper
node_klipper -->|"invokes commands"| node_commands
node_commands -.->|"controls MMU"| node_controller
node_controller -->|"coordinates movement"| node_movement
node_controller -->|"uses gate maps"| node_maps
node_controller -->|"coordinates sensors"| node_sensors
node_controller -->|"uses print state"| node_printstate
node_controller -->|"manages units"| node_unit
node_movement -.->|"synchronizes drives"| node_sync
node_controller -.->|"exposes calibration"| node_calibration
node_controller -.->|"persists state"| node_persistence
node_sensors -->|"uses sensor logic"| node_sensorlogic
node_controller -.->|"coordinates NFC"| node_nfc
node_controller -.->|"coordinates scanner"| node_td1
node_td1 -->|"manages devices"| node_td1device
node_controller -->|"manages LEDs"| node_leds
node_leds -->|"uses unit LEDs"| node_ledunit
node_controller -.->|"supports drying"| node_environment
node_commands -->|"offers spool commands"| node_spoolman
node_klipper -->|"exposes diagnostics"| node_diagnostics
node_operator -->|"configures hardware"| node_installer
node_installer -->|"parses configuration"| node_configparser
node_controller -->|"supports tool mapping"| node_maps
node_controller -->|"protects filament path"| node_sensors
node_controller -->|"integrates spool inventory"| node_spoolman

click node_commands "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/commands/mmu_base_command.py"
click node_controller "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_controller.py"
click node_unit "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_unit.py"
click node_movement "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_filament_movement.py"
click node_sync "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_sync_controller.py"
click node_calibration "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_calibrator.py"
click node_maps "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_gate_maps.py"
click node_printstate "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_print_state_machine.py"
click node_persistence "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_utils.py"
click node_sensors "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_sensor_manager.py"
click node_sensorlogic "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_sensor_utils.py"
click node_nfc "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_nfc_manager.py"
click node_td1 "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_td1_manager.py"
click node_td1device "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/td1/mmu_td1_device.py"
click node_leds "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_led_manager.py"
click node_ledunit "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_leds.py"
click node_environment "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_environment_manager.py"
click node_spoolman "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/commands/mmu_spoolman.py"
click node_diagnostics "https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/commands/mmu_status.py"
click node_installer "https://github.com/moggieuk/happy-hare/blob/main/installer/build.py"
click node_configparser "https://github.com/moggieuk/happy-hare/blob/main/installer/parser.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_commands,node_controller,node_unit,node_diagnostics toneBlue
class node_movement,node_sync,node_calibration toneAmber
class node_maps,node_printstate,node_persistence toneMint
class node_sensors,node_sensorlogic,node_nfc,node_td1,node_td1device,node_leds,node_ledunit,node_environment,node_spoolman toneRose
class node_installer,node_configparser,node_operator,node_klipper toneIndigo
```

## Components

### MMU Control

- [G-code Commands](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/commands/mmu_base_command.py): `extras/mmu/commands/mmu_base_command.py`
- [MMU Controller](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_controller.py): `extras/mmu/mmu_controller.py`
- [MMU Units](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_unit.py): `extras/mmu/mmu_unit.py`
- [Diagnostics and Tests](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/commands/mmu_status.py): `extras/mmu/commands/mmu_status.py`

### Filament Motion

- [Filament Movement](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_filament_movement.py): `extras/mmu/mmu_filament_movement.py`
- [Drive Synchronization](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_sync_controller.py): `extras/mmu/unit/mmu_sync_controller.py`
- [Calibration](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_calibrator.py): `extras/mmu/unit/mmu_calibrator.py`

### Mapping and State

- [Gate and Tool Maps](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_gate_maps.py): `extras/mmu/mmu_gate_maps.py`
- [Print State](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_print_state_machine.py): `extras/mmu/mmu_print_state_machine.py`
- [Persistent State](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_utils.py): `extras/mmu/mmu_utils.py`

### Hardware Services

- [Sensor Manager](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_sensor_manager.py): `extras/mmu/mmu_sensor_manager.py`
- [Sensor Logic](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_sensor_utils.py): `extras/mmu/mmu_sensor_utils.py`
- [NFC / RFID](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_nfc_manager.py): `extras/mmu/unit/mmu_nfc_manager.py`
- [TD-1 Scanner](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_td1_manager.py): `extras/mmu/unit/mmu_td1_manager.py`
- [TD-1 Device](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/td1/mmu_td1_device.py): `extras/mmu/unit/td1/mmu_td1_device.py`
- [LED Services](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/mmu_led_manager.py): `extras/mmu/mmu_led_manager.py`
- [Unit LEDs](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_leds.py): `extras/mmu/unit/mmu_leds.py`
- [Drying and Heaters](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/unit/mmu_environment_manager.py): `extras/mmu/unit/mmu_environment_manager.py`
- [Spoolman Integration](https://github.com/moggieuk/happy-hare/blob/main/extras/mmu/commands/mmu_spoolman.py): `extras/mmu/commands/mmu_spoolman.py`

### Setup and Configuration

- [Guided Configurator](https://github.com/moggieuk/happy-hare/blob/main/installer/build.py): `installer/build.py`
- [Klipper Config Parser](https://github.com/moggieuk/happy-hare/blob/main/installer/parser.py): `installer/parser.py`

### Other components

- **Operator / Print**
- **Klipper**

## Connections

- Operator / Print → Klipper: uses macros (evidence: `README.md`)
- Klipper → G-code Commands: invokes commands (evidence: `README.md`)
- G-code Commands → MMU Controller: controls MMU (evidence: `extras/mmu/mmu_controller.py`)
- MMU Controller → Filament Movement: coordinates movement (evidence: `extras/mmu/mmu_controller.py`)
- MMU Controller → Gate and Tool Maps: uses gate maps (evidence: `extras/mmu/mmu_controller.py`)
- MMU Controller → Sensor Manager: coordinates sensors (evidence: `extras/mmu/mmu_controller.py`)
- MMU Controller → Print State: uses print state (evidence: `extras/mmu/mmu_controller.py`)
- MMU Controller → MMU Units: manages units
- Filament Movement → Drive Synchronization: synchronizes drives
- MMU Controller → Calibration: exposes calibration
- MMU Controller → Persistent State: persists state (evidence: `extras/mmu/mmu_controller.py`)
- Sensor Manager → Sensor Logic: uses sensor logic (evidence: `extras/mmu/mmu_sensor_manager.py`)
- MMU Controller → NFC / RFID: coordinates NFC
- MMU Controller → TD-1 Scanner: coordinates scanner
- TD-1 Scanner → TD-1 Device: manages devices (evidence: `extras/mmu/unit/mmu_td1_manager.py`)
- MMU Controller → LED Services: manages LEDs (evidence: `extras/mmu/mmu_controller.py`)
- LED Services → Unit LEDs: uses unit LEDs (evidence: `extras/mmu/mmu_led_manager.py`)
- MMU Controller → Drying and Heaters: supports drying
- G-code Commands → Spoolman Integration: offers spool commands (evidence: `README.md`)
- Klipper → Diagnostics and Tests: exposes diagnostics (evidence: `README.md`)
- Operator / Print → Guided Configurator: configures hardware (evidence: `README.md`)
- Guided Configurator → Klipper Config Parser: parses configuration (evidence: `installer/build.py`)
- MMU Controller → Gate and Tool Maps: supports tool mapping (evidence: `README.md`)
- MMU Controller → Sensor Manager: protects filament path (evidence: `README.md`)
- MMU Controller → Spoolman Integration: integrates spool inventory (evidence: `README.md`)
