# openprinting/hplip-printer-app architecture

> Architecture diagram of the GitHub repository openprinting/hplip-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/openprinting/hplip-printer-app
- Repository: https://github.com/openprinting/hplip-printer-app

## Overview

#### Purpose and entry points
This is a C-based IPP Printer Application that exposes HPLIP-supported HP/Apollo printers as driverless IPP printers while internally retaining HPLIP’s PPD, filter, and backend stack. The executable and main integration point are `hplip-printer-app.c` and its installed service definition `hplip-printer-app.service`. It runs as an interactive CLI/server and provides PAPPL’s web administration UI, normally on port 8000.

#### Application host and printer model integration
`hplip-printer-app.c` configures PAPPL and pappl-retrofit to turn classic HPLIP PPD drivers into a long-running Printer Application. HPLIP PPDs supply supported-model metadata, capabilities, and vendor options; only `hpcups` PPDs are relevant. At runtime, PPD lookup can be overridden with `PPD_PATHS`, separating application logic from packaged or local driver assets.
Grounding: `hplip-printer-app.c`, `Makefile`, `testpage.ps`.

#### Job processing pipeline
Clients submit IPP jobs—directly or through CUPS/cups-browsed—to PAPPL. pappl-retrofit maps IPP attributes to PPD options, including algorithmic selection of color, quality, and content-optimization settings. PDF/PostScript is rendered through Ghostscript when needed; raster inputs are adapted to the printer color space/resolution and passed to HPLIP’s `hpcups` filter. HPLIP’s `hp` backend delivers the resulting job to hardware.
Grounding: `hplip-printer-app.c`, `Makefile`.

#### Discovery and device-transport boundary
HPLIP discovery is intentionally separate from PAPPL: the `hp` CUPS backend handles USB discovery and communication, while the `HP` wrapper makes HPLIP’s `hp-probe` behave like a discovery-only CUPS backend for network devices. CUPS standard backends are also exposed as alternatives, enabling USB quirks plus socket, IPP/IPPS, LPD, and configurable SNMP paths. The HPLIP backend is important for IEEE-1284.4 USB behavior and special device functions.
Grounding: `HP`, `hplip-printer-app.c`, `scripts/run-avahi.sh`.

#### Service lifecycle and deployment wrappers
The system service starts the application as a server daemon. Snap-specific launch wrappers distinguish normal application execution from server startup. The container startup script selects an optional `PORT`; persistent application state is mounted externally, and host networking/USB access are required for full network discovery and USB printing.
Grounding: `hplip-printer-app.service`, `snap/local/run-hplip-printer-app`, `snap/local/run-hplip-printer-app-server`, `scripts/start-server.sh`.

#### Packaging and runtime infrastructure
Two deployable runtimes are defined: Snap and OCI Rock. `snap/snapcraft.yaml` assembles the confined Snap, including HPLIP sourced from Debian packaging; `rockcraft.yaml` builds the OCI image. Both package or depend on PAPPL, pappl-retrofit, cups-filters/libppd, CUPS backends, Ghostscript, and HPLIP. Local patches adjust CUPS DNS-SD socket behavior and HPLIP plugin/library loading for packaged environments.
Grounding: `snap/snapcraft.yaml`, `rockcraft.yaml`, `patches/cups-dnssd-backend-socket-only.patch`, `patches/hplip-plugin-firmware-load-path.patch`.

#### External services and extension points
PAPPL provides IPP, web UI, and printer-application lifecycle; Avahi/DNS-SD supports service/discovery networking; HPLIP provides driver, PPD, discovery, transport, and optional proprietary-plugin support. The app can install HPLIP’s proprietary plugin through its UI, enabling firmware-dependent or proprietary-format printers. CI, automated dependency/version updates, and registry publication are implemented through GitHub Actions.
Grounding: `.github/workflows/ci.yml`, `.github/workflows/auto-update.yml`, `.github/workflows/registry-actions.yml`.

