# iboutbaoucht/vmaas-zerotouch architecture

> Architecture diagram of the GitHub repository iboutbaoucht/vmaas-zerotouch, 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/iboutbaoucht/vmaas-zerotouch
- Repository: https://github.com/iboutbaoucht/vmaas-zerotouch

## Overview

VMaaS Zero-Touch is a browser-driven self-service provisioner for standalone ESXi. The browser submits VM requests and polls status; the API hands provisioning to a persisted asynchronous lifecycle orchestrator, which allocates an IP, clones a gold image, injects cloud-init configuration, powers on the guest, and checks readiness. Deletion reverses the lifecycle and releases the address. The diagram also includes API authentication, configuration, persistent state, and pool reporting. Edges follow shown calls or README-described behavior; unsampled implementation details are not inferred.

Main entry points: [`backend/internal/lifecycle/orchestrator.go`](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/lifecycle/orchestrator.go) (Lifecycle engine), [`backend/cmd/vmaasd/main.go`](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/cmd/vmaasd/main.go) (Service startup), [`backend/internal/api/server.go`](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/server.go) (HTTP router), [`backend/internal/esxi`](https://github.com/iboutbaoucht/vmaas-zerotouch/tree/main/backend/internal/esxi) (VM and datastore ops)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_console["Web Console"]
  node_frontend["VM console<br/>[app.js]"]
  node_embedded_ui["Embedded console<br/>[app.js]"]
end

subgraph group_service["API Service"]
  node_api_router["HTTP router<br/>[server.go]"]
  node_api_handlers["VM handlers<br/>[handlers.go]"]
  node_api_auth["Bearer auth<br/>[auth.go]"]
  node_daemon["Service startup<br/>[main.go]"]
  node_config["Runtime config<br/>[config.go]"]
end

subgraph group_provision["Provisioning"]
  node_lifecycle["Lifecycle engine<br/>[orchestrator.go]"]
  node_guest_check["Guest readiness<br/>[guest.go]"]
  node_ip_allocator["IP pool<br/>[alloc.go]"]
  node_cloudinit["Cloud-init renderer<br/>[render.go]"]
  node_clone["File-level clone<br/>[clone.go]"]
end

subgraph group_infra["State and Hypervisor"]
  node_state_store[("Persistent state<br/>[store.go]")]
  node_esxi_client["ESXi client<br/>[client.go]"]
  node_esxi_ops["VM and datastore ops"]
end

node_browser(("Browser user"))
node_esxi_host["Standalone ESXi"]
node_guest_vm["Provisioned guest"]

node_browser -->|"uses"| node_frontend
node_frontend -->|"sends API requests"| node_api_router
node_embedded_ui -->|"sends API requests"| node_api_router
node_api_router -->|"protects routes"| node_api_auth
node_api_router -->|"routes requests"| node_api_handlers
node_api_handlers -->|"starts and queries"| node_lifecycle
node_api_handlers -->|"reads pool"| node_ip_allocator
node_daemon -->|"loads"| node_config
node_daemon -->|"starts"| node_api_router
node_daemon -->|"constructs"| node_lifecycle
node_daemon -->|"opens"| node_state_store
node_daemon -->|"connects"| node_esxi_client
node_lifecycle -->|"reserves and releases"| node_ip_allocator
node_lifecycle -->|"renders guest config"| node_cloudinit
node_lifecycle -->|"clones image"| node_clone
node_lifecycle -->|"persists lifecycle"| node_state_store
node_lifecycle -->|"manages VM"| node_esxi_ops
node_lifecycle -->|"checks readiness"| node_guest_check
node_clone -->|"copies and registers"| node_esxi_ops
node_clone -->|"records checkpoints"| node_state_store
node_ip_allocator -->|"updates allocation bucket"| node_state_store
node_esxi_client -->|"connects to"| node_esxi_host
node_esxi_ops -->|"operates on"| node_esxi_host
node_esxi_ops -->|"powers on and inspects"| node_guest_vm
node_cloudinit -->|"provides boot config"| node_guest_vm

click node_frontend "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/frontend/app.js"
click node_embedded_ui "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/static/app.js"
click node_api_router "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/server.go"
click node_api_handlers "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/handlers.go"
click node_api_auth "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/auth.go"
click node_daemon "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/cmd/vmaasd/main.go"
click node_config "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/config/config.go"
click node_lifecycle "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/lifecycle/orchestrator.go"
click node_guest_check "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/lifecycle/guest.go"
click node_ip_allocator "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/ipalloc/alloc.go"
click node_cloudinit "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/cloudinit/render.go"
click node_clone "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/clone/clone.go"
click node_state_store "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/store/store.go"
click node_esxi_client "https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/esxi/client.go"
click node_esxi_ops "https://github.com/iboutbaoucht/vmaas-zerotouch/tree/main/backend/internal/esxi"

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_frontend,node_embedded_ui,node_browser toneBlue
class node_api_router,node_api_handlers,node_api_auth,node_daemon,node_config toneAmber
class node_lifecycle,node_guest_check,node_ip_allocator,node_cloudinit,node_clone toneMint
class node_state_store,node_esxi_client,node_esxi_ops toneRose
class node_esxi_host,node_guest_vm toneIndigo
```

## Components

### Web Console

- [VM console](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/frontend/app.js): `frontend/app.js`
- [Embedded console](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/static/app.js): `backend/internal/api/static/app.js`

### API Service

- [HTTP router](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/server.go): `backend/internal/api/server.go`
- [VM handlers](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/handlers.go): `backend/internal/api/handlers.go`
- [Bearer auth](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/api/auth.go): `backend/internal/api/auth.go`
- [Service startup](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/cmd/vmaasd/main.go): `backend/cmd/vmaasd/main.go`
- [Runtime config](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/config/config.go): `backend/internal/config/config.go`

### Provisioning

- [Lifecycle engine](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/lifecycle/orchestrator.go): `backend/internal/lifecycle/orchestrator.go`
- [Guest readiness](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/lifecycle/guest.go): `backend/internal/lifecycle/guest.go`
- [IP pool](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/ipalloc/alloc.go): `backend/internal/ipalloc/alloc.go`
- [Cloud-init renderer](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/cloudinit/render.go): `backend/internal/cloudinit/render.go`
- [File-level clone](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/clone/clone.go): `backend/internal/clone/clone.go`

### State and Hypervisor

- [Persistent state](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/store/store.go): `backend/internal/store/store.go`
- [ESXi client](https://github.com/iboutbaoucht/vmaas-zerotouch/blob/main/backend/internal/esxi/client.go): `backend/internal/esxi/client.go`
- [VM and datastore ops](https://github.com/iboutbaoucht/vmaas-zerotouch/tree/main/backend/internal/esxi): `backend/internal/esxi`

### Other components

- **Browser user**
- **Standalone ESXi**
- **Provisioned guest**

## Connections

- Browser user → VM console: uses (evidence: `README.md`)
- VM console → HTTP router: sends API requests (evidence: `frontend/app.js`)
- Embedded console → HTTP router: sends API requests (evidence: `backend/internal/api/static/app.js`)
- HTTP router → Bearer auth: protects routes (evidence: `backend/internal/api/server.go`)
- HTTP router → VM handlers: routes requests (evidence: `backend/internal/api/server.go`)
- VM handlers → Lifecycle engine: starts and queries (evidence: `backend/internal/api/handlers.go`)
- VM handlers → IP pool: reads pool (evidence: `backend/internal/api/handlers.go`)
- Service startup → Runtime config: loads (evidence: `backend/cmd/vmaasd/main.go`)
- Service startup → HTTP router: starts (evidence: `backend/cmd/vmaasd/main.go`)
- Service startup → Lifecycle engine: constructs (evidence: `backend/cmd/vmaasd/main.go`)
- Service startup → Persistent state: opens (evidence: `backend/cmd/vmaasd/main.go`)
- Service startup → ESXi client: connects (evidence: `backend/cmd/vmaasd/main.go`)
- Lifecycle engine → IP pool: reserves and releases (evidence: `README.md`)
- Lifecycle engine → Cloud-init renderer: renders guest config (evidence: `backend/internal/lifecycle/orchestrator.go`)
- Lifecycle engine → File-level clone: clones image (evidence: `README.md`)
- Lifecycle engine → Persistent state: persists lifecycle (evidence: `README.md`)
- Lifecycle engine → VM and datastore ops: manages VM (evidence: `README.md`)
- Lifecycle engine → Guest readiness: checks readiness (evidence: `README.md`)
- File-level clone → VM and datastore ops: copies and registers (evidence: `backend/internal/clone/clone.go`)
- File-level clone → Persistent state: records checkpoints (evidence: `backend/internal/clone/clone.go`)
- IP pool → Persistent state: updates allocation bucket (evidence: `backend/internal/ipalloc/alloc.go`)
- ESXi client → Standalone ESXi: connects to (evidence: `backend/internal/esxi/client.go`)
- VM and datastore ops → Standalone ESXi: operates on (evidence: `README.md`)
- VM and datastore ops → Provisioned guest: powers on and inspects (evidence: `README.md`)
- Cloud-init renderer → Provisioned guest: provides boot config (evidence: `README.md`)
