# ranbai7/configraft architecture

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

- Interactive diagram: https://gitdiagram.com/ranbai7/configraft
- Repository: https://github.com/ranbai7/configraft

## Overview

Configraft is a strongly consistent distributed configuration service. Clients use its HTTP/gRPC API to read and mutate KV data, publish or roll back configuration versions, and long-poll Watch events; writes are applied locally or replicated through Raft before reaching the MVCC store. The graph also preserves the documented admin, membership-change, and Dashboard capabilities. Relationships are based on the README and indexed source excerpts; unsampled service details are not inferred beyond documented behavior.

Main entry points: [`src/server/server.cpp`](https://github.com/ranbai7/configraft/blob/main/src/server/server.cpp) (Server assembly), [`src/raft/raft_node.cpp`](https://github.com/ranbai7/configraft/blob/main/src/raft/raft_node.cpp) (Raft node), [`web/app.js`](https://github.com/ranbai7/configraft/blob/main/web/app.js) (Dashboard UI), [`src/watch/watch_hub.cpp`](https://github.com/ranbai7/configraft/blob/main/src/watch/watch_hub.cpp) (Watch event hub)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API services"]
  node_server["Server assembly<br/>[server.cpp]"]
  node_kv_api["KV API"]
  node_config_api["Config API"]
  node_watch_api["Watch API"]
  node_admin_api["Admin API"]
  node_rest_util["REST utilities<br/>[rest_util.h]"]
  node_proto["Service protocol<br/>[configraft.proto]"]
end

subgraph group_consensus["Node and consensus"]
  node_node_iface["Node interface<br/>[node.h]"]
  node_local_node["Single-node mode<br/>[local_node.cpp]"]
  node_raft_node["Raft node<br/>[raft_node.cpp]"]
  node_state_machine["Replicated state machine<br/>[state_machine.cpp]"]
end

subgraph group_data["State and storage"]
  node_store_ops["Command application<br/>[store_ops.cpp]"]
  node_store["MVCC store<br/>[store.cpp]"]
end

subgraph group_ops["Management and watch"]
  node_dashboard_service["Dashboard hosting"]
  node_dashboard_ui["Dashboard UI<br/>[app.js]"]
  node_watch_hub["Watch event hub<br/>[watch_hub.cpp]"]
end

node_clients(("Clients"))
node_dashboard_user(("Dashboard user"))
node_raft_cluster{{"Raft cluster"}}
node_leveldb[("LevelDB")]

node_clients -->|"HTTP or gRPC"| node_server
node_server -->|"registers"| node_kv_api
node_server -->|"registers"| node_config_api
node_server -->|"registers"| node_watch_api
node_server -->|"registers"| node_admin_api
node_server -->|"registers"| node_dashboard_service
node_server -->|"creates single-node"| node_local_node
node_server -->|"creates clustered node"| node_raft_node
node_server -->|"creates"| node_watch_hub
node_kv_api -->|"invokes operations"| node_node_iface
node_config_api -->|"invokes operations"| node_node_iface
node_watch_api -->|"invokes watch"| node_node_iface
node_admin_api -->|"queries or changes"| node_node_iface
node_dashboard_user -->|"opens dashboard"| node_dashboard_service
node_dashboard_service -->|"serves assets"| node_dashboard_ui
node_dashboard_ui -->|"uses KV operations"| node_kv_api
node_dashboard_ui -->|"uses config operations"| node_config_api
node_dashboard_ui -->|"observes events"| node_watch_api
node_dashboard_ui -->|"uses member operations"| node_admin_api
node_local_node -->|"applies commands"| node_store_ops
node_local_node -->|"broadcasts events"| node_watch_hub
node_raft_node -->|"submits replicated writes"| node_raft_cluster
node_raft_node -->|"configures state machine"| node_state_machine
node_raft_node -->|"serves long polls"| node_watch_hub
node_state_machine -->|"applies commands"| node_store_ops
node_state_machine -->|"broadcasts events"| node_watch_hub
node_store_ops -->|"mutates state"| node_store
node_store -->|"persists data"| node_leveldb
node_watch_hub -->|"replays history"| node_store
node_kv_api -->|"uses request helpers"| node_rest_util
node_config_api -->|"uses request helpers"| node_rest_util
node_watch_api -->|"uses request helpers"| node_rest_util
node_admin_api -->|"uses request helpers"| node_rest_util
node_server -->|"registers protocol services"| node_proto
node_raft_node -->|"reads local state"| node_store

click node_server "https://github.com/ranbai7/configraft/blob/main/src/server/server.cpp"
click node_kv_api "https://github.com/ranbai7/configraft/blob/main/src/server/kv_service_impl.cpp"
click node_config_api "https://github.com/ranbai7/configraft/blob/main/src/server/config_service_impl.cpp"
click node_watch_api "https://github.com/ranbai7/configraft/blob/main/src/server/watch_service_impl.cpp"
click node_admin_api "https://github.com/ranbai7/configraft/blob/main/src/server/admin_service_impl.cpp"
click node_rest_util "https://github.com/ranbai7/configraft/blob/main/src/server/rest_util.h"
click node_dashboard_service "https://github.com/ranbai7/configraft/blob/main/src/server/dashboard_service_impl.cpp"
click node_dashboard_ui "https://github.com/ranbai7/configraft/blob/main/web/app.js"
click node_node_iface "https://github.com/ranbai7/configraft/blob/main/src/raft/node.h"
click node_local_node "https://github.com/ranbai7/configraft/blob/main/src/raft/local_node.cpp"
click node_raft_node "https://github.com/ranbai7/configraft/blob/main/src/raft/raft_node.cpp"
click node_state_machine "https://github.com/ranbai7/configraft/blob/main/src/raft/state_machine.cpp"
click node_store_ops "https://github.com/ranbai7/configraft/blob/main/src/store/store_ops.cpp"
click node_store "https://github.com/ranbai7/configraft/blob/main/src/store/store.cpp"
click node_watch_hub "https://github.com/ranbai7/configraft/blob/main/src/watch/watch_hub.cpp"
click node_proto "https://github.com/ranbai7/configraft/blob/main/proto/configraft.proto"

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_server,node_kv_api,node_config_api,node_watch_api,node_admin_api,node_rest_util,node_proto,node_clients,node_dashboard_user toneBlue
class node_node_iface,node_local_node,node_raft_node,node_state_machine,node_leveldb toneAmber
class node_store_ops,node_store toneMint
class node_dashboard_service,node_dashboard_ui,node_watch_hub toneRose
class node_raft_cluster toneIndigo
```

## Components

### API services

- [Server assembly](https://github.com/ranbai7/configraft/blob/main/src/server/server.cpp): `src/server/server.cpp`
- [KV API](https://github.com/ranbai7/configraft/blob/main/src/server/kv_service_impl.cpp): `src/server/kv_service_impl.cpp`
- [Config API](https://github.com/ranbai7/configraft/blob/main/src/server/config_service_impl.cpp): `src/server/config_service_impl.cpp`
- [Watch API](https://github.com/ranbai7/configraft/blob/main/src/server/watch_service_impl.cpp): `src/server/watch_service_impl.cpp`
- [Admin API](https://github.com/ranbai7/configraft/blob/main/src/server/admin_service_impl.cpp): `src/server/admin_service_impl.cpp`
- [REST utilities](https://github.com/ranbai7/configraft/blob/main/src/server/rest_util.h): `src/server/rest_util.h`
- [Service protocol](https://github.com/ranbai7/configraft/blob/main/proto/configraft.proto): `proto/configraft.proto`

### Node and consensus

- [Node interface](https://github.com/ranbai7/configraft/blob/main/src/raft/node.h): `src/raft/node.h`
- [Single-node mode](https://github.com/ranbai7/configraft/blob/main/src/raft/local_node.cpp): `src/raft/local_node.cpp`
- [Raft node](https://github.com/ranbai7/configraft/blob/main/src/raft/raft_node.cpp): `src/raft/raft_node.cpp`
- [Replicated state machine](https://github.com/ranbai7/configraft/blob/main/src/raft/state_machine.cpp): `src/raft/state_machine.cpp`

### State and storage

- [Command application](https://github.com/ranbai7/configraft/blob/main/src/store/store_ops.cpp): `src/store/store_ops.cpp`
- [MVCC store](https://github.com/ranbai7/configraft/blob/main/src/store/store.cpp): `src/store/store.cpp`

### Management and watch

- [Dashboard hosting](https://github.com/ranbai7/configraft/blob/main/src/server/dashboard_service_impl.cpp): `src/server/dashboard_service_impl.cpp`
- [Dashboard UI](https://github.com/ranbai7/configraft/blob/main/web/app.js): `web/app.js`
- [Watch event hub](https://github.com/ranbai7/configraft/blob/main/src/watch/watch_hub.cpp): `src/watch/watch_hub.cpp`

### Other components

- **Clients**
- **Dashboard user**
- **Raft cluster**
- **LevelDB**

## Connections

- Clients → Server assembly: HTTP or gRPC (evidence: `README.md`)
- Server assembly → KV API: registers (evidence: `src/server/server.cpp`)
- Server assembly → Config API: registers (evidence: `src/server/server.cpp`)
- Server assembly → Watch API: registers (evidence: `src/server/server.cpp`)
- Server assembly → Admin API: registers (evidence: `src/server/server.cpp`)
- Server assembly → Dashboard hosting: registers (evidence: `src/server/server.cpp`)
- Server assembly → Single-node mode: creates single-node (evidence: `src/server/server.cpp`)
- Server assembly → Raft node: creates clustered node (evidence: `src/server/server.cpp`)
- Server assembly → Watch event hub: creates (evidence: `src/server/server.cpp`)
- KV API → Node interface: invokes operations (evidence: `src/server/kv_service_impl.cpp`)
- Config API → Node interface: invokes operations (evidence: `src/server/config_service_impl.cpp`)
- Watch API → Node interface: invokes watch (evidence: `src/server/watch_service_impl.cpp`)
- Admin API → Node interface: queries or changes (evidence: `src/server/admin_service_impl.cpp`)
- Dashboard user → Dashboard hosting: opens dashboard (evidence: `README.md`)
- Dashboard hosting → Dashboard UI: serves assets
- Dashboard UI → KV API: uses KV operations (evidence: `README.md`)
- Dashboard UI → Config API: uses config operations (evidence: `README.md`)
- Dashboard UI → Watch API: observes events (evidence: `README.md`)
- Dashboard UI → Admin API: uses member operations (evidence: `README.md`)
- Single-node mode → Command application: applies commands (evidence: `src/raft/local_node.cpp`)
- Single-node mode → Watch event hub: broadcasts events (evidence: `src/raft/local_node.cpp`)
- Raft node → Raft cluster: submits replicated writes (evidence: `README.md`)
- Raft node → Replicated state machine: configures state machine (evidence: `src/raft/raft_node.cpp`)
- Raft node → Watch event hub: serves long polls (evidence: `src/raft/raft_node.cpp`)
- Replicated state machine → Command application: applies commands (evidence: `src/raft/state_machine.cpp`)
- Replicated state machine → Watch event hub: broadcasts events (evidence: `src/raft/state_machine.cpp`)
- Command application → MVCC store: mutates state (evidence: `src/store/store_ops.cpp`)
- MVCC store → LevelDB: persists data (evidence: `README.md`)
- Watch event hub → MVCC store: replays history (evidence: `src/watch/watch_hub.cpp`)
- KV API → REST utilities: uses request helpers (evidence: `src/server/kv_service_impl.cpp`)
- Config API → REST utilities: uses request helpers (evidence: `src/server/config_service_impl.cpp`)
- Watch API → REST utilities: uses request helpers (evidence: `src/server/watch_service_impl.cpp`)
- Admin API → REST utilities: uses request helpers (evidence: `src/server/admin_service_impl.cpp`)
- Server assembly → Service protocol: registers protocol services (evidence: `README.md`)
- Raft node → MVCC store: reads local state (evidence: `src/raft/raft_node.cpp`)
