# rhalkyard/hpplot architecture

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

- Interactive diagram: https://gitdiagram.com/rhalkyard/hpplot
- Repository: https://github.com/rhalkyard/hpplot

## Overview

hpplot is a command-line sender for HPGL files, with optional stream rewriting and several plotter flow-control modes. The main workflow parses options, reads and filters the file, configures the serial connection, sends blocks while tracking progress, and resets the plotter connection afterward. The implementation is concentrated in one source file, so several responsibilities share that path. The graph is based on the supplied excerpt and README; no separate filter or transport modules are present.

Main entry points: [`hpplot/__main__.py`](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py) (CLI entrypoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["CLI workflow"]
  node_cli["CLI entrypoint<br/>[__main__.py]"]
  node_input["HPGL input"]
  node_progress["Progress display<br/>[__main__.py]"]
end

subgraph group_processing["HPGL processing"]
  node_stream["Stream cleanup<br/>[__main__.py]"]
  node_rewrite["Command rewriting<br/>[__main__.py]"]
end

subgraph group_transport["Plotter transport"]
  node_flow_config["Flow setup<br/>[__main__.py]"]
  node_block_send["Block transfer<br/>[__main__.py]"]
  node_buffer_query["Buffer query<br/>[__main__.py]"]
  node_recovery["Abort and reset<br/>[__main__.py]"]
end

node_user(("User"))
node_serial["Serial port"]
node_plotter(("HPGL plotter"))
node_terminal(("Terminal"))

node_user -->|"provides options"| node_cli
node_input -->|"provides file"| node_cli
node_cli -->|"reads and cleans"| node_stream
node_cli -->|"applies options"| node_rewrite
node_cli -->|"opens port"| node_serial
node_cli -->|"selects mode"| node_flow_config
node_flow_config -->|"configures"| node_serial
node_cli -->|"sends blocks"| node_block_send
node_block_send -->|"writes HPGL"| node_plotter
node_block_send -->|"queries space"| node_buffer_query
node_buffer_query -->|"reads and writes"| node_serial
node_serial -->|"communicates"| node_plotter
node_cli -->|"updates display"| node_progress
node_progress -->|"prints status"| node_terminal
node_cli -->|"handles interrupt"| node_recovery
node_recovery -->|"aborts and resets"| node_serial

click node_cli "https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py"
click node_stream "https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py"
click node_rewrite "https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py"
click node_flow_config "https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py"
click node_block_send "https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py"
click node_buffer_query "https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py"
click node_progress "https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py"
click node_recovery "https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.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_cli,node_input,node_progress,node_user toneBlue
class node_stream,node_rewrite toneAmber
class node_flow_config,node_block_send,node_buffer_query,node_recovery toneMint
class node_serial,node_plotter,node_terminal toneIndigo
```

## Components

### CLI workflow

- [CLI entrypoint](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py): `hpplot/__main__.py`
- **HPGL input**
- [Progress display](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py): `hpplot/__main__.py`

### HPGL processing

- [Stream cleanup](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py): `hpplot/__main__.py`
- [Command rewriting](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py): `hpplot/__main__.py`

### Plotter transport

- [Flow setup](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py): `hpplot/__main__.py`
- [Block transfer](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py): `hpplot/__main__.py`
- [Buffer query](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py): `hpplot/__main__.py`
- [Abort and reset](https://github.com/rhalkyard/hpplot/blob/main/hpplot/__main__.py): `hpplot/__main__.py`

### Other components

- **User**
- **Serial port**
- **HPGL plotter**
- **Terminal**

## Connections

- User → CLI entrypoint: provides options (evidence: `README.md`)
- HPGL input → CLI entrypoint: provides file (evidence: `README.md`)
- CLI entrypoint → Stream cleanup: reads and cleans (evidence: `hpplot/__main__.py`)
- CLI entrypoint → Command rewriting: applies options (evidence: `hpplot/__main__.py`)
- CLI entrypoint → Serial port: opens port (evidence: `hpplot/__main__.py`)
- CLI entrypoint → Flow setup: selects mode (evidence: `hpplot/__main__.py`)
- Flow setup → Serial port: configures (evidence: `hpplot/__main__.py`)
- CLI entrypoint → Block transfer: sends blocks (evidence: `hpplot/__main__.py`)
- Block transfer → HPGL plotter: writes HPGL (evidence: `hpplot/__main__.py`)
- Block transfer → Buffer query: queries space (evidence: `hpplot/__main__.py`)
- Buffer query → Serial port: reads and writes (evidence: `hpplot/__main__.py`)
- Serial port → HPGL plotter: communicates (evidence: `README.md`)
- CLI entrypoint → Progress display: updates display (evidence: `hpplot/__main__.py`)
- Progress display → Terminal: prints status (evidence: `hpplot/__main__.py`)
- CLI entrypoint → Abort and reset: handles interrupt (evidence: `hpplot/__main__.py`)
- Abort and reset → Serial port: aborts and resets (evidence: `hpplot/__main__.py`)
