# spiffe/spike architecture

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

- Interactive diagram: https://gitdiagram.com/spiffe/spike
- Repository: https://github.com/spiffe/spike

## Overview

SPIKE is a SPIFFE-identity-based secrets store. Pilot is the operator/user interface; Nexus serves secret and policy operations and manages the root key, while Keeper holds redundant key shards and Bootstrap distributes initial shards and verifies Nexus. The graph preserves the documented product roles and sampled runtime links. Some capabilities, including secret CLI commands and detailed route wiring, are not represented in the supplied tree or excerpts; those links are omitted rather than inferred.

Main entry points: [`app/nexus/cmd/main.go`](https://github.com/spiffe/spike/blob/main/app/nexus/cmd/main.go) (Nexus entry), [`app/spike/cmd/main.go`](https://github.com/spiffe/spike/blob/main/app/spike/cmd/main.go) (Pilot entry), [`app/spike/internal/cmd/cmd.go`](https://github.com/spiffe/spike/blob/main/app/spike/internal/cmd/cmd.go) (Command router), [`app/bootstrap/internal/net/broadcast.go`](https://github.com/spiffe/spike/blob/main/app/bootstrap/internal/net/broadcast.go) (Shard broadcast)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pilot["Pilot CLI"]
  node_pilot_entry["Pilot entry<br/>[main.go]"]
  node_pilot_commands["Command router<br/>[cmd.go]"]
  node_pilot_policy["Policy commands<br/>[query.go]"]
  node_pilot_operator["Recovery commands<br/>[restore.go]"]
end

subgraph group_nexus["Nexus service"]
  node_nexus_entry["Nexus entry<br/>[main.go]"]
  node_nexus_init["State initialization<br/>[initialization.go]"]
  node_nexus_recovery["Key recovery<br/>[recovery.go]"]
  node_nexus_routes["HTTP route base<br/>[impl.go]"]
  node_nexus_cipher["Cipher routes<br/>[handle.go]"]
  node_nexus_policy["Policy state<br/>[policy.go]"]
  node_nexus_persist["Persistence interface<br/>[backend.go]"]
  node_nexus_backends["State backends<br/>[interface.go]"]
  node_sqlite_store[("SQLite persistence<br/>[policy.go]")]
end

subgraph group_keeper["Keeper redundancy"]
  node_keeper_entry["Keeper entry<br/>[main.go]"]
  node_keeper_routes["Keeper route base<br/>[route.go]"]
  node_keeper_shards["Shard contribution<br/>[contribute.go]"]
  node_keeper_state["Shard state<br/>[shard.go]"]
end

subgraph group_bootstrap["Bootstrap"]
  node_bootstrap_entry["Bootstrap entry<br/>[main.go]"]
  node_bootstrap_lifecycle["Bootstrap lifecycle<br/>[lifecycle.go]"]
  node_bootstrap_broadcast["Shard broadcast<br/>[broadcast.go]"]
end

node_operator(("Operator"))

node_operator -->|"runs"| node_pilot_entry
node_pilot_entry -->|"initializes"| node_pilot_commands
node_pilot_commands -->|"registers"| node_pilot_policy
node_pilot_commands -->|"registers"| node_pilot_operator
node_pilot_entry -.->|"calls by mTLS"| node_nexus_entry
node_nexus_entry -->|"initializes"| node_nexus_init
node_nexus_entry -->|"serves"| node_nexus_routes
node_nexus_init -->|"starts recovery"| node_nexus_recovery
node_nexus_recovery -->|"initializes state"| node_nexus_policy
node_nexus_cipher -->|"uses state"| node_nexus_policy
node_nexus_policy -->|"loads and writes"| node_nexus_persist
node_nexus_persist -.->|"selects backend"| node_nexus_backends
node_nexus_backends -.->|"persists with"| node_sqlite_store
node_keeper_entry -->|"serves"| node_keeper_routes
node_keeper_routes -->|"routes requests"| node_keeper_shards
node_keeper_shards -->|"stores shard"| node_keeper_state
node_bootstrap_entry -->|"checks completion"| node_bootstrap_lifecycle
node_bootstrap_entry -->|"broadcasts and verifies"| node_bootstrap_broadcast
node_bootstrap_broadcast -->|"sends shards"| node_keeper_entry
node_bootstrap_broadcast -->|"verifies initialization"| node_nexus_entry

click node_pilot_entry "https://github.com/spiffe/spike/blob/main/app/spike/cmd/main.go"
click node_pilot_commands "https://github.com/spiffe/spike/blob/main/app/spike/internal/cmd/cmd.go"
click node_pilot_policy "https://github.com/spiffe/spike/blob/main/app/spike/internal/cmd/policy/query.go"
click node_pilot_operator "https://github.com/spiffe/spike/blob/main/app/spike/internal/cmd/operator/restore.go"
click node_nexus_entry "https://github.com/spiffe/spike/blob/main/app/nexus/cmd/main.go"
click node_nexus_init "https://github.com/spiffe/spike/blob/main/app/nexus/internal/initialization/initialization.go"
click node_nexus_recovery "https://github.com/spiffe/spike/blob/main/app/nexus/internal/initialization/recovery/recovery.go"
click node_nexus_routes "https://github.com/spiffe/spike/blob/main/app/nexus/internal/route/base/impl.go"
click node_nexus_cipher "https://github.com/spiffe/spike/blob/main/app/nexus/internal/route/cipher/handle.go"
click node_nexus_policy "https://github.com/spiffe/spike/blob/main/app/nexus/internal/state/base/policy.go"
click node_nexus_persist "https://github.com/spiffe/spike/blob/main/app/nexus/internal/state/persist/backend.go"
click node_nexus_backends "https://github.com/spiffe/spike/blob/main/app/nexus/internal/state/backend/interface.go"
click node_sqlite_store "https://github.com/spiffe/spike/blob/main/app/nexus/internal/state/backend/sqlite/persist/policy.go"
click node_keeper_entry "https://github.com/spiffe/spike/blob/main/app/keeper/cmd/main.go"
click node_keeper_routes "https://github.com/spiffe/spike/blob/main/app/keeper/internal/route/base/route.go"
click node_keeper_shards "https://github.com/spiffe/spike/blob/main/app/keeper/internal/route/store/contribute.go"
click node_keeper_state "https://github.com/spiffe/spike/blob/main/app/keeper/internal/state/shard.go"
click node_bootstrap_entry "https://github.com/spiffe/spike/blob/main/app/bootstrap/cmd/main.go"
click node_bootstrap_lifecycle "https://github.com/spiffe/spike/blob/main/app/bootstrap/internal/lifecycle/lifecycle.go"
click node_bootstrap_broadcast "https://github.com/spiffe/spike/blob/main/app/bootstrap/internal/net/broadcast.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_pilot_entry,node_pilot_commands,node_pilot_policy,node_pilot_operator toneBlue
class node_nexus_entry,node_nexus_init,node_nexus_recovery,node_nexus_routes,node_nexus_cipher,node_nexus_policy,node_nexus_persist,node_nexus_backends,node_sqlite_store toneAmber
class node_keeper_entry,node_keeper_routes,node_keeper_shards,node_keeper_state toneMint
class node_bootstrap_entry,node_bootstrap_lifecycle,node_bootstrap_broadcast toneRose
class node_operator toneIndigo
```

## Components

### Pilot CLI

- [Pilot entry](https://github.com/spiffe/spike/blob/main/app/spike/cmd/main.go): `app/spike/cmd/main.go`
- [Command router](https://github.com/spiffe/spike/blob/main/app/spike/internal/cmd/cmd.go): `app/spike/internal/cmd/cmd.go`
- [Policy commands](https://github.com/spiffe/spike/blob/main/app/spike/internal/cmd/policy/query.go): `app/spike/internal/cmd/policy/query.go`
- [Recovery commands](https://github.com/spiffe/spike/blob/main/app/spike/internal/cmd/operator/restore.go): `app/spike/internal/cmd/operator/restore.go`

### Nexus service

- [Nexus entry](https://github.com/spiffe/spike/blob/main/app/nexus/cmd/main.go): `app/nexus/cmd/main.go`
- [State initialization](https://github.com/spiffe/spike/blob/main/app/nexus/internal/initialization/initialization.go): `app/nexus/internal/initialization/initialization.go`
- [Key recovery](https://github.com/spiffe/spike/blob/main/app/nexus/internal/initialization/recovery/recovery.go): `app/nexus/internal/initialization/recovery/recovery.go`
- [HTTP route base](https://github.com/spiffe/spike/blob/main/app/nexus/internal/route/base/impl.go): `app/nexus/internal/route/base/impl.go`
- [Cipher routes](https://github.com/spiffe/spike/blob/main/app/nexus/internal/route/cipher/handle.go): `app/nexus/internal/route/cipher/handle.go`
- [Policy state](https://github.com/spiffe/spike/blob/main/app/nexus/internal/state/base/policy.go): `app/nexus/internal/state/base/policy.go`
- [Persistence interface](https://github.com/spiffe/spike/blob/main/app/nexus/internal/state/persist/backend.go): `app/nexus/internal/state/persist/backend.go`
- [State backends](https://github.com/spiffe/spike/blob/main/app/nexus/internal/state/backend/interface.go): `app/nexus/internal/state/backend/interface.go`
- [SQLite persistence](https://github.com/spiffe/spike/blob/main/app/nexus/internal/state/backend/sqlite/persist/policy.go): `app/nexus/internal/state/backend/sqlite/persist/policy.go`

### Keeper redundancy

- [Keeper entry](https://github.com/spiffe/spike/blob/main/app/keeper/cmd/main.go): `app/keeper/cmd/main.go`
- [Keeper route base](https://github.com/spiffe/spike/blob/main/app/keeper/internal/route/base/route.go): `app/keeper/internal/route/base/route.go`
- [Shard contribution](https://github.com/spiffe/spike/blob/main/app/keeper/internal/route/store/contribute.go): `app/keeper/internal/route/store/contribute.go`
- [Shard state](https://github.com/spiffe/spike/blob/main/app/keeper/internal/state/shard.go): `app/keeper/internal/state/shard.go`

### Bootstrap

- [Bootstrap entry](https://github.com/spiffe/spike/blob/main/app/bootstrap/cmd/main.go): `app/bootstrap/cmd/main.go`
- [Bootstrap lifecycle](https://github.com/spiffe/spike/blob/main/app/bootstrap/internal/lifecycle/lifecycle.go): `app/bootstrap/internal/lifecycle/lifecycle.go`
- [Shard broadcast](https://github.com/spiffe/spike/blob/main/app/bootstrap/internal/net/broadcast.go): `app/bootstrap/internal/net/broadcast.go`

### Other components

- **Operator**

## Connections

- Operator → Pilot entry: runs
- Pilot entry → Command router: initializes (evidence: `app/spike/cmd/main.go`)
- Command router → Policy commands: registers (evidence: `app/spike/internal/cmd/cmd.go`)
- Command router → Recovery commands: registers (evidence: `app/spike/internal/cmd/cmd.go`)
- Pilot entry → Nexus entry: calls by mTLS
- Nexus entry → State initialization: initializes (evidence: `app/nexus/cmd/main.go`)
- Nexus entry → HTTP route base: serves (evidence: `app/nexus/cmd/main.go`)
- State initialization → Key recovery: starts recovery (evidence: `app/nexus/internal/initialization/initialization.go`)
- Key recovery → Policy state: initializes state (evidence: `app/nexus/internal/initialization/recovery/recovery.go`)
- Cipher routes → Policy state: uses state (evidence: `app/nexus/internal/route/cipher/handle.go`)
- Policy state → Persistence interface: loads and writes (evidence: `app/nexus/internal/state/base/policy.go`)
- Persistence interface → State backends: selects backend
- State backends → SQLite persistence: persists with
- Keeper entry → Keeper route base: serves (evidence: `app/keeper/cmd/main.go`)
- Keeper route base → Shard contribution: routes requests (evidence: `app/keeper/internal/route/base/route.go`)
- Shard contribution → Shard state: stores shard (evidence: `app/keeper/internal/route/store/contribute.go`)
- Bootstrap entry → Bootstrap lifecycle: checks completion (evidence: `app/bootstrap/cmd/main.go`)
- Bootstrap entry → Shard broadcast: broadcasts and verifies (evidence: `app/bootstrap/cmd/main.go`)
- Shard broadcast → Keeper entry: sends shards (evidence: `app/bootstrap/internal/net/broadcast.go`)
- Shard broadcast → Nexus entry: verifies initialization (evidence: `app/bootstrap/internal/net/broadcast.go`)
