# qdrvm/kagome architecture

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

- Interactive diagram: https://gitdiagram.com/qdrvm/kagome
- Repository: https://github.com/qdrvm/kagome

## Overview

KAGOME is a Polkadot Host node. Its principal workflow is to start from chain configuration, connect to peers, synchronize and import blocks, execute runtime logic against state, and participate in consensus; JSON-RPC exposes node and chain data to clients. The README also documents parachain processing, keystore, offchain workers, telemetry, and metrics. Several runtime and orchestration links are inferred from the documented product workflow rather than sampled call sites, so those edges are dashed and uncited.

Main entry points: [`core/application/impl/kagome_application_impl.cpp`](https://github.com/qdrvm/kagome/blob/master/core/application/impl/kagome_application_impl.cpp) (Application setup), [`core/network/impl/peer_manager_impl.cpp`](https://github.com/qdrvm/kagome/blob/master/core/network/impl/peer_manager_impl.cpp) (Peer networking), [`core/consensus/timeline/impl/timeline_impl.cpp`](https://github.com/qdrvm/kagome/blob/master/core/consensus/timeline/impl/timeline_impl.cpp) (Chain synchronization), [`core/runtime/common/trie_storage_provider_impl.cpp`](https://github.com/qdrvm/kagome/blob/master/core/runtime/common/trie_storage_provider_impl.cpp) (Runtime execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_node["Node lifecycle"]
  node_application["Application setup"]
  node_configuration["Chain configuration"]
end

subgraph group_network["Networking and sync"]
  node_peer_network["Peer networking"]
  node_sync["Chain synchronization<br/>[timeline_impl.cpp]"]
  node_authority_discovery["Authority discovery<br/>[query_impl.cpp]"]
end

subgraph group_chain["Chain processing"]
  node_block_storage[("Block storage")]
  node_block_tree[("Block tree")]
  node_block_execution["Block execution"]
  node_babe["BABE production<br/>[babe.cpp]"]
  node_grandpa["GRANDPA finality<br/>[grandpa_impl.cpp]"]
  node_parachains["Parachain processing"]
end

subgraph group_runtime["Runtime and storage"]
  node_runtime["Runtime execution"]
  node_host_api["Runtime host API"]
  node_trie_storage[("Trie state")]
end

subgraph group_interfaces["APIs and operations"]
  node_rpc_transport["WebSocket transport<br/>[ws_session.cpp]"]
  node_rpc_service["JSON-RPC services"]
  node_keystore[("Keystore")]
  node_offchain[("Offchain workers")]
  node_telemetry["Telemetry<br/>[service_impl.cpp]"]
  node_metrics["Prometheus metrics<br/>[handler_impl.cpp]"]
end

node_operator(("Node operator"))
node_rpc_client(("RPC client"))
node_peer_nodes(("Polkadot peers"))

node_operator -.->|"starts node"| node_application
node_application -.->|"loads settings"| node_configuration
node_application -.->|"starts services"| node_peer_network
node_peer_network -.->|"exchanges blocks"| node_peer_nodes
node_peer_network -.->|"supplies chain data"| node_sync
node_sync -.->|"stores blocks"| node_block_storage
node_block_storage -.->|"tracks chain"| node_block_tree
node_sync -.->|"imports blocks"| node_block_execution
node_block_execution -.->|"executes runtime"| node_runtime
node_runtime -.->|"invokes host functions"| node_host_api
node_host_api -->|"accesses state"| node_trie_storage
node_runtime -->|"manages state batches"| node_trie_storage
node_application -.->|"enables consensus"| node_babe
node_application -.->|"enables finality"| node_grandpa
node_application -.->|"enables parachain processing"| node_parachains
node_application -.->|"starts discovery"| node_authority_discovery
node_rpc_client -.->|"sends requests"| node_rpc_transport
node_rpc_transport -.->|"dispatches RPC"| node_rpc_service
node_rpc_service -.->|"queries chain"| node_block_storage
node_rpc_service -.->|"queries state"| node_trie_storage
node_application -.->|"uses keys"| node_keystore
node_application -.->|"runs workers"| node_offchain
node_application -.->|"reports node status"| node_telemetry
node_application -.->|"exposes metrics"| node_metrics

click node_application "https://github.com/qdrvm/kagome/blob/master/core/application/impl/kagome_application_impl.cpp"
click node_configuration "https://github.com/qdrvm/kagome/blob/master/core/application/impl/app_configuration_impl.cpp"
click node_peer_network "https://github.com/qdrvm/kagome/blob/master/core/network/impl/peer_manager_impl.cpp"
click node_sync "https://github.com/qdrvm/kagome/blob/master/core/consensus/timeline/impl/timeline_impl.cpp"
click node_authority_discovery "https://github.com/qdrvm/kagome/blob/master/core/authority_discovery/query/query_impl.cpp"
click node_block_storage "https://github.com/qdrvm/kagome/blob/master/core/blockchain/impl/block_storage_impl.cpp"
click node_block_tree "https://github.com/qdrvm/kagome/blob/master/core/blockchain/impl/block_tree_impl.cpp"
click node_block_execution "https://github.com/qdrvm/kagome/blob/master/core/consensus/timeline/impl/block_executor_impl.cpp"
click node_babe "https://github.com/qdrvm/kagome/blob/master/core/consensus/babe/impl/babe.cpp"
click node_grandpa "https://github.com/qdrvm/kagome/blob/master/core/consensus/grandpa/impl/grandpa_impl.cpp"
click node_parachains "https://github.com/qdrvm/kagome/blob/master/core/dispute_coordinator/impl/dispute_coordinator_impl.cpp"
click node_runtime "https://github.com/qdrvm/kagome/blob/master/core/runtime/common/trie_storage_provider_impl.cpp"
click node_host_api "https://github.com/qdrvm/kagome/blob/master/core/host_api/impl/storage_extension.cpp"
click node_trie_storage "https://github.com/qdrvm/kagome/blob/master/core/storage/trie/impl/trie_storage_impl.cpp"
click node_rpc_transport "https://github.com/qdrvm/kagome/blob/master/core/api/transport/impl/ws/ws_session.cpp"
click node_rpc_service "https://github.com/qdrvm/kagome/blob/master/core/api/service/impl/api_service_impl.cpp"
click node_keystore "https://github.com/qdrvm/kagome/blob/master/core/crypto/key_store/key_file_storage.cpp"
click node_offchain "https://github.com/qdrvm/kagome/blob/master/core/offchain/impl/offchain_persistent_storage.cpp"
click node_telemetry "https://github.com/qdrvm/kagome/blob/master/core/telemetry/impl/service_impl.cpp"
click node_metrics "https://github.com/qdrvm/kagome/blob/master/core/metrics/impl/prometheus/handler_impl.cpp"

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_application,node_configuration,node_rpc_client toneBlue
class node_peer_network,node_sync,node_authority_discovery toneAmber
class node_block_storage,node_block_tree,node_block_execution,node_babe,node_grandpa,node_parachains toneMint
class node_runtime,node_host_api,node_trie_storage toneRose
class node_rpc_transport,node_rpc_service,node_keystore,node_offchain,node_telemetry,node_metrics,node_operator,node_peer_nodes toneIndigo
```

## Components

### Node lifecycle

- [Application setup](https://github.com/qdrvm/kagome/blob/master/core/application/impl/kagome_application_impl.cpp): `core/application/impl/kagome_application_impl.cpp`
- [Chain configuration](https://github.com/qdrvm/kagome/blob/master/core/application/impl/app_configuration_impl.cpp): `core/application/impl/app_configuration_impl.cpp`

### Networking and sync

- [Peer networking](https://github.com/qdrvm/kagome/blob/master/core/network/impl/peer_manager_impl.cpp): `core/network/impl/peer_manager_impl.cpp`
- [Chain synchronization](https://github.com/qdrvm/kagome/blob/master/core/consensus/timeline/impl/timeline_impl.cpp): `core/consensus/timeline/impl/timeline_impl.cpp`
- [Authority discovery](https://github.com/qdrvm/kagome/blob/master/core/authority_discovery/query/query_impl.cpp): `core/authority_discovery/query/query_impl.cpp`

### Chain processing

- [Block storage](https://github.com/qdrvm/kagome/blob/master/core/blockchain/impl/block_storage_impl.cpp): `core/blockchain/impl/block_storage_impl.cpp`
- [Block tree](https://github.com/qdrvm/kagome/blob/master/core/blockchain/impl/block_tree_impl.cpp): `core/blockchain/impl/block_tree_impl.cpp`
- [Block execution](https://github.com/qdrvm/kagome/blob/master/core/consensus/timeline/impl/block_executor_impl.cpp): `core/consensus/timeline/impl/block_executor_impl.cpp`
- [BABE production](https://github.com/qdrvm/kagome/blob/master/core/consensus/babe/impl/babe.cpp): `core/consensus/babe/impl/babe.cpp`
- [GRANDPA finality](https://github.com/qdrvm/kagome/blob/master/core/consensus/grandpa/impl/grandpa_impl.cpp): `core/consensus/grandpa/impl/grandpa_impl.cpp`
- [Parachain processing](https://github.com/qdrvm/kagome/blob/master/core/dispute_coordinator/impl/dispute_coordinator_impl.cpp): `core/dispute_coordinator/impl/dispute_coordinator_impl.cpp`

### Runtime and storage

- [Runtime execution](https://github.com/qdrvm/kagome/blob/master/core/runtime/common/trie_storage_provider_impl.cpp): `core/runtime/common/trie_storage_provider_impl.cpp`
- [Runtime host API](https://github.com/qdrvm/kagome/blob/master/core/host_api/impl/storage_extension.cpp): `core/host_api/impl/storage_extension.cpp`
- [Trie state](https://github.com/qdrvm/kagome/blob/master/core/storage/trie/impl/trie_storage_impl.cpp): `core/storage/trie/impl/trie_storage_impl.cpp`

### APIs and operations

- [WebSocket transport](https://github.com/qdrvm/kagome/blob/master/core/api/transport/impl/ws/ws_session.cpp): `core/api/transport/impl/ws/ws_session.cpp`
- [JSON-RPC services](https://github.com/qdrvm/kagome/blob/master/core/api/service/impl/api_service_impl.cpp): `core/api/service/impl/api_service_impl.cpp`
- [Keystore](https://github.com/qdrvm/kagome/blob/master/core/crypto/key_store/key_file_storage.cpp): `core/crypto/key_store/key_file_storage.cpp`
- [Offchain workers](https://github.com/qdrvm/kagome/blob/master/core/offchain/impl/offchain_persistent_storage.cpp): `core/offchain/impl/offchain_persistent_storage.cpp`
- [Telemetry](https://github.com/qdrvm/kagome/blob/master/core/telemetry/impl/service_impl.cpp): `core/telemetry/impl/service_impl.cpp`
- [Prometheus metrics](https://github.com/qdrvm/kagome/blob/master/core/metrics/impl/prometheus/handler_impl.cpp): `core/metrics/impl/prometheus/handler_impl.cpp`

### Other components

- **Node operator**
- **RPC client**
- **Polkadot peers**

## Connections

- Node operator → Application setup: starts node
- Application setup → Chain configuration: loads settings
- Application setup → Peer networking: starts services
- Peer networking → Polkadot peers: exchanges blocks
- Peer networking → Chain synchronization: supplies chain data
- Chain synchronization → Block storage: stores blocks
- Block storage → Block tree: tracks chain
- Chain synchronization → Block execution: imports blocks
- Block execution → Runtime execution: executes runtime
- Runtime execution → Runtime host API: invokes host functions
- Runtime host API → Trie state: accesses state (evidence: `core/host_api/impl/storage_extension.cpp`)
- Runtime execution → Trie state: manages state batches (evidence: `core/runtime/common/trie_storage_provider_impl.cpp`)
- Application setup → BABE production: enables consensus
- Application setup → GRANDPA finality: enables finality
- Application setup → Parachain processing: enables parachain processing
- Application setup → Authority discovery: starts discovery
- RPC client → WebSocket transport: sends requests
- WebSocket transport → JSON-RPC services: dispatches RPC
- JSON-RPC services → Block storage: queries chain
- JSON-RPC services → Trie state: queries state
- Application setup → Keystore: uses keys
- Application setup → Offchain workers: runs workers
- Application setup → Telemetry: reports node status
- Application setup → Prometheus metrics: exposes metrics
