# getsops/sops architecture

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

- Interactive diagram: https://gitdiagram.com/getsops/sops
- Repository: https://github.com/getsops/sops

## Overview

SOPS is a command-line editor for structured files whose values and data key are encrypted. The main workflow selects a file format and configuration, operates on the encrypted tree, and uses configured master keys to protect or recover the data key. The repository also provides a remote gRPC key service and publishing commands. The graph captures documented format and key-provider support; some CLI handlers and provider implementations were not sampled, so their detailed runtime links are omitted.

Main entry points: [`config/config.go`](https://github.com/getsops/sops/blob/main/config/config.go) (Configuration), [`keyservice/server.go`](https://github.com/getsops/sops/blob/main/keyservice/server.go) (gRPC key server), [`cmd/sops/common/common.go`](https://github.com/getsops/sops/blob/main/cmd/sops/common/common.go) (CLI operations), [`stores/stores.go`](https://github.com/getsops/sops/blob/main/stores/stores.go) (SOPS metadata)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli["SOPS CLI<br/>[main.go]"]
  node_common["CLI operations<br/>[common.go]"]
  node_config["Configuration<br/>[config.go]"]
end

subgraph group_core["Encryption core"]
  node_core["Encrypted tree<br/>[sops.go]"]
  node_cipher["Value cipher<br/>[cipher.go]"]
  node_audit["Audit logging<br/>[audit.go]"]
end

subgraph group_formats["File formats"]
  node_stores["SOPS metadata<br/>[stores.go]"]
  node_yaml["YAML store<br/>[store.go]"]
  node_json["JSON and binary<br/>[store.go]"]
  node_dotenv["ENV store<br/>[store.go]"]
  node_ini["INI store<br/>[store.go]"]
end

subgraph group_keys["Key management"]
  node_keyservice["Key service API<br/>[keyservice.go]"]
  node_server["gRPC key server<br/>[server.go]"]
  node_aws["AWS KMS<br/>[keysource.go]"]
  node_gcp["GCP KMS<br/>[keysource.go]"]
  node_azure["Azure Key Vault<br/>[keysource.go]"]
  node_huawei["Huawei KMS<br/>[keysource.go]"]
  node_vault["Vault Transit<br/>[keysource.go]"]
  node_age["age keys<br/>[keysource.go]"]
  node_pgp["PGP keys<br/>[keysource.go]"]
end

subgraph group_extensions["Publishing and service"]
  node_publish["Publish command<br/>[publish.go]"]
  node_publishers["Publish targets<br/>[publish.go]"]
  node_keyservice_cmd["Service command<br/>[keyservice.go]"]
end

node_user(("Operator"))

node_user -->|"runs commands"| node_cli
node_cli -->|"uses operations"| node_common
node_common -->|"reads settings"| node_config
node_common -->|"selects store"| node_yaml
node_common -->|"selects store"| node_json
node_common -->|"selects store"| node_dotenv
node_common -->|"selects store"| node_ini
node_stores -->|"serializes metadata"| node_yaml
node_stores -->|"serializes metadata"| node_json
node_stores -->|"serializes metadata"| node_dotenv
node_stores -->|"serializes metadata"| node_ini
node_core -->|"protects data key"| node_keyservice
node_core -->|"encrypts values"| node_cipher
node_core -->|"records events"| node_audit
node_server -->|"dispatches key ops"| node_aws
node_server -->|"dispatches key ops"| node_gcp
node_server -->|"dispatches key ops"| node_azure
node_server -->|"dispatches key ops"| node_huawei
node_server -->|"dispatches key ops"| node_vault
node_server -->|"dispatches key ops"| node_age
node_server -->|"dispatches key ops"| node_pgp
node_keyservice_cmd -->|"registers server"| node_server
node_cli -->|"invokes command"| node_publish
node_publish -->|"publishes output"| node_publishers
node_config -->|"configures keys"| node_aws
node_config -->|"configures keys"| node_gcp
node_config -->|"configures keys"| node_azure
node_config -->|"configures keys"| node_huawei
node_config -->|"configures keys"| node_vault
node_config -->|"configures keys"| node_age
node_config -->|"configures keys"| node_pgp

click node_cli "https://github.com/getsops/sops/blob/main/cmd/sops/main.go"
click node_common "https://github.com/getsops/sops/blob/main/cmd/sops/common/common.go"
click node_config "https://github.com/getsops/sops/blob/main/config/config.go"
click node_core "https://github.com/getsops/sops/blob/main/sops.go"
click node_cipher "https://github.com/getsops/sops/blob/main/aes/cipher.go"
click node_audit "https://github.com/getsops/sops/blob/main/audit/audit.go"
click node_stores "https://github.com/getsops/sops/blob/main/stores/stores.go"
click node_yaml "https://github.com/getsops/sops/blob/main/stores/yaml/store.go"
click node_json "https://github.com/getsops/sops/blob/main/stores/json/store.go"
click node_dotenv "https://github.com/getsops/sops/blob/main/stores/dotenv/store.go"
click node_ini "https://github.com/getsops/sops/blob/main/stores/ini/store.go"
click node_keyservice "https://github.com/getsops/sops/blob/main/keyservice/keyservice.go"
click node_server "https://github.com/getsops/sops/blob/main/keyservice/server.go"
click node_aws "https://github.com/getsops/sops/blob/main/kms/keysource.go"
click node_gcp "https://github.com/getsops/sops/blob/main/gcpkms/keysource.go"
click node_azure "https://github.com/getsops/sops/blob/main/azkv/keysource.go"
click node_huawei "https://github.com/getsops/sops/blob/main/hckms/keysource.go"
click node_vault "https://github.com/getsops/sops/blob/main/hcvault/keysource.go"
click node_age "https://github.com/getsops/sops/blob/main/age/keysource.go"
click node_pgp "https://github.com/getsops/sops/blob/main/pgp/keysource.go"
click node_publish "https://github.com/getsops/sops/blob/main/cmd/sops/subcommand/publish/publish.go"
click node_publishers "https://github.com/getsops/sops/blob/main/publish/publish.go"
click node_keyservice_cmd "https://github.com/getsops/sops/blob/main/cmd/sops/subcommand/keyservice/keyservice.go"

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_common,node_config toneBlue
class node_core,node_cipher,node_audit toneAmber
class node_stores,node_yaml,node_json,node_dotenv,node_ini toneMint
class node_keyservice,node_server,node_aws,node_gcp,node_azure,node_huawei,node_vault,node_age,node_pgp toneRose
class node_publish,node_publishers,node_keyservice_cmd,node_user toneIndigo
```

## Components

### CLI workflow

- [SOPS CLI](https://github.com/getsops/sops/blob/main/cmd/sops/main.go): `cmd/sops/main.go`
- [CLI operations](https://github.com/getsops/sops/blob/main/cmd/sops/common/common.go): `cmd/sops/common/common.go`
- [Configuration](https://github.com/getsops/sops/blob/main/config/config.go): `config/config.go`

### Encryption core

- [Encrypted tree](https://github.com/getsops/sops/blob/main/sops.go): `sops.go`
- [Value cipher](https://github.com/getsops/sops/blob/main/aes/cipher.go): `aes/cipher.go`
- [Audit logging](https://github.com/getsops/sops/blob/main/audit/audit.go): `audit/audit.go`

### File formats

- [SOPS metadata](https://github.com/getsops/sops/blob/main/stores/stores.go): `stores/stores.go`
- [YAML store](https://github.com/getsops/sops/blob/main/stores/yaml/store.go): `stores/yaml/store.go`
- [JSON and binary](https://github.com/getsops/sops/blob/main/stores/json/store.go): `stores/json/store.go`
- [ENV store](https://github.com/getsops/sops/blob/main/stores/dotenv/store.go): `stores/dotenv/store.go`
- [INI store](https://github.com/getsops/sops/blob/main/stores/ini/store.go): `stores/ini/store.go`

### Key management

- [Key service API](https://github.com/getsops/sops/blob/main/keyservice/keyservice.go): `keyservice/keyservice.go`
- [gRPC key server](https://github.com/getsops/sops/blob/main/keyservice/server.go): `keyservice/server.go`
- [AWS KMS](https://github.com/getsops/sops/blob/main/kms/keysource.go): `kms/keysource.go`
- [GCP KMS](https://github.com/getsops/sops/blob/main/gcpkms/keysource.go): `gcpkms/keysource.go`
- [Azure Key Vault](https://github.com/getsops/sops/blob/main/azkv/keysource.go): `azkv/keysource.go`
- [Huawei KMS](https://github.com/getsops/sops/blob/main/hckms/keysource.go): `hckms/keysource.go`
- [Vault Transit](https://github.com/getsops/sops/blob/main/hcvault/keysource.go): `hcvault/keysource.go`
- [age keys](https://github.com/getsops/sops/blob/main/age/keysource.go): `age/keysource.go`
- [PGP keys](https://github.com/getsops/sops/blob/main/pgp/keysource.go): `pgp/keysource.go`

### Publishing and service

- [Publish command](https://github.com/getsops/sops/blob/main/cmd/sops/subcommand/publish/publish.go): `cmd/sops/subcommand/publish/publish.go`
- [Publish targets](https://github.com/getsops/sops/blob/main/publish/publish.go): `publish/publish.go`
- [Service command](https://github.com/getsops/sops/blob/main/cmd/sops/subcommand/keyservice/keyservice.go): `cmd/sops/subcommand/keyservice/keyservice.go`

### Other components

- **Operator**

## Connections

- Operator → SOPS CLI: runs commands
- SOPS CLI → CLI operations: uses operations (evidence: `cmd/sops/main.go`)
- CLI operations → Configuration: reads settings (evidence: `cmd/sops/common/common.go`)
- CLI operations → YAML store: selects store (evidence: `cmd/sops/common/common.go`)
- CLI operations → JSON and binary: selects store (evidence: `cmd/sops/common/common.go`)
- CLI operations → ENV store: selects store (evidence: `cmd/sops/common/common.go`)
- CLI operations → INI store: selects store (evidence: `cmd/sops/common/common.go`)
- SOPS metadata → YAML store: serializes metadata (evidence: `stores/yaml/store.go`)
- SOPS metadata → JSON and binary: serializes metadata (evidence: `stores/json/store.go`)
- SOPS metadata → ENV store: serializes metadata (evidence: `stores/dotenv/store.go`)
- SOPS metadata → INI store: serializes metadata (evidence: `stores/ini/store.go`)
- Encrypted tree → Key service API: protects data key (evidence: `sops.go`)
- Encrypted tree → Value cipher: encrypts values (evidence: `sops.go`)
- Encrypted tree → Audit logging: records events (evidence: `sops.go`)
- gRPC key server → AWS KMS: dispatches key ops (evidence: `keyservice/server.go`)
- gRPC key server → GCP KMS: dispatches key ops (evidence: `keyservice/server.go`)
- gRPC key server → Azure Key Vault: dispatches key ops (evidence: `keyservice/server.go`)
- gRPC key server → Huawei KMS: dispatches key ops (evidence: `keyservice/server.go`)
- gRPC key server → Vault Transit: dispatches key ops (evidence: `keyservice/server.go`)
- gRPC key server → age keys: dispatches key ops (evidence: `keyservice/server.go`)
- gRPC key server → PGP keys: dispatches key ops (evidence: `keyservice/server.go`)
- Service command → gRPC key server: registers server (evidence: `cmd/sops/subcommand/keyservice/keyservice.go`)
- SOPS CLI → Publish command: invokes command (evidence: `cmd/sops/main.go`)
- Publish command → Publish targets: publishes output (evidence: `cmd/sops/subcommand/publish/publish.go`)
- Configuration → AWS KMS: configures keys (evidence: `config/config.go`)
- Configuration → GCP KMS: configures keys (evidence: `config/config.go`)
- Configuration → Azure Key Vault: configures keys (evidence: `config/config.go`)
- Configuration → Huawei KMS: configures keys (evidence: `config/config.go`)
- Configuration → Vault Transit: configures keys (evidence: `config/config.go`)
- Configuration → age keys: configures keys (evidence: `config/config.go`)
- Configuration → PGP keys: configures keys (evidence: `config/config.go`)
