# dragonflydb/dragonfly architecture

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

- Interactive diagram: https://gitdiagram.com/dragonflydb/dragonfly
- Repository: https://github.com/dragonflydb/dragonfly

## Overview

Dragonfly is a high-throughput in-memory datastore compatible with Redis and Memcached APIs. The principal workflow is: a client connects through a protocol listener, the request is parsed and dispatched to a command family, a transaction executes on an engine shard against the database, and a reply is encoded back to the client. Persistence, search, clustering, replication, ACLs, and tiered storage form adjacent capabilities. Source excerpts were partial, so uncertain internal call edges are omitted.

Main entry points: [`src/server/command_families.h`](https://github.com/dragonflydb/dragonfly/blob/main/src/server/command_families.h) (Command Families), [`src/server/engine_shard.cc`](https://github.com/dragonflydb/dragonfly/blob/main/src/server/engine_shard.cc) (Engine Shards), [`src/server/db_slice.cc`](https://github.com/dragonflydb/dragonfly/blob/main/src/server/db_slice.cc) (Database Slices), [`src/facade/dragonfly_listener.cc`](https://github.com/dragonflydb/dragonfly/blob/main/src/facade/dragonfly_listener.cc) (Protocol Listener)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["Protocol Access"]
  node_listener["Protocol Listener"]
  node_parsers["RESP Memcache Parsers<br/>[resp_parser.cc]"]
  node_reply["Reply Builder<br/>[reply_builder.cc]"]
end

subgraph group_execution["Command Execution"]
  node_registry["Command Registry"]
  node_families["Command Families<br/>[command_families.h]"]
  node_transactions["Transactions<br/>[transaction.cc]"]
  node_shards["Engine Shards<br/>[engine_shard.cc]"]
end

subgraph group_data["Data Services"]
  node_dbslice[("Database Slices<br/>[db_slice.cc]")]
  node_collections["Redis Collections<br/>[generic_family.cc]"]
  node_search["Search And Vectors<br/>[search_family.cc]"]
  node_indices["Search Indices<br/>[indices.cc]"]
end

subgraph group_durability["Durability Storage"]
  node_journal["Write Journal<br/>[journal.cc]"]
  node_snapshots["RDB Snapshots<br/>[snapshot.cc]"]
  node_snapshot_storage["Snapshot Storage"]
  node_tiered["Tiered Storage<br/>[tiered_storage.cc]"]
  node_disk[("Tiered Disk Store<br/>[disk_storage.cc]")]
end

subgraph group_operations["Scale Operations"]
  node_acl["ACL Authentication<br/>[validator.cc]"]
  node_cluster["Cluster Coordination<br/>[coordinator.cc]"]
  node_replication["Replication<br/>[replica.cc]"]
end

node_clients(("Redis Memcache Clients"))
node_cloud[("Cloud Object Storage")]

node_clients -->|"opens connection"| node_listener
node_listener -->|"reads protocol"| node_parsers
node_parsers -->|"dispatches command"| node_registry
node_registry -->|"selects family"| node_families
node_families -->|"starts transaction"| node_transactions
node_transactions -->|"runs on shard"| node_shards
node_shards -->|"accesses data"| node_dbslice
node_families -->|"builds reply"| node_reply
node_reply -->|"returns result"| node_clients
node_families -->|"executes datatype"| node_collections
node_families -->|"executes search"| node_search
node_search -->|"queries indices"| node_indices
node_dbslice -->|"indexes values"| node_indices
node_shards -->|"journals writes"| node_journal
node_snapshots -->|"reads writes snapshots"| node_snapshot_storage
node_snapshot_storage -.->|"uses object storage"| node_cloud
node_dbslice -->|"offloads values"| node_tiered
node_tiered -->|"reads writes segments"| node_disk
node_families -->|"checks access"| node_acl
node_shards -->|"coordinates slots"| node_cluster
node_shards -->|"serves replicas"| node_replication

click node_listener "https://github.com/dragonflydb/dragonfly/blob/main/src/facade/dragonfly_listener.cc"
click node_parsers "https://github.com/dragonflydb/dragonfly/blob/main/src/facade/resp_parser.cc"
click node_reply "https://github.com/dragonflydb/dragonfly/blob/main/src/facade/reply_builder.cc"
click node_registry "https://github.com/dragonflydb/dragonfly/blob/main/src/server/command_registry.cc"
click node_families "https://github.com/dragonflydb/dragonfly/blob/main/src/server/command_families.h"
click node_transactions "https://github.com/dragonflydb/dragonfly/blob/main/src/server/transaction.cc"
click node_shards "https://github.com/dragonflydb/dragonfly/blob/main/src/server/engine_shard.cc"
click node_dbslice "https://github.com/dragonflydb/dragonfly/blob/main/src/server/db_slice.cc"
click node_collections "https://github.com/dragonflydb/dragonfly/blob/main/src/server/generic_family.cc"
click node_search "https://github.com/dragonflydb/dragonfly/blob/main/src/server/search/search_family.cc"
click node_indices "https://github.com/dragonflydb/dragonfly/blob/main/src/core/search/indices.cc"
click node_journal "https://github.com/dragonflydb/dragonfly/blob/main/src/server/journal/journal.cc"
click node_snapshots "https://github.com/dragonflydb/dragonfly/blob/main/src/server/snapshot.cc"
click node_snapshot_storage "https://github.com/dragonflydb/dragonfly/blob/main/src/server/detail/snapshot_storage.cc"
click node_tiered "https://github.com/dragonflydb/dragonfly/blob/main/src/server/tiered_storage.cc"
click node_disk "https://github.com/dragonflydb/dragonfly/blob/main/src/server/tiering/disk_storage.cc"
click node_acl "https://github.com/dragonflydb/dragonfly/blob/main/src/server/acl/validator.cc"
click node_cluster "https://github.com/dragonflydb/dragonfly/blob/main/src/server/cluster/coordinator.cc"
click node_replication "https://github.com/dragonflydb/dragonfly/blob/main/src/server/replica.cc"

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_listener,node_parsers,node_reply toneBlue
class node_registry,node_families,node_transactions,node_shards,node_clients,node_cloud toneAmber
class node_dbslice,node_collections,node_search,node_indices toneMint
class node_journal,node_snapshots,node_snapshot_storage,node_tiered,node_disk toneRose
class node_acl,node_cluster,node_replication toneIndigo
```

## Components

### Protocol Access

- [Protocol Listener](https://github.com/dragonflydb/dragonfly/blob/main/src/facade/dragonfly_listener.cc): `src/facade/dragonfly_listener.cc`
- [RESP Memcache Parsers](https://github.com/dragonflydb/dragonfly/blob/main/src/facade/resp_parser.cc): `src/facade/resp_parser.cc`
- [Reply Builder](https://github.com/dragonflydb/dragonfly/blob/main/src/facade/reply_builder.cc): `src/facade/reply_builder.cc`

### Command Execution

- [Command Registry](https://github.com/dragonflydb/dragonfly/blob/main/src/server/command_registry.cc): `src/server/command_registry.cc`
- [Command Families](https://github.com/dragonflydb/dragonfly/blob/main/src/server/command_families.h): `src/server/command_families.h`
- [Transactions](https://github.com/dragonflydb/dragonfly/blob/main/src/server/transaction.cc): `src/server/transaction.cc`
- [Engine Shards](https://github.com/dragonflydb/dragonfly/blob/main/src/server/engine_shard.cc): `src/server/engine_shard.cc`

### Data Services

- [Database Slices](https://github.com/dragonflydb/dragonfly/blob/main/src/server/db_slice.cc): `src/server/db_slice.cc`
- [Redis Collections](https://github.com/dragonflydb/dragonfly/blob/main/src/server/generic_family.cc): `src/server/generic_family.cc`
- [Search And Vectors](https://github.com/dragonflydb/dragonfly/blob/main/src/server/search/search_family.cc): `src/server/search/search_family.cc`
- [Search Indices](https://github.com/dragonflydb/dragonfly/blob/main/src/core/search/indices.cc): `src/core/search/indices.cc`

### Durability Storage

- [Write Journal](https://github.com/dragonflydb/dragonfly/blob/main/src/server/journal/journal.cc): `src/server/journal/journal.cc`
- [RDB Snapshots](https://github.com/dragonflydb/dragonfly/blob/main/src/server/snapshot.cc): `src/server/snapshot.cc`
- [Snapshot Storage](https://github.com/dragonflydb/dragonfly/blob/main/src/server/detail/snapshot_storage.cc): `src/server/detail/snapshot_storage.cc`
- [Tiered Storage](https://github.com/dragonflydb/dragonfly/blob/main/src/server/tiered_storage.cc): `src/server/tiered_storage.cc`
- [Tiered Disk Store](https://github.com/dragonflydb/dragonfly/blob/main/src/server/tiering/disk_storage.cc): `src/server/tiering/disk_storage.cc`

### Scale Operations

- [ACL Authentication](https://github.com/dragonflydb/dragonfly/blob/main/src/server/acl/validator.cc): `src/server/acl/validator.cc`
- [Cluster Coordination](https://github.com/dragonflydb/dragonfly/blob/main/src/server/cluster/coordinator.cc): `src/server/cluster/coordinator.cc`
- [Replication](https://github.com/dragonflydb/dragonfly/blob/main/src/server/replica.cc): `src/server/replica.cc`

### Other components

- **Redis Memcache Clients**
- **Cloud Object Storage**

## Connections

- Redis Memcache Clients → Protocol Listener: opens connection
- Protocol Listener → RESP Memcache Parsers: reads protocol
- RESP Memcache Parsers → Command Registry: dispatches command
- Command Registry → Command Families: selects family
- Command Families → Transactions: starts transaction
- Transactions → Engine Shards: runs on shard
- Engine Shards → Database Slices: accesses data
- Command Families → Reply Builder: builds reply
- Reply Builder → Redis Memcache Clients: returns result
- Command Families → Redis Collections: executes datatype
- Command Families → Search And Vectors: executes search
- Search And Vectors → Search Indices: queries indices
- Database Slices → Search Indices: indexes values
- Engine Shards → Write Journal: journals writes
- RDB Snapshots → Snapshot Storage: reads writes snapshots
- Snapshot Storage → Cloud Object Storage: uses object storage
- Database Slices → Tiered Storage: offloads values
- Tiered Storage → Tiered Disk Store: reads writes segments
- Command Families → ACL Authentication: checks access
- Engine Shards → Cluster Coordination: coordinates slots
- Engine Shards → Replication: serves replicas
