# michaelrsweet/hp-printer-app architecture

> Architecture diagram of the GitHub repository michaelrsweet/hp-printer-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/michaelrsweet/hp-printer-app
- Repository: https://github.com/michaelrsweet/hp-printer-app

## Overview

#### Purpose and Entry Points
`hp-printer-app` is a native C printer application for network- and USB-connected PCL printers. One executable provides both a long-running IPP print service and command-line administration/submission commands. Primary runtime entry point: `hp-printer-app.c`. A separate diagnostic/conversion utility for experimental PCL 6 handling is implemented in `decode-pcl6.c`.

#### Application Control Plane
The executable dispatches subcommands for printer lifecycle management, job management, status, discovery, driver listing, client-side submission, and server startup. In server mode it hosts multiple printer queues; in CLI mode it acts as the management/client interface to that service. The central control boundary is therefore between local command invocation and the running printer-application server, both implemented by `hp-printer-app.c`.

Paths:
- `hp-printer-app.c`
- `hp-printer-app.1`

#### Print-Service and Job Pipeline
PAPPL supplies the printer-application framework: IPP Everywhere queue exposure, job spooling/lifecycle, printer state reporting, and web/service integration. The application configures printer capabilities and sends supported document forms—raw PCL, Apple/PWG Raster, and PNG—to physical devices. Printer communication spans network and raw USB transports, with recovery expected for media, power, and connection faults.

Paths:
- `hp-printer-app.c`
- `decode-pcl6.c`

#### Protocol and Device Boundary
The outward-facing protocol is IPP Everywhere, allowing driverless clients across major desktop and mobile platforms. The inward-facing boundary is PCL-capable hardware, including PCL 5 printers and experimental PCL 6 devices. CUPS `libcups` is a material dependency for IPP/client operations, while PAPPL is the server and printer-application runtime.

Paths:
- `hp-printer-app.c`
- `decode-pcl6.c`

#### Platform Service Integration
Linux deployment is designed for a system service and Snap confinement. The Snap package includes a server launcher and configuration hook, and requires raw-USB access when managing USB devices. macOS packages include a native app bundle definition, entitlement file, icon resources, and launch-agent plist integration; the macOS application exposes menu-bar access to the web interface and printers.

Paths:
- `hp-printer-app.service.in`
- `snap/snapcraft.yaml`
- `snap/local/scripts/hp-printer-app-server`
- `hp-printer-app.plist.in`
- `hp-printer-app.entitlements`

#### Build and Distribution Boundary
The project uses an Autoconf-style portable native build: `configure` generates build settings consumed by `Makefile.in`. The required compilation/runtime ecosystem is POSIX make, a C99 compiler, PAPPL 1.2+, and CUPS 2.4+. Source releases, Linux Snap packaging, system service installation, and macOS packaging are distinct distribution paths around the same executable.

Paths:
- `configure`
- `Makefile.in`
- `snap/snapcraft.yaml`
- `macos-scripts/postinstall`

