Architecture Overview¶
FiberPath is organized as a layered system that keeps the heavy math and machine modeling inside the Python core while exposing multiple user interfaces. This document explains how the pieces fit together and where to extend them.
High-Level Stack¶
┌──────────────────┐ ┌────────────────────────────┐
│ Desktop GUI │ IPC │ fiberpath_cli (Typer) │
│ fiberpath_gui │ ─────► │ Commands: plan/plot/... │
└──────────────────┘ └────────────┬───────────────┘
│ (import)
┌──────────────────────┐ ▼
│ FastAPI service │ ┌────────────────────────┐
│ fiberpath_api │ JSON │ Core engine (Python) │
└──────────────────────┘ ◄──────│ Planning/Sim/G-code │
└────────────────────────┘
- Core Engine (
fiberpath/) – Immutable planners, geometry helpers, machine abstractions, and G-code emitters. The modules are designed to run without side effects so they can be imported from both CLI and API layers. - Interface Layer –
fiberpath_clihosts the Typer commands, whilefiberpath_apiturns the same operations into REST endpoints. The desktop GUI wraps the CLI and communicates via Tauri IPC to keep Python the single source of truth.
Key Modules¶
| Module | Responsibility | Notes |
|---|---|---|
fiberpath.planning |
Parses .wind files, validates machine/layer constraints, produces command sequences. |
PlanOptions governs verbosity and strategy tweaks. |
fiberpath.geometry |
Curve/surface math shared between planner and simulator. | Pure functions make it safe for reuse. |
fiberpath.gcode |
Dialects and writers for Marlin-style controllers. | Extend here when adding custom headers or commands. |
fiberpath.simulation |
Time/distance estimations based on planned feed rates. | Feeds CLI simulate summaries. |
fiberpath.execution |
PySerial streaming, pause/resume, and progress tracking. | Used by CLI streaming and API /stream. |
Data Flow¶
- Plan –
.winddefinitions load throughfiberpath.config, the planner emits aPlanSummary, andfiberpath.gcode.write_gcodepersists the result. - Plot –
fiberpath.visualization.plotter.render_plotinterprets G-code into a Pillow image. - Simulate –
fiberpath.simulation.simulate_programwalks the commands created by the planner to estimate duration, distance, and tow usage. - Stream –
fiberpath.execution.marlin.MarlinStreamerreads the final G-code file, opening a serial connection (or dry-run) and emitting progress callbacks.
Each CLI command keeps the JSON serialization logic local so the API and GUI can reuse the same shapes without introducing FastAPI or Typer dependencies in the core.
Extension Points¶
- New planner strategies: Add implementations under
fiberpath/planning/layer_strategies.pyand wire them throughplan_wind. - Alternate machine dialects: Create new dialect definitions under
fiberpath/gcode/dialects.pyand swap them in via CLI flags or API parameters. - GUI panels: Implement a new Tauri command in
fiberpath_gui/src-tauri/src/main.rs, call the relevant CLI entry point, and expose it viasrc/lib/commands.tsfor React components.
External Dependencies¶
- Python:
numpy,pydantic,typer,rich,Pillow, andpyserialcover numerics, data validation, CLI UX, plotting, and serial I/O. - Desktop: Vite + React + Tauri for cross-platform packaging; the Rust side shells out to the Python CLI to avoid code duplication.
Understanding this layout should make Phase 6 documentation, linting, and packaging updates easier because each layer stays isolated yet composable.