# saffroncarp1106/osgar architecture

> Architecture diagram of the GitHub repository saffroncarp1106/osgar, 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/saffroncarp1106/osgar
- Repository: https://github.com/saffroncarp1106/osgar

## Overview

OSGAR is a desktop tool for turning osu! replay (.osr) or SVG paths into printer-oriented G-code, with replay visualization and optional synchronized HID key playback through a printer. The principal workflow is import, edit or preview paths, generate G-code, then coordinate printing and key events. The README documents the OSR/SVG conversion goal; sampled code confirms parsing, recording data, export, and run control. Some GUI wiring and peripheral capabilities are unsampled, so only documented or indexed relationships are shown.

Main entry points: [`gui/main_window.py`](https://github.com/saffroncarp1106/osgar/blob/main/gui/main_window.py) (Application window), [`recording/model.py`](https://github.com/saffroncarp1106/osgar/blob/main/recording/model.py) (Recording model), [`gui/hid_panel.py`](https://github.com/saffroncarp1106/osgar/blob/main/gui/hid_panel.py) (HID controls), [`hardware/run_controller.py`](https://github.com/saffroncarp1106/osgar/blob/main/hardware/run_controller.py) (Run controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_desktop["Application window<br/>[main_window.py]"]
  node_canvas["Canvas and editing<br/>[canvas.py]"]
  node_exportui["Export controls<br/>[export_panel.py]"]
end

subgraph group_ingest["Path ingestion"]
  node_osr["OSR parser<br/>[osr_importer.py]"]
  node_svg["SVG importer<br/>[svg_importer.py]"]
  node_recording["Recording model<br/>[model.py]"]
end

subgraph group_motion["Motion and export"]
  node_analysis["Replay analysis<br/>[analyze.py]"]
  node_coordinates["Coordinate conversion"]
  node_filters["Path filters<br/>[filters.py]"]
  node_planner["Motion planner<br/>[klipper_planner.py]"]
  node_speedfit["Speed fitting<br/>[speed_fit.py]"]
  node_gcode["G-code generator<br/>[gcode_exporter.py]"]
end

subgraph group_playback["Replay and HID"]
  node_player["Replay player<br/>[player.py]"]
  node_schedule["Key schedule<br/>[key_schedule.py]"]
  node_hidpanel["HID controls<br/>[hid_panel.py]"]
  node_hid["HID link<br/>[hid_link.py]"]
  node_controller["Run controller<br/>[run_controller.py]"]
  node_printerclient["Moonraker client"]
end

subgraph group_support["Settings and projects"]
  node_settings["Application settings<br/>[settings.py]"]
  node_project["Project persistence<br/>[project.py]"]
end

node_operator(("Operator"))
node_printer(("3D printer"))

node_operator -->|"uses"| node_desktop
node_desktop -->|"updates"| node_canvas
node_desktop -->|"imports replay"| node_osr
node_desktop -->|"imports paths"| node_svg
node_osr -->|"creates"| node_recording
node_svg -->|"creates"| node_recording
node_desktop -->|"edits layers"| node_recording
node_desktop -.->|"analyzes replay"| node_analysis
node_desktop -->|"converts positions"| node_coordinates
node_coordinates -->|"feeds"| node_filters
node_recording -->|"fits timing"| node_speedfit
node_exportui -->|"sets export options"| node_desktop
node_desktop -->|"exports paths"| node_gcode
node_gcode -->|"plans moves"| node_planner
node_desktop -.->|"controls replay"| node_player
node_hidpanel -->|"starts runs"| node_controller
node_hidpanel -->|"controls link"| node_hid
node_hidpanel -->|"prepares playback"| node_schedule
node_controller -->|"dispatches events"| node_schedule
node_controller -->|"controls printer"| node_printerclient
node_printerclient -->|"sends commands"| node_printer
node_desktop -->|"loads settings"| node_settings
node_desktop -.->|"loads projects"| node_project

click node_desktop "https://github.com/saffroncarp1106/osgar/blob/main/gui/main_window.py"
click node_canvas "https://github.com/saffroncarp1106/osgar/blob/main/gui/canvas.py"
click node_exportui "https://github.com/saffroncarp1106/osgar/blob/main/gui/export_panel.py"
click node_osr "https://github.com/saffroncarp1106/osgar/blob/main/storage/osr_importer.py"
click node_svg "https://github.com/saffroncarp1106/osgar/blob/main/storage/svg_importer.py"
click node_recording "https://github.com/saffroncarp1106/osgar/blob/main/recording/model.py"
click node_analysis "https://github.com/saffroncarp1106/osgar/blob/main/analyze.py"
click node_coordinates "https://github.com/saffroncarp1106/osgar/blob/main/motion/coordinate_converter.py"
click node_filters "https://github.com/saffroncarp1106/osgar/blob/main/motion/filters.py"
click node_planner "https://github.com/saffroncarp1106/osgar/blob/main/motion/klipper_planner.py"
click node_speedfit "https://github.com/saffroncarp1106/osgar/blob/main/motion/speed_fit.py"
click node_gcode "https://github.com/saffroncarp1106/osgar/blob/main/storage/gcode_exporter.py"
click node_player "https://github.com/saffroncarp1106/osgar/blob/main/playback/player.py"
click node_schedule "https://github.com/saffroncarp1106/osgar/blob/main/hardware/key_schedule.py"
click node_hidpanel "https://github.com/saffroncarp1106/osgar/blob/main/gui/hid_panel.py"
click node_hid "https://github.com/saffroncarp1106/osgar/blob/main/hardware/hid_link.py"
click node_controller "https://github.com/saffroncarp1106/osgar/blob/main/hardware/run_controller.py"
click node_printerclient "https://github.com/saffroncarp1106/osgar/blob/main/hardware/moonraker_client.py"
click node_settings "https://github.com/saffroncarp1106/osgar/blob/main/config/settings.py"
click node_project "https://github.com/saffroncarp1106/osgar/blob/main/storage/project.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_desktop,node_canvas,node_exportui toneBlue
class node_osr,node_svg,node_recording toneAmber
class node_analysis,node_coordinates,node_filters,node_planner,node_speedfit,node_gcode toneMint
class node_player,node_schedule,node_hidpanel,node_hid,node_controller,node_printerclient toneRose
class node_settings,node_project,node_operator,node_printer toneIndigo
```

## Components

### Desktop interface

- [Application window](https://github.com/saffroncarp1106/osgar/blob/main/gui/main_window.py): `gui/main_window.py`
- [Canvas and editing](https://github.com/saffroncarp1106/osgar/blob/main/gui/canvas.py): `gui/canvas.py`
- [Export controls](https://github.com/saffroncarp1106/osgar/blob/main/gui/export_panel.py): `gui/export_panel.py`

### Path ingestion

- [OSR parser](https://github.com/saffroncarp1106/osgar/blob/main/storage/osr_importer.py): `storage/osr_importer.py`
- [SVG importer](https://github.com/saffroncarp1106/osgar/blob/main/storage/svg_importer.py): `storage/svg_importer.py`
- [Recording model](https://github.com/saffroncarp1106/osgar/blob/main/recording/model.py): `recording/model.py`

### Motion and export

- [Replay analysis](https://github.com/saffroncarp1106/osgar/blob/main/analyze.py): `analyze.py`
- [Coordinate conversion](https://github.com/saffroncarp1106/osgar/blob/main/motion/coordinate_converter.py): `motion/coordinate_converter.py`
- [Path filters](https://github.com/saffroncarp1106/osgar/blob/main/motion/filters.py): `motion/filters.py`
- [Motion planner](https://github.com/saffroncarp1106/osgar/blob/main/motion/klipper_planner.py): `motion/klipper_planner.py`
- [Speed fitting](https://github.com/saffroncarp1106/osgar/blob/main/motion/speed_fit.py): `motion/speed_fit.py`
- [G-code generator](https://github.com/saffroncarp1106/osgar/blob/main/storage/gcode_exporter.py): `storage/gcode_exporter.py`

### Replay and HID

- [Replay player](https://github.com/saffroncarp1106/osgar/blob/main/playback/player.py): `playback/player.py`
- [Key schedule](https://github.com/saffroncarp1106/osgar/blob/main/hardware/key_schedule.py): `hardware/key_schedule.py`
- [HID controls](https://github.com/saffroncarp1106/osgar/blob/main/gui/hid_panel.py): `gui/hid_panel.py`
- [HID link](https://github.com/saffroncarp1106/osgar/blob/main/hardware/hid_link.py): `hardware/hid_link.py`
- [Run controller](https://github.com/saffroncarp1106/osgar/blob/main/hardware/run_controller.py): `hardware/run_controller.py`
- [Moonraker client](https://github.com/saffroncarp1106/osgar/blob/main/hardware/moonraker_client.py): `hardware/moonraker_client.py`

### Settings and projects

- [Application settings](https://github.com/saffroncarp1106/osgar/blob/main/config/settings.py): `config/settings.py`
- [Project persistence](https://github.com/saffroncarp1106/osgar/blob/main/storage/project.py): `storage/project.py`

### Other components

- **Operator**
- **3D printer**

## Connections

- Operator → Application window: uses
- Application window → Canvas and editing: updates (evidence: `gui/main_window.py`)
- Application window → OSR parser: imports replay (evidence: `gui/main_window.py`)
- Application window → SVG importer: imports paths (evidence: `gui/main_window.py`)
- OSR parser → Recording model: creates (evidence: `storage/osr_importer.py`)
- SVG importer → Recording model: creates (evidence: `storage/svg_importer.py`)
- Application window → Recording model: edits layers (evidence: `gui/main_window.py`)
- Application window → Replay analysis: analyzes replay
- Application window → Coordinate conversion: converts positions (evidence: `gui/main_window.py`)
- Coordinate conversion → Path filters: feeds (evidence: `motion/filters.py`)
- Recording model → Speed fitting: fits timing (evidence: `motion/speed_fit.py`)
- Export controls → Application window: sets export options (evidence: `gui/main_window.py`)
- Application window → G-code generator: exports paths (evidence: `gui/main_window.py`)
- G-code generator → Motion planner: plans moves (evidence: `storage/gcode_exporter.py`)
- Application window → Replay player: controls replay (evidence: `gui/main_window.py`)
- HID controls → Run controller: starts runs (evidence: `gui/hid_panel.py`)
- HID controls → HID link: controls link (evidence: `gui/hid_panel.py`)
- HID controls → Key schedule: prepares playback (evidence: `gui/hid_panel.py`)
- Run controller → Key schedule: dispatches events (evidence: `hardware/run_controller.py`)
- Run controller → Moonraker client: controls printer (evidence: `hardware/run_controller.py`)
- Moonraker client → 3D printer: sends commands (evidence: `hardware/moonraker_client.py`)
- Application window → Application settings: loads settings (evidence: `gui/main_window.py`)
- Application window → Project persistence: loads projects (evidence: `gui/main_window.py`)
