# khayreddine-zomita/grblhal-cutter-compensation architecture

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

- Interactive diagram: https://gitdiagram.com/khayreddine-zomita/grblhal-cutter-compensation
- Repository: https://github.com/khayreddine-zomita/grblhal-cutter-compensation

## Overview

This is a grblHAL Teensy 4 CNC-controller repository, described by its README as a test repository for diameter cutter compensation (G41/G42). The intended user-facing flow is G-code execution with cutter compensation affecting programmed motion, but the supplied excerpts do not show the runtime registration or call path joining those stages. The graph therefore highlights the documented capability and the main controller/runtime layers without asserting unverified calls. Relationships are limited to README statements and visible source-index references; unsampled implementation details are not treated as inspected.

Main entry points: [`grblHAL_Teensy4/src/grbl/gcode.c`](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/gcode.c) (G-code interpreter), [`grblHAL_Teensy4/src/grbl/grblHALCutterComp/cutter_comp.c`](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/grblHALCutterComp/cutter_comp.c) (Cutter compensation), [`grblHAL_Teensy4/src/webui/fs_handlers.c`](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/webui/fs_handlers.c) (Web file handlers), [`grblHAL_Teensy4/src/main.c`](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/main.c) (Firmware entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_motion["CNC motion"]
  node_gcode["G-code interpreter<br/>[gcode.c]"]
  node_cutter["Cutter compensation<br/>[cutter_comp.c]"]
  node_motion_control["Motion control<br/>[motion_control.c]"]
  node_planner["Motion planner<br/>[planner.c]"]
  node_stepper["Stepper execution<br/>[stepper.c]"]
end

subgraph group_core["Controller core"]
  node_protocol["Execution protocol<br/>[protocol.c]"]
  node_state["Machine state<br/>[state_machine.c]"]
  node_settings["Settings<br/>[settings.c]"]
  node_report["Reports<br/>[report.c]"]
  node_main["Firmware entry<br/>[main.c]"]
  node_library["grblHAL core library<br/>[grbllib.c]"]
end

subgraph group_platform["Teensy platform"]
  node_hal["Hardware interface<br/>[hal.h]"]
  node_driver["Teensy driver<br/>[driver.h]"]
end

subgraph group_services["Interfaces and services"]
  node_storage["Virtual filesystem<br/>[vfs.h]"]
  node_webui["Web UI backend<br/>[server.c]"]
  node_web_files["Web file handlers<br/>[fs_handlers.c]"]
  node_network["Networking<br/>[networking.c]"]
  node_modbus["Modbus TCP client<br/>[client.c]"]
end

node_operator(("CNC operator"))

node_operator -.->|"provides program"| node_gcode
node_gcode -.->|"uses compensation"| node_cutter
node_cutter -.->|"adjusts motion"| node_motion_control
node_main -->|"calls"| node_library
node_webui -->|"uses handlers"| node_web_files
node_web_files -->|"uses VFS"| node_storage
node_modbus -->|"uses networking"| node_network

click node_gcode "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/gcode.c"
click node_cutter "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/grblHALCutterComp/cutter_comp.c"
click node_motion_control "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/motion_control.c"
click node_planner "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/planner.c"
click node_stepper "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/stepper.c"
click node_protocol "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/protocol.c"
click node_state "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/state_machine.c"
click node_settings "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/settings.c"
click node_report "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/report.c"
click node_hal "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/hal.h"
click node_driver "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/driver.h"
click node_storage "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/vfs.h"
click node_webui "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/webui/server.c"
click node_web_files "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/webui/fs_handlers.c"
click node_network "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/networking/networking.c"
click node_modbus "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/networking/modbus/client.c"
click node_main "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/main.c"
click node_library "https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/grbllib.c"

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_gcode,node_cutter,node_motion_control,node_planner,node_stepper toneBlue
class node_protocol,node_state,node_settings,node_report,node_main,node_library toneAmber
class node_hal,node_driver toneMint
class node_storage,node_webui,node_web_files,node_network,node_modbus toneRose
class node_operator toneIndigo
```

## Components

### CNC motion

- [G-code interpreter](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/gcode.c): `grblHAL_Teensy4/src/grbl/gcode.c`
- [Cutter compensation](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/grblHALCutterComp/cutter_comp.c): `grblHAL_Teensy4/src/grbl/grblHALCutterComp/cutter_comp.c`
- [Motion control](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/motion_control.c): `grblHAL_Teensy4/src/grbl/motion_control.c`
- [Motion planner](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/planner.c): `grblHAL_Teensy4/src/grbl/planner.c`
- [Stepper execution](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/stepper.c): `grblHAL_Teensy4/src/grbl/stepper.c`

### Controller core

- [Execution protocol](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/protocol.c): `grblHAL_Teensy4/src/grbl/protocol.c`
- [Machine state](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/state_machine.c): `grblHAL_Teensy4/src/grbl/state_machine.c`
- [Settings](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/settings.c): `grblHAL_Teensy4/src/grbl/settings.c`
- [Reports](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/report.c): `grblHAL_Teensy4/src/grbl/report.c`
- [Firmware entry](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/main.c): `grblHAL_Teensy4/src/main.c`
- [grblHAL core library](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/grbllib.c): `grblHAL_Teensy4/src/grbl/grbllib.c`

### Teensy platform

- [Hardware interface](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/hal.h): `grblHAL_Teensy4/src/grbl/hal.h`
- [Teensy driver](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/driver.h): `grblHAL_Teensy4/src/driver.h`

### Interfaces and services

- [Virtual filesystem](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/grbl/vfs.h): `grblHAL_Teensy4/src/grbl/vfs.h`
- [Web UI backend](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/webui/server.c): `grblHAL_Teensy4/src/webui/server.c`
- [Web file handlers](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/webui/fs_handlers.c): `grblHAL_Teensy4/src/webui/fs_handlers.c`
- [Networking](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/networking/networking.c): `grblHAL_Teensy4/src/networking/networking.c`
- [Modbus TCP client](https://github.com/khayreddine-zomita/grblhal-cutter-compensation/blob/main/grblHAL_Teensy4/src/networking/modbus/client.c): `grblHAL_Teensy4/src/networking/modbus/client.c`

### Other components

- **CNC operator**

## Connections

- CNC operator → G-code interpreter: provides program
- G-code interpreter → Cutter compensation: uses compensation
- Cutter compensation → Motion control: adjusts motion
- Firmware entry → grblHAL core library: calls (evidence: `grblHAL_Teensy4/src/main.c`)
- Web UI backend → Web file handlers: uses handlers (evidence: `grblHAL_Teensy4/src/webui/server.c`)
- Web file handlers → Virtual filesystem: uses VFS (evidence: `grblHAL_Teensy4/src/webui/fs_handlers.c`)
- Modbus TCP client → Networking: uses networking (evidence: `grblHAL_Teensy4/src/networking/modbus/client.c`)
