# gngram/ghaf architecture

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

- Interactive diagram: https://gitdiagram.com/gngram/ghaf
- Repository: https://github.com/gngram/ghaf

## Overview

Ghaf is a Nix-based framework for building compartmentalized, security-focused operating systems for edge devices. Its user-facing path is to select or extend a hardware configuration, build an image, then install or boot it. The tree also shows distinct security, VM, update, and network-boot capabilities. Relationships between most Nix subsystems could not be verified from the sampled source, so those links are dashed and have no evidence path; documented build and installation capabilities are cited to the README.

Main entry points: [`lib/builders`](https://github.com/gngram/ghaf/tree/main/lib/builders) (Image builders), [`modules/microvm`](https://github.com/gngram/ghaf/tree/main/modules/microvm) (MicroVM composition), [`targets`](https://github.com/gngram/ghaf/tree/main/targets) (Hardware targets), [`modules/reference`](https://github.com/gngram/ghaf/tree/main/modules/reference) (Reference configurations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_config["Configuration and builds"]
  node_targets["Hardware targets"]
  node_reference["Reference configurations"]
  node_builders["Image builders"]
end

subgraph group_runtime["VM and hardware"]
  node_common["Common system modules"]
  node_microvm["MicroVM composition"]
  node_hardware["Hardware support"]
  node_fakebattery["Fake battery driver<br/>[fake_battery.c]"]
  node_givc["GIVC integration"]
end

subgraph group_security["Security services"]
  node_securitymods["Security modules"]
  node_enrollment["Enrollment verifier"]
end

subgraph group_delivery["Image delivery"]
  node_installer["Installer"]
  node_bootcontents["ESP boot contents<br/>[mk-esp-contents.py]"]
  node_flashxml["Flash layout"]
  node_netboot["Netboot API"]
  node_manifest["Update manifests"]
end

subgraph group_tools["Runtime utilities"]
  node_greenprobe["GPU partition probe<br/>[runner.c]"]
  node_gpuload["GPU load smoke test<br/>[runner.c]"]
  node_openbrowser["Normal-browser extension<br/>[open_normal.js]"]
end

node_user(("System integrator"))

node_user -.->|"selects hardware"| node_targets
node_user -->|"builds images"| node_builders
node_user -->|"uses installer"| node_installer
node_targets -.->|"configures"| node_reference
node_reference -.->|"configures build"| node_builders
node_builders -.->|"composes VMs"| node_microvm
node_builders -.->|"configures system"| node_common
node_microvm -.->|"assigns devices"| node_hardware
node_common -.->|"applies security"| node_securitymods
node_hardware -.->|"includes driver"| node_fakebattery
node_microvm -.->|"integrates control"| node_givc
node_builders -.->|"prepares boot"| node_bootcontents
node_builders -.->|"prepares flashing"| node_flashxml
node_netboot -.->|"serves boot clients"| node_user

click node_targets "https://github.com/gngram/ghaf/tree/main/targets"
click node_reference "https://github.com/gngram/ghaf/tree/main/modules/reference"
click node_builders "https://github.com/gngram/ghaf/tree/main/lib/builders"
click node_common "https://github.com/gngram/ghaf/tree/main/modules/common"
click node_microvm "https://github.com/gngram/ghaf/tree/main/modules/microvm"
click node_hardware "https://github.com/gngram/ghaf/tree/main/modules/hardware"
click node_fakebattery "https://github.com/gngram/ghaf/blob/main/modules/hardware/x86_64-generic/kernel/modules/fake-battery/fake_battery.c"
click node_securitymods "https://github.com/gngram/ghaf/tree/main/modules/common/security"
click node_givc "https://github.com/gngram/ghaf/tree/main/modules/givc"
click node_installer "https://github.com/gngram/ghaf/tree/main/packages/pkgs-by-name/ghaf-installer"
click node_bootcontents "https://github.com/gngram/ghaf/blob/main/modules/reference/hardware/jetpack/nvidia-jetson-orin/mk-esp-contents.py"
click node_flashxml "https://github.com/gngram/ghaf/blob/main/modules/reference/hardware/jetpack/nvidia-jetson-orin/splice-flash-xml.py"
click node_netboot "https://github.com/gngram/ghaf/blob/main/packages/pkgs-by-name/ghaf-netboot/ghaf-netboot-api.py"
click node_manifest "https://github.com/gngram/ghaf/blob/main/packages/pkgs-by-name/ghaf-update-manifest/ghaf-update-manifest.py"
click node_enrollment "https://github.com/gngram/ghaf/blob/main/packages/pkgs-by-name/ghaf-verify-enrollment/verify-enrollment.py"
click node_greenprobe "https://github.com/gngram/ghaf/blob/main/packages/gpu-vm-green-context-probe/runner.c"
click node_gpuload "https://github.com/gngram/ghaf/blob/main/packages/gpu-vm-load/runner.c"
click node_openbrowser "https://github.com/gngram/ghaf/blob/main/packages/chrome-extensions/open-normal/src/open_normal.js"

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_targets,node_reference,node_builders toneBlue
class node_common,node_microvm,node_hardware,node_fakebattery,node_givc toneAmber
class node_securitymods,node_enrollment toneMint
class node_installer,node_bootcontents,node_flashxml,node_netboot,node_manifest toneRose
class node_greenprobe,node_gpuload,node_openbrowser,node_user toneIndigo
```

## Components

### Configuration and builds

- [Hardware targets](https://github.com/gngram/ghaf/tree/main/targets): `targets`
- [Reference configurations](https://github.com/gngram/ghaf/tree/main/modules/reference): `modules/reference`
- [Image builders](https://github.com/gngram/ghaf/tree/main/lib/builders): `lib/builders`

### VM and hardware

- [Common system modules](https://github.com/gngram/ghaf/tree/main/modules/common): `modules/common`
- [MicroVM composition](https://github.com/gngram/ghaf/tree/main/modules/microvm): `modules/microvm`
- [Hardware support](https://github.com/gngram/ghaf/tree/main/modules/hardware): `modules/hardware`
- [Fake battery driver](https://github.com/gngram/ghaf/blob/main/modules/hardware/x86_64-generic/kernel/modules/fake-battery/fake_battery.c): `modules/hardware/x86_64-generic/kernel/modules/fake-battery/fake_battery.c`
- [GIVC integration](https://github.com/gngram/ghaf/tree/main/modules/givc): `modules/givc`

### Security services

- [Security modules](https://github.com/gngram/ghaf/tree/main/modules/common/security): `modules/common/security`
- [Enrollment verifier](https://github.com/gngram/ghaf/blob/main/packages/pkgs-by-name/ghaf-verify-enrollment/verify-enrollment.py): `packages/pkgs-by-name/ghaf-verify-enrollment/verify-enrollment.py`

### Image delivery

- [Installer](https://github.com/gngram/ghaf/tree/main/packages/pkgs-by-name/ghaf-installer): `packages/pkgs-by-name/ghaf-installer`
- [ESP boot contents](https://github.com/gngram/ghaf/blob/main/modules/reference/hardware/jetpack/nvidia-jetson-orin/mk-esp-contents.py): `modules/reference/hardware/jetpack/nvidia-jetson-orin/mk-esp-contents.py`
- [Flash layout](https://github.com/gngram/ghaf/blob/main/modules/reference/hardware/jetpack/nvidia-jetson-orin/splice-flash-xml.py): `modules/reference/hardware/jetpack/nvidia-jetson-orin/splice-flash-xml.py`
- [Netboot API](https://github.com/gngram/ghaf/blob/main/packages/pkgs-by-name/ghaf-netboot/ghaf-netboot-api.py): `packages/pkgs-by-name/ghaf-netboot/ghaf-netboot-api.py`
- [Update manifests](https://github.com/gngram/ghaf/blob/main/packages/pkgs-by-name/ghaf-update-manifest/ghaf-update-manifest.py): `packages/pkgs-by-name/ghaf-update-manifest/ghaf-update-manifest.py`

### Runtime utilities

- [GPU partition probe](https://github.com/gngram/ghaf/blob/main/packages/gpu-vm-green-context-probe/runner.c): `packages/gpu-vm-green-context-probe/runner.c`
- [GPU load smoke test](https://github.com/gngram/ghaf/blob/main/packages/gpu-vm-load/runner.c): `packages/gpu-vm-load/runner.c`
- [Normal-browser extension](https://github.com/gngram/ghaf/blob/main/packages/chrome-extensions/open-normal/src/open_normal.js): `packages/chrome-extensions/open-normal/src/open_normal.js`

### Other components

- **System integrator**

## Connections

- System integrator → Hardware targets: selects hardware
- System integrator → Image builders: builds images (evidence: `README.md`)
- System integrator → Installer: uses installer (evidence: `README.md`)
- Hardware targets → Reference configurations: configures
- Reference configurations → Image builders: configures build
- Image builders → MicroVM composition: composes VMs
- Image builders → Common system modules: configures system
- MicroVM composition → Hardware support: assigns devices
- Common system modules → Security modules: applies security
- Hardware support → Fake battery driver: includes driver
- MicroVM composition → GIVC integration: integrates control
- Image builders → ESP boot contents: prepares boot
- Image builders → Flash layout: prepares flashing
- Netboot API → System integrator: serves boot clients
