# rlmeeson/wkhtmltopdf-packaging architecture

> Architecture diagram of the GitHub repository rlmeeson/wkhtmltopdf-packaging, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rlmeeson/wkhtmltopdf-packaging
- Repository: https://github.com/rlmeeson/wkhtmltopdf-packaging

## Overview

##### Project type and purpose
- This is a tooling repository that automates building and packaging of wkhtmltopdf across multiple platforms.
- It decouples packaging logic from releases, using containers (Docker) and VMs (Vagrant) to produce reproducible artifacts.
- CI/CD is orchestrated via Azure Pipelines and GitHub Actions for release workflows.

##### File structure
- CI/CD configs at top level:
- .azure-pipelines.yml – Azure build definitions
- .github/workflows/release.yml – GitHub Actions release pipeline
- Dependency management:
- .conan/ – conan client configuration and profiles for each target platform
- conanfile.txt – declares external libraries (e.g., patched Qt)
- Build orchestrator:
- build (executable shell or Python wrapper)
- build.yml – YAML configuration of build targets and their parameters
- Packaging and post-build:
- after_compile/amazonlinux2_lambda.sh – post-processing for specific targets
- Multi-platform definitions:
- docker/ – Dockerfiles for Linux distributions and cross-compile images
- vagrant/ – Vagrantfile plus platform plugins (macos.py, windows.py) for non-Linux targets
- Versioning and automation:
- build scripts generate version numbers from git commits, iteration flags for filename variations

##### README insights
- Workflows:
- `build package-docker` – runs Docker container builds
- `build vagrant` – provisions VMs, rsyncs code, executes conan and compilation inside VM
- QEMU for cross-arch emulation in Docker, configurable via --no-qemu / --use-qemu
- Output artifacts are placed in a “targets” folder for later consumption

a. Main components
- CI/CD orchestrator (Azure Pipelines + GitHub Actions)
- Build orchestrator (build script + build.yml)
- Dependency manager (Conan + profiles)
- Docker build subsystem (docker/ Dockerfiles + QEMU integration)
- Vagrant build subsystem (Vagrant core + platform plugins under vagrant/)
- Post-build handlers (after_compile scripts)
- Artifact repository (targets folder, release workflow)

b. Relationships and interactions
- CI/CD initiates the build orchestrator
- Build orchestrator reads build.yml and conanfile.txt, loads conan profiles
- For Linux targets: orchestrator calls Docker subsystem → container spins up → conan installs deps → compile & package → outputs to host targets folder
- For non-Linux targets: orchestrator calls Vagrant subsystem → VM is provisioned → code rsync → conan + Qt build inside VM → package → host targets folder
- Post-build handlers run after compile phase to tweak or wrap outputs
- CI/CD then picks artifacts and pushes to release channel

c. Architectural patterns & design principles
- Separation of concerns: packaging logic is separate from application source
- Plugin-like architecture for Vagrant targets (prepare_build, package_build)
- Declarative config: build.yml defines targets, conan profiles abstract dependencies
- Immutable build environments: containers/VMs ensure reproducible outputs

d. Key technologies, frameworks, libraries
- Python & shell build scripts
- Conan package manager
- Docker & QEMU for containerized cross-compilation
- Vagrant + VirtualBox for VM-based builds
- fpm (optionally) for distro packaging
- Azure Pipelines & GitHub Actions for CI/CD

##### Detail
- That Vagrant plugins implement a common interface with prepare_build and package_build
- QEMU integration as a conditional component within the Docker subsystem
- That build.yml drives both subsystems via named targets (e.g., buster-amd64, macos, windows)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration Layer
    CICD_AZ["Azure Pipelines"]:::orchestration
    CICD_GH["GitHub Actions"]:::orchestration
    BuildScript["Build Script (build)"]:::orchestration
    BuildConfig["Build Config (build.yml)"]:::orchestration
    Release["Release Workflow"]:::orchestration

    %% Dependency Management
    ConanConfig["Conan Config (.conan/conan.conf)"]:::dep
    ConanProfiles["Conan Profiles (.conan/profiles/)"]:::dep
    ConanFile["Conanfile.txt"]:::dep

    %% Build Environments
    DockerSubsystem["Docker Subsystem"]:::buildenv
    QEMU["QEMU Integration"]:::buildenv

    VagrantSubsystem["Vagrant Subsystem"]:::buildenv
    Vagrantfile["Vagrantfile"]:::buildenv
    MacosPlugin["macOS Plugin (macos.py)"]:::buildenv
    WindowsPlugin["Windows Plugin (windows.py)"]:::buildenv
    NSIS["NSIS Script (wkhtmltox.nsi)"]:::buildenv

    %% Post-build and Artifacts
    PostHandler["Post-Build Handlers"]:::post
    ArtifactStore["Artifact Store (targets)"]:::post

    %% Connections
    CICD_AZ -->|triggers| BuildScript
    CICD_GH -->|triggers| BuildScript

    BuildScript -->|reads| BuildConfig
    BuildScript -->|reads| ConanConfig
    BuildScript -->|reads| ConanProfiles
    BuildScript -->|reads| ConanFile

    BuildScript -->|builds Linux targets| DockerSubsystem
    DockerSubsystem -->|uses| QEMU
    DockerSubsystem -->|outputs| PostHandler

    BuildScript -->|builds non-Linux targets| VagrantSubsystem
    VagrantSubsystem -->|configured by| Vagrantfile
    VagrantSubsystem -->|uses plugin| MacosPlugin
    VagrantSubsystem -->|uses plugin| WindowsPlugin
    VagrantSubsystem -->|uses| NSIS
    VagrantSubsystem -->|outputs| PostHandler

    PostHandler -->|places artifacts in| ArtifactStore
    ArtifactStore -->|feeds| Release

    %% Click Events
    click CICD_AZ "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/.azure-pipelines.yml"
    click CICD_GH "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/.github/workflows/release.yml"
    click BuildScript "https://github.com/rlmeeson/wkhtmltopdf-packaging/tree/master/build"
    click BuildConfig "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/build.yml"
    click ConanConfig "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/.conan/conan.conf"
    click ConanProfiles "https://github.com/rlmeeson/wkhtmltopdf-packaging/tree/master/.conan/profiles/"
    click ConanFile "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/conanfile.txt"
    click DockerSubsystem "https://github.com/rlmeeson/wkhtmltopdf-packaging/tree/master/docker/"
    click Vagrantfile "https://github.com/rlmeeson/wkhtmltopdf-packaging/tree/master/vagrant/Vagrantfile"
    click MacosPlugin "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/vagrant/macos.py"
    click WindowsPlugin "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/vagrant/windows.py"
    click NSIS "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/vagrant/wkhtmltox.nsi"
    click PostHandler "https://github.com/rlmeeson/wkhtmltopdf-packaging/blob/master/after_compile/amazonlinux2_lambda.sh"

    %% Styles
    classDef orchestration fill:#80BFFF,stroke:#333,stroke-width:1px
    classDef dep fill:#FFCC66,stroke:#333,stroke-width:1px
    classDef buildenv fill:#99FF99,stroke:#333,stroke-width:1px
    classDef post fill:#C0C0C0,stroke:#333,stroke-width:1px
```