Main entry points: [`hp-printer-app.c`](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c) (hp-printer-app), [`snap/snapcraft.yaml`](https://github.com/michaelrsweet/hp-printer-app/blob/master/snap/snapcraft.yaml) (Snap package), [`Makefile.in`](https://github.com/michaelrsweet/hp-printer-app/blob/master/Makefile.in) (Makefile template), [`snap/local/scripts/hp-printer-app-server`](https://github.com/michaelrsweet/hp-printer-app/blob/master/snap/local/scripts/hp-printer-app-server) (Server launcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Print Runtime"]
  node_app["hp-printer-app<br/>C application<br/>[hp-printer-app.c]"]
  node_cli["CLI commands<br/>control plane<br/>[hp-printer-app.c]"]
  node_server["IPP print service<br/>server mode<br/>[hp-printer-app.c]"]
  node_queues["Printer queues<br/>job pipeline<br/>[hp-printer-app.c]"]
  node_pappl["PAPPL<br/>printer framework"]
  node_libcups["libcups<br/>IPP client library"]
  node_manual["Manual page<br/>CLI documentation<br/>[hp-printer-app.1]"]
end

subgraph group_devices["Protocol &amp; Devices"]
  node_ipp_clients["Driverless clients<br/>IPP Everywhere clients"]
  node_transports["Network &amp; raw USB<br/>device transport<br/>[hp-printer-app.c]"]
  node_printers["PCL printers<br/>physical hardware"]
  node_pcl6_tool["PCL 6 decoder<br/>diagnostic utility<br/>[decode-pcl6.c]"]
end

subgraph group_build["Build &amp; Distribution"]
  node_configure["configure<br/>Autoconf configuration"]
  node_makefile["Makefile template<br/>native build<br/>[Makefile.in]"]
end

subgraph group_platform["Platform Integration"]
  node_linux_service["System service<br/>Linux service unit"]
  node_snap["Snap package<br/>Linux distribution<br/>[snapcraft.yaml]"]
  node_snap_launcher["Server launcher<br/>Snap launcher"]
  node_macos_plist["Launch agent<br/>macOS integration"]
  node_entitlements["macOS entitlements<br/>package permissions"]
  node_postinstall["macOS postinstall<br/>package installer"]
end

node_app -->|"dispatches"| node_cli
node_app -->|"starts"| node_server
node_cli -->|"administers / submits to"| node_server
node_server -->|"hosts"| node_queues
node_pappl -->|"runtime for"| node_server
node_pappl -->|"spools and tracks"| node_queues
node_ipp_clients -->|"IPP Everywhere"| node_server
node_libcups -->|"IPP operations"| node_app
node_queues -->|"sends documents"| node_transports
node_transports -->|"connects"| node_printers
node_pcl6_tool -.->|"diagnoses PCL 6"| node_printers
node_configure -->|"generates settings for"| node_makefile
node_makefile -->|"builds"| node_app
node_linux_service -->|"runs"| node_app
node_snap -->|"packages"| node_snap_launcher
node_snap_launcher -->|"starts server"| node_app
node_snap -.->|"distributes"| node_app
node_macos_plist -->|"launches"| node_app
node_entitlements -.->|"authorizes"| node_app
node_postinstall -->|"installs"| node_macos_plist
node_manual -.->|"documents"| node_cli

click node_app "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c"
click node_cli "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c"
click node_server "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c"
click node_queues "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c"
click node_transports "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c"
click node_pcl6_tool "https://github.com/michaelrsweet/hp-printer-app/blob/master/decode-pcl6.c"
click node_configure "https://github.com/michaelrsweet/hp-printer-app/blob/master/configure"
click node_makefile "https://github.com/michaelrsweet/hp-printer-app/blob/master/Makefile.in"
click node_linux_service "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.service.in"
click node_snap "https://github.com/michaelrsweet/hp-printer-app/blob/master/snap/snapcraft.yaml"
click node_snap_launcher "https://github.com/michaelrsweet/hp-printer-app/blob/master/snap/local/scripts/hp-printer-app-server"
click node_macos_plist "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.plist.in"
click node_entitlements "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.entitlements"
click node_postinstall "https://github.com/michaelrsweet/hp-printer-app/blob/master/macos-scripts/postinstall"
click node_manual "https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.1"

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_app,node_cli,node_server,node_queues,node_pappl,node_libcups,node_manual toneBlue
class node_ipp_clients,node_transports,node_printers,node_pcl6_tool toneAmber
class node_configure,node_makefile toneMint
class node_linux_service,node_snap,node_snap_launcher,node_macos_plist,node_entitlements,node_postinstall toneRose
```

## Components

### Print Runtime

- [hp-printer-app](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c): C application · Single executable for service, administration, and submission. · `hp-printer-app.c`
- [CLI commands](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c): control plane · Manages printers and jobs or submits work to the service. · `hp-printer-app.c`
- [IPP print service](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c): server mode · Hosts multiple printer queues. · `hp-printer-app.c`
- [Printer queues](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c): job pipeline · Accepts raw PCL, Apple/PWG Raster, and PNG jobs. · `hp-printer-app.c`
- **PAPPL**: printer framework · Provides queue exposure, spooling, lifecycle, and printer state.
- **libcups**: IPP client library
- [Manual page](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.1): CLI documentation · `hp-printer-app.1`

### Protocol & Devices

- **Driverless clients**: IPP Everywhere clients
- [Network & raw USB](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.c): device transport · Connects printers and supports fault recovery. · `hp-printer-app.c`
- **PCL printers**: physical hardware · PCL 5 devices and experimental PCL 6 devices.
- [PCL 6 decoder](https://github.com/michaelrsweet/hp-printer-app/blob/master/decode-pcl6.c): diagnostic utility · Experimental PCL 6 conversion and diagnostics. · `decode-pcl6.c`

### Build & Distribution

- [configure](https://github.com/michaelrsweet/hp-printer-app/blob/master/configure): Autoconf configuration · `configure`
- [Makefile template](https://github.com/michaelrsweet/hp-printer-app/blob/master/Makefile.in): native build · Consumes generated build settings. · `Makefile.in`

### Platform Integration

- [System service](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.service.in): Linux service unit · `hp-printer-app.service.in`
- [Snap package](https://github.com/michaelrsweet/hp-printer-app/blob/master/snap/snapcraft.yaml): Linux distribution · Defines confined deployment and raw-USB access. · `snap/snapcraft.yaml`
- [Server launcher](https://github.com/michaelrsweet/hp-printer-app/blob/master/snap/local/scripts/hp-printer-app-server): Snap launcher · `snap/local/scripts/hp-printer-app-server`
- [Launch agent](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.plist.in): macOS integration · Provides menu-bar access to the web interface and printers. · `hp-printer-app.plist.in`
- [macOS entitlements](https://github.com/michaelrsweet/hp-printer-app/blob/master/hp-printer-app.entitlements): package permissions · `hp-printer-app.entitlements`
- [macOS postinstall](https://github.com/michaelrsweet/hp-printer-app/blob/master/macos-scripts/postinstall): package installer · `macos-scripts/postinstall`

## Connections

- hp-printer-app → CLI commands: dispatches
- hp-printer-app → IPP print service: starts
- CLI commands → IPP print service: administers / submits to
- IPP print service → Printer queues: hosts
- PAPPL → IPP print service: runtime for
- PAPPL → Printer queues: spools and tracks
- Driverless clients → IPP print service: IPP Everywhere
- libcups → hp-printer-app: IPP operations
- Printer queues → Network & raw USB: sends documents
- Network & raw USB → PCL printers: connects
- PCL 6 decoder → PCL printers: diagnoses PCL 6
- configure → Makefile template: generates settings for
- Makefile template → hp-printer-app: builds
- System service → hp-printer-app: runs
- Snap package → Server launcher: packages
- Server launcher → hp-printer-app: starts server
- Snap package → hp-printer-app: distributes
- Launch agent → hp-printer-app: launches
- macOS entitlements → hp-printer-app: authorizes
- macOS postinstall → Launch agent: installs
- Manual page → CLI commands: documents
