# kaanergun/pi-usbboot architecture

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

- Interactive diagram: https://gitdiagram.com/kaanergun/pi-usbboot
- Repository: https://github.com/kaanergun/pi-usbboot

## Overview

Pi USB Boot is a macOS/Linux desktop app that exposes supported Raspberry Pi storage over USB and opens the bundled Raspberry Pi Imager to flash it. The main workflow runs from the UI through Tauri commands: detect a single boot-mode board, select matching bundled boot files, run rpiboot with elevated privileges, then wait for the resulting external disk and launch Imager. The source excerpts show the command and runtime relationships; Imager’s image-writing behavior is documented in the README.

Main entry points: [`src-tauri/src/lib.rs`](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/lib.rs) (Tauri commands), [`src-tauri/src/runtime.rs`](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/runtime.rs) (Imager launcher), [`src-ui/main.ts`](https://github.com/kaanergun/pi-usbboot/blob/main/src-ui/main.ts) (App UI), [`src-tauri/src/disks.rs`](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/disks.rs) (External disk listing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Desktop interface"]
  node_ui["App UI<br/>[main.ts]"]
  node_commands["Tauri commands<br/>[lib.rs]"]
end

subgraph group_boot["Board boot workflow"]
  node_board["RPIBOOT board"]
  node_usb["USB detection<br/>[usb.rs]"]
  node_payload["Payload selection<br/>[rpiboot.rs]"]
  node_rpiboot["Privileged rpiboot<br/>[rpiboot.rs]"]
end

subgraph group_runtime["Bundled tools"]
  node_runtime["Runtime paths<br/>[runtime.rs]"]
  node_packaged["Bundled tools and boot files<br/>[runtime.rs]"]
  node_launcher["Imager launcher<br/>[runtime.rs]"]
end

subgraph group_flash["Disk imaging"]
  node_disklist["External disk listing<br/>[disks.rs]"]
  node_hostdisks["Host disk services"]
  node_imager["Raspberry Pi Imager"]
  node_catalog["OS image catalog"]
  node_image["OS image"]
end

node_user(("User"))

node_user -->|"uses"| node_ui
node_ui -->|"invokes commands"| node_commands
node_commands -->|"detects board"| node_usb
node_usb -->|"enumerates USB"| node_board
node_commands -->|"locates payload"| node_payload
node_commands -->|"starts boot transfer"| node_rpiboot
node_rpiboot -->|"transfers boot files"| node_board
node_commands -->|"resolves runtime"| node_runtime
node_runtime -->|"locates bundled assets"| node_packaged
node_commands -->|"lists disks"| node_disklist
node_disklist -->|"queries disk services"| node_hostdisks
node_ui -->|"requests launch"| node_launcher
node_commands -->|"opens Imager"| node_launcher
node_launcher -->|"launches bundled app"| node_packaged
node_launcher -->|"starts"| node_imager
node_imager -->|"loads OS choices"| node_catalog
node_catalog -->|"provides image"| node_image
node_imager -->|"writes selected disk"| node_disklist
node_user -->|"selects disk"| node_imager

click node_ui "https://github.com/kaanergun/pi-usbboot/blob/main/src-ui/main.ts"
click node_commands "https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/lib.rs"
click node_usb "https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/usb.rs"
click node_payload "https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/rpiboot.rs"
click node_rpiboot "https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/rpiboot.rs"
click node_runtime "https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/runtime.rs"
click node_packaged "https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/runtime.rs"
click node_disklist "https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/disks.rs"
click node_launcher "https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/runtime.rs"

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_ui,node_commands,node_user toneBlue
class node_board,node_usb,node_payload,node_rpiboot toneAmber
class node_runtime,node_packaged,node_launcher toneMint
class node_disklist,node_hostdisks,node_imager,node_catalog,node_image toneRose
```

## Components

### Desktop interface

- [App UI](https://github.com/kaanergun/pi-usbboot/blob/main/src-ui/main.ts): `src-ui/main.ts`
- [Tauri commands](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`

### Board boot workflow

- **RPIBOOT board**
- [USB detection](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/usb.rs): `src-tauri/src/usb.rs`
- [Payload selection](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/rpiboot.rs): `src-tauri/src/rpiboot.rs`
- [Privileged rpiboot](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/rpiboot.rs): `src-tauri/src/rpiboot.rs`

### Bundled tools

- [Runtime paths](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/runtime.rs): `src-tauri/src/runtime.rs`
- [Bundled tools and boot files](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/runtime.rs): `src-tauri/src/runtime.rs`
- [Imager launcher](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/runtime.rs): `src-tauri/src/runtime.rs`

### Disk imaging

- [External disk listing](https://github.com/kaanergun/pi-usbboot/blob/main/src-tauri/src/disks.rs): `src-tauri/src/disks.rs`
- **Host disk services**
- **Raspberry Pi Imager**
- **OS image catalog**
- **OS image**

### Other components

- **User**

## Connections

- User → App UI: uses (evidence: `README.md`)
- App UI → Tauri commands: invokes commands (evidence: `src-ui/main.ts`)
- Tauri commands → USB detection: detects board (evidence: `src-tauri/src/lib.rs`)
- USB detection → RPIBOOT board: enumerates USB (evidence: `README.md`)
- Tauri commands → Payload selection: locates payload (evidence: `src-tauri/src/lib.rs`)
- Tauri commands → Privileged rpiboot: starts boot transfer (evidence: `src-tauri/src/lib.rs`)
- Privileged rpiboot → RPIBOOT board: transfers boot files (evidence: `README.md`)
- Tauri commands → Runtime paths: resolves runtime (evidence: `src-tauri/src/lib.rs`)
- Runtime paths → Bundled tools and boot files: locates bundled assets (evidence: `src-tauri/src/runtime.rs`)
- Tauri commands → External disk listing: lists disks (evidence: `src-tauri/src/lib.rs`)
- External disk listing → Host disk services: queries disk services (evidence: `src-tauri/src/disks.rs`)
- App UI → Imager launcher: requests launch (evidence: `src-ui/main.ts`)
- Tauri commands → Imager launcher: opens Imager (evidence: `src-tauri/src/lib.rs`)
- Imager launcher → Bundled tools and boot files: launches bundled app (evidence: `src-tauri/src/runtime.rs`)
- Imager launcher → Raspberry Pi Imager: starts (evidence: `README.md`)
- Raspberry Pi Imager → OS image catalog: loads OS choices (evidence: `README.md`)
- OS image catalog → OS image: provides image (evidence: `README.md`)
- Raspberry Pi Imager → External disk listing: writes selected disk (evidence: `README.md`)
- User → Raspberry Pi Imager: selects disk (evidence: `README.md`)
