# civo/cli architecture

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

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

## Overview

Civo CLI is a terminal client for managing Civo account and cloud resources. The principal workflow is a user invoking a Cobra command, which selects a resource operation, obtains a region-aware API client, calls Civo’s API, and formats the response for terminal or machine-readable output. The command tree covers compute, networking, Kubernetes, databases, storage, and account resources. README capabilities and the file tree support those broad branches; sampled source confirms API-client use, output handling, database operations, and Kubernetes kubeconfig integration, but not every command’s internal wiring.

Main entry points: [`cmd/root.go`](https://github.com/civo/cli/blob/master/cmd/root.go) (Command entry), [`config/config.go`](https://github.com/civo/cli/blob/master/config/config.go) (Civo API client), [`cmd/database`](https://github.com/civo/cli/tree/master/cmd/database) (Databases and backups), [`cmd/instance`](https://github.com/civo/cli/tree/master/cmd/instance) (Instances and snapshots)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and settings"]
  node_entry["Command entry<br/>[root.go]"]
  node_config[("Credentials and region<br/>[config.go]")]
  node_client["Civo API client<br/>[config.go]"]
  node_output["Output formatting<br/>[output_writer.go]"]
end

subgraph group_compute["Compute and network"]
  node_instances["Instances and snapshots"]
  node_networking["Networks and VPC"]
  node_firewalls["Firewalls and IPs"]
  node_volumes["Volumes and images"]
end

subgraph group_orchestration["Kubernetes"]
  node_kubernetes["Clusters and node pools"]
  node_kubeconfig["Kubeconfig integration<br/>[kubernetes.go]"]
end

subgraph group_data["Data services"]
  node_domains["Domains and records"]
  node_databases["Databases and backups"]
  node_objectstore["Object stores"]
end

subgraph group_account["Account resources"]
  node_keys["API keys"]
  node_teams["Teams and permissions"]
  node_regions["Regions and sizes"]
  node_quota["Quota<br/>[quota.go]"]
  node_resources["Resource snapshots"]
  node_other["Other cloud resources"]
end

node_user(("CLI user"))
node_civo{{"Civo API"}}

node_user -->|"invokes"| node_entry
node_entry -->|"loads settings"| node_config
node_entry -->|"dispatches"| node_instances
node_entry -->|"dispatches"| node_networking
node_entry -->|"dispatches"| node_firewalls
node_entry -->|"dispatches"| node_volumes
node_entry -->|"dispatches"| node_kubernetes
node_entry -->|"dispatches"| node_domains
node_entry -->|"dispatches"| node_databases
node_entry -->|"dispatches"| node_objectstore
node_entry -->|"dispatches"| node_keys
node_entry -->|"dispatches"| node_teams
node_entry -->|"dispatches"| node_regions
node_entry -->|"dispatches"| node_quota
node_entry -->|"dispatches"| node_resources
node_entry -->|"dispatches"| node_other
node_config -->|"configures"| node_client
node_instances -->|"requests"| node_client
node_networking -->|"requests"| node_client
node_firewalls -->|"requests"| node_client
node_volumes -->|"requests"| node_client
node_kubernetes -->|"requests"| node_client
node_domains -->|"requests"| node_client
node_databases -->|"requests"| node_client
node_objectstore -->|"requests"| node_client
node_keys -->|"requests"| node_client
node_teams -->|"requests"| node_client
node_regions -->|"requests"| node_client
node_quota -->|"requests"| node_client
node_resources -->|"requests"| node_client
node_other -->|"requests"| node_client
node_client -->|"calls"| node_civo
node_databases -->|"creates database"| node_civo
node_databases -->|"lists backups"| node_civo
node_kubernetes -->|"updates config"| node_kubeconfig
node_instances -->|"formats results"| node_output
node_databases -->|"formats results"| node_output
node_quota -->|"formats results"| node_output

click node_entry "https://github.com/civo/cli/blob/master/cmd/root.go"
click node_config "https://github.com/civo/cli/blob/master/config/config.go"
click node_client "https://github.com/civo/cli/blob/master/config/config.go"
click node_output "https://github.com/civo/cli/blob/master/utility/output_writer.go"
click node_instances "https://github.com/civo/cli/tree/master/cmd/instance"
click node_networking "https://github.com/civo/cli/tree/master/cmd/vpc"
click node_firewalls "https://github.com/civo/cli/tree/master/cmd/firewall"
click node_volumes "https://github.com/civo/cli/tree/master/cmd/volume"
click node_kubernetes "https://github.com/civo/cli/tree/master/cmd/kubernetes"
click node_kubeconfig "https://github.com/civo/cli/blob/master/utility/kubernetes.go"
click node_domains "https://github.com/civo/cli/tree/master/cmd/domain"
click node_databases "https://github.com/civo/cli/tree/master/cmd/database"
click node_objectstore "https://github.com/civo/cli/tree/master/cmd/objectstore"
click node_keys "https://github.com/civo/cli/tree/master/cmd/apikey"
click node_teams "https://github.com/civo/cli/tree/master/cmd/teams"
click node_regions "https://github.com/civo/cli/tree/master/cmd/region"
click node_quota "https://github.com/civo/cli/blob/master/cmd/quota.go"
click node_resources "https://github.com/civo/cli/tree/master/cmd/resourcesnapshot"
click node_other "https://github.com/civo/cli/tree/master/cmd/loadbalancer"

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_config,node_client,node_output,node_user toneBlue
class node_instances,node_networking,node_firewalls,node_volumes toneAmber
class node_kubernetes,node_kubeconfig,node_civo toneMint
class node_domains,node_databases,node_objectstore toneRose
class node_keys,node_teams,node_regions,node_quota,node_resources,node_other toneIndigo
```

## Components

### CLI and settings

- [Command entry](https://github.com/civo/cli/blob/master/cmd/root.go): `cmd/root.go`
- [Credentials and region](https://github.com/civo/cli/blob/master/config/config.go): `config/config.go`
- [Civo API client](https://github.com/civo/cli/blob/master/config/config.go): `config/config.go`
- [Output formatting](https://github.com/civo/cli/blob/master/utility/output_writer.go): `utility/output_writer.go`

### Compute and network

- [Instances and snapshots](https://github.com/civo/cli/tree/master/cmd/instance): `cmd/instance`
- [Networks and VPC](https://github.com/civo/cli/tree/master/cmd/vpc): `cmd/vpc`
- [Firewalls and IPs](https://github.com/civo/cli/tree/master/cmd/firewall): `cmd/firewall`
- [Volumes and images](https://github.com/civo/cli/tree/master/cmd/volume): `cmd/volume`

### Kubernetes

- [Clusters and node pools](https://github.com/civo/cli/tree/master/cmd/kubernetes): `cmd/kubernetes`
- [Kubeconfig integration](https://github.com/civo/cli/blob/master/utility/kubernetes.go): `utility/kubernetes.go`

### Data services

- [Domains and records](https://github.com/civo/cli/tree/master/cmd/domain): `cmd/domain`
- [Databases and backups](https://github.com/civo/cli/tree/master/cmd/database): `cmd/database`
- [Object stores](https://github.com/civo/cli/tree/master/cmd/objectstore): `cmd/objectstore`

### Account resources

- [API keys](https://github.com/civo/cli/tree/master/cmd/apikey): `cmd/apikey`
- [Teams and permissions](https://github.com/civo/cli/tree/master/cmd/teams): `cmd/teams`
- [Regions and sizes](https://github.com/civo/cli/tree/master/cmd/region): `cmd/region`
- [Quota](https://github.com/civo/cli/blob/master/cmd/quota.go): `cmd/quota.go`
- [Resource snapshots](https://github.com/civo/cli/tree/master/cmd/resourcesnapshot): `cmd/resourcesnapshot`
- [Other cloud resources](https://github.com/civo/cli/tree/master/cmd/loadbalancer): `cmd/loadbalancer`

### Other components

- **CLI user**
- **Civo API**

## Connections

- CLI user → Command entry: invokes
- Command entry → Credentials and region: loads settings
- Command entry → Instances and snapshots: dispatches
- Command entry → Networks and VPC: dispatches
- Command entry → Firewalls and IPs: dispatches
- Command entry → Volumes and images: dispatches
- Command entry → Clusters and node pools: dispatches
- Command entry → Domains and records: dispatches
- Command entry → Databases and backups: dispatches
- Command entry → Object stores: dispatches
- Command entry → API keys: dispatches
- Command entry → Teams and permissions: dispatches
- Command entry → Regions and sizes: dispatches
- Command entry → Quota: dispatches
- Command entry → Resource snapshots: dispatches
- Command entry → Other cloud resources: dispatches
- Credentials and region → Civo API client: configures
- Instances and snapshots → Civo API client: requests
- Networks and VPC → Civo API client: requests
- Firewalls and IPs → Civo API client: requests
- Volumes and images → Civo API client: requests
- Clusters and node pools → Civo API client: requests
- Domains and records → Civo API client: requests
- Databases and backups → Civo API client: requests
- Object stores → Civo API client: requests
- API keys → Civo API client: requests
- Teams and permissions → Civo API client: requests
- Regions and sizes → Civo API client: requests
- Quota → Civo API client: requests
- Resource snapshots → Civo API client: requests
- Other cloud resources → Civo API client: requests
- Civo API client → Civo API: calls
- Databases and backups → Civo API: creates database
- Databases and backups → Civo API: lists backups
- Clusters and node pools → Kubeconfig integration: updates config
- Instances and snapshots → Output formatting: formats results
- Databases and backups → Output formatting: formats results
- Quota → Output formatting: formats results