Main entry points: [`hplip-printer-app.c`](https://github.com/openprinting/hplip-printer-app/blob/master/hplip-printer-app.c) (HPLIP Printer App), [`.github/workflows/ci.yml`](https://github.com/openprinting/hplip-printer-app/blob/master/.github/workflows/ci.yml) (CI & Registry Publishing), [`snap/snapcraft.yaml`](https://github.com/openprinting/hplip-printer-app/blob/master/snap/snapcraft.yaml) (Snap Runtime), [`rockcraft.yaml`](https://github.com/openprinting/hplip-printer-app/blob/master/rockcraft.yaml) (OCI Rock Runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Printer Application"]
  node_app["HPLIP Printer App<br/>C application"]
  node_pappl{{"PAPPL<br/>printer app framework"}}
  node_retrofit["pappl-retrofit<br/>PPD bridge"]
  node_ppds["hpcups PPDs<br/>driver metadata"]
end

subgraph group_pipeline["Job Processing"]
  node_option_mapping["IPP-to-PPD Mapping<br/>job option selection"]
  node_rendering["Ghostscript Rendering<br/>renderer"]
  node_raster_adaptation["Raster Adaptation<br/>raster conversion"]
  node_hpcups["hpcups Filter<br/>HPLIP filter"]
end

subgraph group_transport["Discovery &amp; Transport"]
  node_hp_backend["hp Backend<br/>HPLIP backend"]
  node_hp_wrapper["HP Discovery Wrapper<br/>CUPS backend wrapper"]
  node_cups_backends["CUPS Backends<br/>transport alternatives"]
  node_avahi{{"Avahi / DNS-SD<br/>service discovery<br/>[run-avahi.sh]"}}
end

subgraph group_deployment["Deployment"]
  node_systemd_service["System Service<br/>systemd unit"]
  node_snap_runtime["Snap Runtime<br/>confined package<br/>[snapcraft.yaml]"]
  node_oci_runtime["OCI Rock Runtime<br/>container image<br/>[rockcraft.yaml]"]
  node_ci_release["CI &amp; Registry Publishing<br/>GitHub Actions<br/>[ci.yml]"]
end

node_ipp_clients(("IPP Clients<br/>external clients"))
node_printers(("HP/Apollo Printers<br/>hardware"))

node_systemd_service -->|"starts"| node_app
node_snap_runtime -->|"launches"| node_app
node_oci_runtime -->|"runs"| node_app
node_ipp_clients -->|"submits IPP jobs"| node_pappl
node_app -->|"configures"| node_pappl
node_app -->|"integrates"| node_retrofit
node_retrofit -->|"reads capabilities"| node_ppds
node_pappl -->|"dispatches jobs"| node_option_mapping
node_retrofit -->|"maps attributes"| node_option_mapping
node_option_mapping -->|"PDF/PostScript"| node_rendering
node_option_mapping -->|"raster input"| node_raster_adaptation
node_rendering -->|"produces raster"| node_raster_adaptation
node_raster_adaptation -->|"printer-ready raster"| node_hpcups
node_hpcups -->|"sends job"| node_hp_backend
node_hp_backend -->|"USB/device delivery"| node_printers
node_hp_wrapper -->|"uses hp-probe"| node_hp_backend
node_cups_backends -->|"network transports"| node_printers
node_pappl -->|"advertises services"| node_avahi
node_ci_release -->|"builds/publishes"| node_snap_runtime
node_ci_release -->|"builds/publishes"| node_oci_runtime

click node_app "https://github.com/openprinting/hplip-printer-app/blob/master/hplip-printer-app.c"
click node_hp_wrapper "https://github.com/openprinting/hplip-printer-app/blob/master/HP"
click node_avahi "https://github.com/openprinting/hplip-printer-app/blob/master/scripts/run-avahi.sh"
click node_systemd_service "https://github.com/openprinting/hplip-printer-app/blob/master/hplip-printer-app.service"
click node_snap_runtime "https://github.com/openprinting/hplip-printer-app/blob/master/snap/snapcraft.yaml"
click node_oci_runtime "https://github.com/openprinting/hplip-printer-app/blob/master/rockcraft.yaml"
click node_ci_release "https://github.com/openprinting/hplip-printer-app/blob/master/.github/workflows/ci.yml"

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_pappl,node_retrofit,node_ppds toneBlue
class node_option_mapping,node_rendering,node_raster_adaptation,node_hpcups toneAmber
class node_hp_backend,node_hp_wrapper,node_cups_backends,node_avahi toneMint
class node_systemd_service,node_snap_runtime,node_oci_runtime,node_ci_release toneRose
class node_ipp_clients,node_printers toneNeutral
```

## Components

### Printer Application

- [HPLIP Printer App](https://github.com/openprinting/hplip-printer-app/blob/master/hplip-printer-app.c): C application · Long-running driverless IPP printer application. · `hplip-printer-app.c`
- **PAPPL**: printer app framework · Provides IPP, web administration, and lifecycle.
- **pappl-retrofit**: PPD bridge · Adapts classic PPD drivers to IPP printers.
- **hpcups PPDs**: driver metadata · Model capabilities and vendor options; lookup supports PPD_PATHS.

### Job Processing

- **IPP-to-PPD Mapping**: job option selection · Selects color, quality, and content optimization.
- **Ghostscript Rendering**: renderer · Renders PDF/PostScript when required.
- **Raster Adaptation**: raster conversion · Matches printer color space and resolution.
- **hpcups Filter**: HPLIP filter · Processes raster jobs using HPLIP driver logic.

### Discovery & Transport

- **hp Backend**: HPLIP backend · Handles USB discovery, special functions, and delivery.
- [HP Discovery Wrapper](https://github.com/openprinting/hplip-printer-app/blob/master/HP): CUPS backend wrapper · Exposes hp-probe as network discovery only. · `HP`
- **CUPS Backends**: transport alternatives · Supports socket, IPP/IPPS, LPD, and SNMP paths.
- [Avahi / DNS-SD](https://github.com/openprinting/hplip-printer-app/blob/master/scripts/run-avahi.sh): service discovery · `scripts/run-avahi.sh`

### Deployment

- [System Service](https://github.com/openprinting/hplip-printer-app/blob/master/hplip-printer-app.service): systemd unit · Starts the application as a server daemon. · `hplip-printer-app.service`
- [Snap Runtime](https://github.com/openprinting/hplip-printer-app/blob/master/snap/snapcraft.yaml): confined package · Uses separate normal and server launch wrappers. · `snap/snapcraft.yaml`
- [OCI Rock Runtime](https://github.com/openprinting/hplip-printer-app/blob/master/rockcraft.yaml): container image · Supports PORT selection and externally mounted state. · `rockcraft.yaml`
- [CI & Registry Publishing](https://github.com/openprinting/hplip-printer-app/blob/master/.github/workflows/ci.yml): GitHub Actions · Builds, updates dependencies, and publishes artifacts. · `.github/workflows/ci.yml`

### Other components

- **IPP Clients**: external clients · Direct clients or CUPS/cups-browsed submit jobs.
- **HP/Apollo Printers**: hardware

## Connections

- System Service → HPLIP Printer App: starts
- Snap Runtime → HPLIP Printer App: launches
- OCI Rock Runtime → HPLIP Printer App: runs
- IPP Clients → PAPPL: submits IPP jobs
- HPLIP Printer App → PAPPL: configures
- HPLIP Printer App → pappl-retrofit: integrates
- pappl-retrofit → hpcups PPDs: reads capabilities
- PAPPL → IPP-to-PPD Mapping: dispatches jobs
- pappl-retrofit → IPP-to-PPD Mapping: maps attributes
- IPP-to-PPD Mapping → Ghostscript Rendering: PDF/PostScript
- IPP-to-PPD Mapping → Raster Adaptation: raster input
- Ghostscript Rendering → Raster Adaptation: produces raster
- Raster Adaptation → hpcups Filter: printer-ready raster
- hpcups Filter → hp Backend: sends job
- hp Backend → HP/Apollo Printers: USB/device delivery
- HP Discovery Wrapper → hp Backend: uses hp-probe
- CUPS Backends → HP/Apollo Printers: network transports
- PAPPL → Avahi / DNS-SD: advertises services
- CI & Registry Publishing → Snap Runtime: builds/publishes
- CI & Registry Publishing → OCI Rock Runtime: builds/publishes
