# vmvarela/gh-tofu architecture

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

- Interactive diagram: https://gitdiagram.com/vmvarela/gh-tofu
- Repository: https://github.com/vmvarela/gh-tofu

## Overview

gh-tofu distributes a pinned OpenTofu build with an ORAS backend for storing state, locks, and optional retained history in an OCI registry. The main workflow is `gh tofu init`: an interactive assistant can write backend configuration, after which OpenTofu performs its normal initialization and migration; users then run the usual plan/apply workflow. README statements support these relationships, but the tree exposes patch files rather than the full CLI or backend implementation, so those components are represented only where a path is supported.

Main entry points: [`patches/backend.patch`](https://github.com/vmvarela/gh-tofu/blob/master/patches/backend.patch) (ORAS backend), [`patches/init-assistant.patch`](https://github.com/vmvarela/gh-tofu/blob/master/patches/init-assistant.patch) (Init assistant), [`patches/history.patch`](https://github.com/vmvarela/gh-tofu/blob/master/patches/history.patch) (State history), [`patches/oras-purge.patch`](https://github.com/vmvarela/gh-tofu/blob/master/patches/oras-purge.patch) (Tag deletion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["CLI setup"]
  node_cli["gh-tofu CLI"]
  node_assistant["Init assistant"]
  node_config["Backend config"]
end

subgraph group_backend["ORAS backend"]
  node_opentofu["OpenTofu runtime"]
  node_oras["ORAS backend<br/>[backend.patch]"]
end

subgraph group_state["State lifecycle"]
  node_registry[("OCI registry")]
  node_history["State history<br/>[history.patch]"]
  node_purge["Tag deletion<br/>[oras-purge.patch]"]
  node_workspace["Workspace support"]
end

node_user(("CLI user"))

node_user -->|"runs commands"| node_cli
node_cli -->|"offers setup"| node_assistant
node_assistant -->|"writes config"| node_config
node_cli -->|"runs init"| node_opentofu
node_opentofu -->|"uses backend"| node_oras
node_oras -->|"stores state"| node_registry
node_oras -->|"stores locks"| node_registry
node_oras -->|"retains versions"| node_history
node_oras -->|"deletes tags"| node_purge
node_opentofu -.->|"supports workspaces"| node_workspace
node_user -->|"runs plan/apply"| node_cli

click node_assistant "https://github.com/vmvarela/gh-tofu/blob/master/patches/init-assistant.patch"
click node_config "https://github.com/vmvarela/gh-tofu/blob/master/patches/init-assistant.patch"
click node_oras "https://github.com/vmvarela/gh-tofu/blob/master/patches/backend.patch"
click node_history "https://github.com/vmvarela/gh-tofu/blob/master/patches/history.patch"
click node_purge "https://github.com/vmvarela/gh-tofu/blob/master/patches/oras-purge.patch"
click node_workspace "https://github.com/vmvarela/gh-tofu/blob/master/patches/workspace-exists.patch"

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_cli,node_assistant,node_config,node_user toneBlue
class node_opentofu,node_oras toneAmber
class node_registry,node_history,node_purge,node_workspace toneMint
```

## Components

### CLI setup

- **gh-tofu CLI**
- [Init assistant](https://github.com/vmvarela/gh-tofu/blob/master/patches/init-assistant.patch): `patches/init-assistant.patch`
- [Backend config](https://github.com/vmvarela/gh-tofu/blob/master/patches/init-assistant.patch): `patches/init-assistant.patch`

### ORAS backend

- **OpenTofu runtime**
- [ORAS backend](https://github.com/vmvarela/gh-tofu/blob/master/patches/backend.patch): `patches/backend.patch`

### State lifecycle

- **OCI registry**
- [State history](https://github.com/vmvarela/gh-tofu/blob/master/patches/history.patch): `patches/history.patch`
- [Tag deletion](https://github.com/vmvarela/gh-tofu/blob/master/patches/oras-purge.patch): `patches/oras-purge.patch`
- [Workspace support](https://github.com/vmvarela/gh-tofu/blob/master/patches/workspace-exists.patch): `patches/workspace-exists.patch`

### Other components

- **CLI user**

## Connections

- CLI user → gh-tofu CLI: runs commands (evidence: `README.md`)
- gh-tofu CLI → Init assistant: offers setup (evidence: `README.md`)
- Init assistant → Backend config: writes config (evidence: `README.md`)
- gh-tofu CLI → OpenTofu runtime: runs init (evidence: `README.md`)
- OpenTofu runtime → ORAS backend: uses backend (evidence: `README.md`)
- ORAS backend → OCI registry: stores state (evidence: `README.md`)
- ORAS backend → OCI registry: stores locks (evidence: `README.md`)
- ORAS backend → State history: retains versions (evidence: `README.md`)
- ORAS backend → Tag deletion: deletes tags (evidence: `README.md`)
- OpenTofu runtime → Workspace support: supports workspaces
- CLI user → gh-tofu CLI: runs plan/apply (evidence: `README.md`)
