# schoolyear/avd-cli architecture

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

- Interactive diagram: https://gitdiagram.com/schoolyear/avd-cli
- Repository: https://github.com/schoolyear/avd-cli

## Overview

AVD CLI builds Windows virtual-desktop images through a two-step workflow: users assemble and validate layers into a bundle, then generate or deploy an Azure Image Builder template that executes the bundle and publishes an image. It also scaffolds layer folders and updates the CLI. The command files own most orchestration; shared libraries handle file, JSON, prompt, and GitHub operations. The excerpts show key bundle and deployment steps, but not every internal call or Azure interaction, so uncertain links are omitted.

Main entry points: [`commands/bundle_layers.go`](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go) (Bundle command), [`main.go`](https://github.com/schoolyear/avd-cli/blob/master/main.go) (Command router), [`commands/bundle_autobuild.go`](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_autobuild.go) (Autobuild command), [`lib/lib_github/download.go`](https://github.com/schoolyear/avd-cli/blob/master/lib/lib_github/download.go) (Release lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI commands"]
  node_entry["Command router<br/>[main.go]"]
  node_newlayer["Layer scaffolding<br/>[layer_new.go]"]
  node_update["CLI updater<br/>[update.go]"]
end

subgraph group_bundle["Layer bundling"]
  node_bundlecmd["Bundle command<br/>[bundle_layers.go]"]
  node_layerresolve["Layer resolution<br/>[bundle_layers.go]"]
  node_layervalidate["Layer validation<br/>[bundle_layers.go]"]
  node_parameters["Build parameters<br/>[bundle_layers.go]"]
  node_bundlearchive["Bundle archive<br/>[bundle_layers.go]"]
  node_defaultlayers["Default base layers<br/>[embed.go]"]
end

subgraph group_image["Image building"]
  node_autobuild["Autobuild command"]
  node_bundlecheck["Bundle validation"]
  node_templategen["Template generation"]
end

subgraph group_shared["Shared services"]
  node_templates["Embedded templates<br/>[embed.go]"]
  node_githubauth["GitHub device auth"]
  node_githubrelease["Release lookup<br/>[download.go]"]
  node_filejson["File and JSON helpers<br/>[json.go]"]
  node_schema["Bundle file schema<br/>[v2_bundle_files.go]"]
  node_execution["Bundle execution script<br/>[v2_execute.ps1]"]
end

node_user(("CLI user"))
node_azurebuilder{{"Azure Image Builder"}}
node_azuregallery[("Azure image gallery")]
node_github{{"GitHub releases"}}

node_user -->|"runs"| node_entry
node_entry -->|"routes"| node_newlayer
node_entry -->|"routes"| node_bundlecmd
node_entry -->|"routes"| node_autobuild
node_entry -->|"routes"| node_update
node_newlayer -->|"copies"| node_templates
node_bundlecmd -->|"resolves layers"| node_layerresolve
node_bundlecmd -->|"selects base layer"| node_defaultlayers
node_bundlecmd -->|"authenticates"| node_githubauth
node_bundlecmd -->|"validates layers"| node_layervalidate
node_bundlecmd -->|"resolves parameters"| node_parameters
node_bundlecmd -->|"creates archive"| node_bundlearchive
node_layerresolve -->|"downloads community layers"| node_github
node_layervalidate -->|"checks script names"| node_schema
node_bundlecmd -->|"reads JSON configuration"| node_filejson
node_autobuild -->|"validates bundle"| node_bundlecheck
node_autobuild -->|"generates template"| node_templategen
node_templategen -.->|"embeds execution script"| node_execution
node_autobuild -->|"deploys template"| node_azurebuilder
node_azurebuilder -.->|"publishes image"| node_azuregallery
node_entry -->|"checks version"| node_githubrelease
node_githubrelease -->|"queries releases"| node_github
node_update -->|"fetches version"| node_githubrelease

click node_entry "https://github.com/schoolyear/avd-cli/blob/master/main.go"
click node_newlayer "https://github.com/schoolyear/avd-cli/blob/master/commands/layer_new.go"
click node_update "https://github.com/schoolyear/avd-cli/blob/master/commands/update.go"
click node_bundlecmd "https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go"
click node_layerresolve "https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go"
click node_layervalidate "https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go"
click node_parameters "https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go"
click node_bundlearchive "https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go"
click node_defaultlayers "https://github.com/schoolyear/avd-cli/blob/master/embeddedfiles/v2_default_layers/embed.go"
click node_templates "https://github.com/schoolyear/avd-cli/blob/master/embeddedfiles/embed.go"
click node_autobuild "https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_autobuild.go"
click node_bundlecheck "https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_autobuild.go"
click node_templategen "https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_autobuild.go"
click node_githubauth "https://github.com/schoolyear/avd-cli/blob/master/lib/lib_github/github_device_auth.go"
click node_githubrelease "https://github.com/schoolyear/avd-cli/blob/master/lib/lib_github/download.go"
click node_filejson "https://github.com/schoolyear/avd-cli/blob/master/lib/json.go"
click node_schema "https://github.com/schoolyear/avd-cli/blob/master/schema/v2_bundle_files.go"
click node_execution "https://github.com/schoolyear/avd-cli/blob/master/embeddedfiles/v2_execute.ps1"

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_entry,node_newlayer,node_update,node_user toneBlue
class node_bundlecmd,node_layerresolve,node_layervalidate,node_parameters,node_bundlearchive,node_defaultlayers,node_azuregallery toneAmber
class node_autobuild,node_bundlecheck,node_templategen toneMint
class node_templates,node_githubauth,node_githubrelease,node_filejson,node_schema,node_execution toneRose
class node_azurebuilder,node_github toneIndigo
```

## Components

### CLI commands

- [Command router](https://github.com/schoolyear/avd-cli/blob/master/main.go): `main.go`
- [Layer scaffolding](https://github.com/schoolyear/avd-cli/blob/master/commands/layer_new.go): `commands/layer_new.go`
- [CLI updater](https://github.com/schoolyear/avd-cli/blob/master/commands/update.go): `commands/update.go`

### Layer bundling

- [Bundle command](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go): `commands/bundle_layers.go`
- [Layer resolution](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go): `commands/bundle_layers.go`
- [Layer validation](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go): `commands/bundle_layers.go`
- [Build parameters](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go): `commands/bundle_layers.go`
- [Bundle archive](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_layers.go): `commands/bundle_layers.go`
- [Default base layers](https://github.com/schoolyear/avd-cli/blob/master/embeddedfiles/v2_default_layers/embed.go): `embeddedfiles/v2_default_layers/embed.go`

### Image building

- [Autobuild command](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_autobuild.go): `commands/bundle_autobuild.go`
- [Bundle validation](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_autobuild.go): `commands/bundle_autobuild.go`
- [Template generation](https://github.com/schoolyear/avd-cli/blob/master/commands/bundle_autobuild.go): `commands/bundle_autobuild.go`

### Shared services

- [Embedded templates](https://github.com/schoolyear/avd-cli/blob/master/embeddedfiles/embed.go): `embeddedfiles/embed.go`
- [GitHub device auth](https://github.com/schoolyear/avd-cli/blob/master/lib/lib_github/github_device_auth.go): `lib/lib_github/github_device_auth.go`
- [Release lookup](https://github.com/schoolyear/avd-cli/blob/master/lib/lib_github/download.go): `lib/lib_github/download.go`
- [File and JSON helpers](https://github.com/schoolyear/avd-cli/blob/master/lib/json.go): `lib/json.go`
- [Bundle file schema](https://github.com/schoolyear/avd-cli/blob/master/schema/v2_bundle_files.go): `schema/v2_bundle_files.go`
- [Bundle execution script](https://github.com/schoolyear/avd-cli/blob/master/embeddedfiles/v2_execute.ps1): `embeddedfiles/v2_execute.ps1`

### Other components

- **CLI user**
- **Azure Image Builder**
- **Azure image gallery**
- **GitHub releases**

## Connections

- CLI user → Command router: runs (evidence: `main.go`)
- Command router → Layer scaffolding: routes (evidence: `main.go`)
- Command router → Bundle command: routes (evidence: `main.go`)
- Command router → Autobuild command: routes (evidence: `main.go`)
- Command router → CLI updater: routes (evidence: `main.go`)
- Layer scaffolding → Embedded templates: copies (evidence: `commands/layer_new.go`)
- Bundle command → Layer resolution: resolves layers (evidence: `commands/bundle_layers.go`)
- Bundle command → Default base layers: selects base layer (evidence: `commands/bundle_layers.go`)
- Bundle command → GitHub device auth: authenticates (evidence: `commands/bundle_layers.go`)
- Bundle command → Layer validation: validates layers (evidence: `commands/bundle_layers.go`)
- Bundle command → Build parameters: resolves parameters (evidence: `commands/bundle_layers.go`)
- Bundle command → Bundle archive: creates archive (evidence: `commands/bundle_layers.go`)
- Layer resolution → GitHub releases: downloads community layers (evidence: `commands/bundle_layers.go`)
- Layer validation → Bundle file schema: checks script names (evidence: `commands/bundle_layers.go`)
- Bundle command → File and JSON helpers: reads JSON configuration (evidence: `commands/bundle_layers.go`)
- Autobuild command → Bundle validation: validates bundle (evidence: `commands/bundle_autobuild.go`)
- Autobuild command → Template generation: generates template (evidence: `commands/bundle_autobuild.go`)
- Template generation → Bundle execution script: embeds execution script
- Autobuild command → Azure Image Builder: deploys template (evidence: `commands/bundle_autobuild.go`)
- Azure Image Builder → Azure image gallery: publishes image
- Command router → Release lookup: checks version (evidence: `main.go`)
- Release lookup → GitHub releases: queries releases (evidence: `lib/lib_github/download.go`)
- CLI updater → Release lookup: fetches version (evidence: `commands/update.go`)
