# valkey-io/valkey architecture

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

- Interactive diagram: https://gitdiagram.com/valkey-io/valkey
- Repository: https://github.com/valkey-io/valkey

## Overview

Valkey is a high-performance key/value data-structure server. The principal workflow is: a client sends a RESP command, networking parses it, command dispatch performs authorization and execution against native data structures, then a reply returns through the connection. The server also supports persistence, replication, clustering, Sentinel, scripting, modules, TLS, and experimental RDMA. Sampled source confirms the scripting-manager/Lua-engine boundary; several other subsystem links are based on the documented product structure and exact tree paths.

Main entry points: [`src/networking.c`](https://github.com/valkey-io/valkey/blob/unstable/src/networking.c) (Networking), [`src/commands.c`](https://github.com/valkey-io/valkey/blob/unstable/src/commands.c) (Command Dispatch), [`src/server.c`](https://github.com/valkey-io/valkey/blob/unstable/src/server.c) (Server Runtime), [`src/db.c`](https://github.com/valkey-io/valkey/blob/unstable/src/db.c) (Core Data Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Client Access"]
  node_event_loop["Event Loop<br/>[ae.c]"]
  node_networking["Networking<br/>[networking.c]"]
  node_resp["RESP Parser<br/>[resp_parser.c]"]
  node_tls["TLS Transport<br/>[tls.c]"]
  node_rdma["RDMA Transport<br/>[rdma.c]"]
end

subgraph group_core["Command Core"]
  node_server["Server Runtime<br/>[server.c]"]
  node_dispatch["Command Dispatch<br/>[commands.c]"]
  node_acl["Access Control<br/>[acl.c]"]
  node_store[("Core Data Store<br/>[db.c]")]
  node_native_types["Native Structures<br/>[t_string.c]"]
  node_pubsub["Pub/Sub<br/>[pubsub.c]"]
end

subgraph group_state["State Services"]
  node_rdb["RDB Snapshots<br/>[rdb.c]"]
  node_aof["AOF Log<br/>[aof.c]"]
  node_replication["Replication<br/>[replication.c]"]
  node_cluster["Cluster Coordination<br/>[cluster.c]"]
  node_sentinel["Sentinel Monitoring<br/>[sentinel.c]"]
  node_latency["Latency Metrics<br/>[latency.c]"]
end

subgraph group_ext["Extensions"]
  node_module_api["Module Runtime<br/>[module.c]"]
  node_scripting["Scripting Manager<br/>[scripting_engine.c]"]
  node_lua["Lua Engine<br/>[engine_lua.c]"]
end

node_client(("Application Client"))
node_operator(("Operator"))

node_client -->|"sends commands"| node_networking
node_operator -->|"configures server"| node_server
node_server -->|"runs loop"| node_event_loop
node_event_loop -->|"handles events"| node_networking
node_networking -->|"parses requests"| node_resp
node_networking -->|"dispatches commands"| node_dispatch
node_dispatch -->|"checks access"| node_acl
node_dispatch -->|"executes commands"| node_store
node_dispatch -->|"uses structures"| node_native_types
node_dispatch -->|"handles channels"| node_pubsub
node_dispatch -->|"invokes modules"| node_module_api
node_dispatch -->|"invokes scripts"| node_scripting
node_dispatch -->|"records writes"| node_aof
node_store -->|"persists state"| node_rdb
node_rdb -->|"loads state"| node_store
node_server -->|"manages replicas"| node_replication
node_server -->|"coordinates shards"| node_cluster
node_server -->|"runs monitoring"| node_sentinel
node_replication -->|"streams updates"| node_networking
node_cluster -->|"handles cluster links"| node_networking
node_networking -.->|"secures transport"| node_tls
node_networking -.->|"uses RDMA"| node_rdma
node_scripting -->|"calls engine"| node_lua
node_lua -->|"uses module API"| node_module_api
node_server -->|"tracks latency"| node_latency
node_dispatch -->|"queues replies"| node_networking
node_networking -->|"returns replies"| node_client

click node_server "https://github.com/valkey-io/valkey/blob/unstable/src/server.c"
click node_event_loop "https://github.com/valkey-io/valkey/blob/unstable/src/ae.c"
click node_networking "https://github.com/valkey-io/valkey/blob/unstable/src/networking.c"
click node_resp "https://github.com/valkey-io/valkey/blob/unstable/src/resp_parser.c"
click node_dispatch "https://github.com/valkey-io/valkey/blob/unstable/src/commands.c"
click node_acl "https://github.com/valkey-io/valkey/blob/unstable/src/acl.c"
click node_store "https://github.com/valkey-io/valkey/blob/unstable/src/db.c"
click node_native_types "https://github.com/valkey-io/valkey/blob/unstable/src/t_string.c"
click node_pubsub "https://github.com/valkey-io/valkey/blob/unstable/src/pubsub.c"
click node_rdb "https://github.com/valkey-io/valkey/blob/unstable/src/rdb.c"
click node_aof "https://github.com/valkey-io/valkey/blob/unstable/src/aof.c"
click node_replication "https://github.com/valkey-io/valkey/blob/unstable/src/replication.c"
click node_cluster "https://github.com/valkey-io/valkey/blob/unstable/src/cluster.c"
click node_sentinel "https://github.com/valkey-io/valkey/blob/unstable/src/sentinel.c"
click node_tls "https://github.com/valkey-io/valkey/blob/unstable/src/tls.c"
click node_rdma "https://github.com/valkey-io/valkey/blob/unstable/src/rdma.c"
click node_module_api "https://github.com/valkey-io/valkey/blob/unstable/src/module.c"
click node_scripting "https://github.com/valkey-io/valkey/blob/unstable/src/scripting_engine.c"
click node_lua "https://github.com/valkey-io/valkey/blob/unstable/src/modules/lua/engine_lua.c"
click node_latency "https://github.com/valkey-io/valkey/blob/unstable/src/latency.c"

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_event_loop,node_networking,node_resp,node_tls,node_rdma,node_client toneBlue
class node_server,node_dispatch,node_acl,node_store,node_native_types,node_pubsub toneAmber
class node_rdb,node_aof,node_replication,node_cluster,node_sentinel,node_latency toneMint
class node_module_api,node_scripting,node_lua toneRose
class node_operator toneIndigo
```

## Components

### Client Access

- [Event Loop](https://github.com/valkey-io/valkey/blob/unstable/src/ae.c): `src/ae.c`
- [Networking](https://github.com/valkey-io/valkey/blob/unstable/src/networking.c): `src/networking.c`
- [RESP Parser](https://github.com/valkey-io/valkey/blob/unstable/src/resp_parser.c): `src/resp_parser.c`
- [TLS Transport](https://github.com/valkey-io/valkey/blob/unstable/src/tls.c): `src/tls.c`
- [RDMA Transport](https://github.com/valkey-io/valkey/blob/unstable/src/rdma.c): `src/rdma.c`

### Command Core

- [Server Runtime](https://github.com/valkey-io/valkey/blob/unstable/src/server.c): `src/server.c`
- [Command Dispatch](https://github.com/valkey-io/valkey/blob/unstable/src/commands.c): `src/commands.c`
- [Access Control](https://github.com/valkey-io/valkey/blob/unstable/src/acl.c): `src/acl.c`
- [Core Data Store](https://github.com/valkey-io/valkey/blob/unstable/src/db.c): `src/db.c`
- [Native Structures](https://github.com/valkey-io/valkey/blob/unstable/src/t_string.c): `src/t_string.c`
- [Pub/Sub](https://github.com/valkey-io/valkey/blob/unstable/src/pubsub.c): `src/pubsub.c`

### State Services

- [RDB Snapshots](https://github.com/valkey-io/valkey/blob/unstable/src/rdb.c): `src/rdb.c`
- [AOF Log](https://github.com/valkey-io/valkey/blob/unstable/src/aof.c): `src/aof.c`
- [Replication](https://github.com/valkey-io/valkey/blob/unstable/src/replication.c): `src/replication.c`
- [Cluster Coordination](https://github.com/valkey-io/valkey/blob/unstable/src/cluster.c): `src/cluster.c`
- [Sentinel Monitoring](https://github.com/valkey-io/valkey/blob/unstable/src/sentinel.c): `src/sentinel.c`
- [Latency Metrics](https://github.com/valkey-io/valkey/blob/unstable/src/latency.c): `src/latency.c`

### Extensions

- [Module Runtime](https://github.com/valkey-io/valkey/blob/unstable/src/module.c): `src/module.c`
- [Scripting Manager](https://github.com/valkey-io/valkey/blob/unstable/src/scripting_engine.c): `src/scripting_engine.c`
- [Lua Engine](https://github.com/valkey-io/valkey/blob/unstable/src/modules/lua/engine_lua.c): `src/modules/lua/engine_lua.c`

### Other components

- **Application Client**
- **Operator**

## Connections

- Application Client → Networking: sends commands
- Operator → Server Runtime: configures server
- Server Runtime → Event Loop: runs loop
- Event Loop → Networking: handles events
- Networking → RESP Parser: parses requests
- Networking → Command Dispatch: dispatches commands
- Command Dispatch → Access Control: checks access
- Command Dispatch → Core Data Store: executes commands
- Command Dispatch → Native Structures: uses structures
- Command Dispatch → Pub/Sub: handles channels
- Command Dispatch → Module Runtime: invokes modules
- Command Dispatch → Scripting Manager: invokes scripts
- Command Dispatch → AOF Log: records writes
- Core Data Store → RDB Snapshots: persists state
- RDB Snapshots → Core Data Store: loads state
- Server Runtime → Replication: manages replicas
- Server Runtime → Cluster Coordination: coordinates shards
- Server Runtime → Sentinel Monitoring: runs monitoring
- Replication → Networking: streams updates
- Cluster Coordination → Networking: handles cluster links
- Networking → TLS Transport: secures transport
- Networking → RDMA Transport: uses RDMA
- Scripting Manager → Lua Engine: calls engine
- Lua Engine → Module Runtime: uses module API
- Server Runtime → Latency Metrics: tracks latency
- Command Dispatch → Networking: queues replies
- Networking → Application Client: returns replies
