# sdevanathan96/rusty-redis architecture

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

- Interactive diagram: https://gitdiagram.com/sdevanathan96/rusty-redis
- Repository: https://github.com/sdevanathan96/rusty-redis

## Overview

rusty-redis is an in-memory, Redis-compatible RESP server. A client sends RESP commands through a connection; frames become parsed commands, which the keyspace task executes against the database and returns as RESP replies. Blocking list/stream operations and WATCH transactions are coordinated in the keyspace/connection layers. The graph preserves the documented command families and storage stages; some domain-handler and startup links rely on the README or SOURCE INDEX references rather than fully sampled implementations.

Main entry points: [`src/command.rs`](https://github.com/sdevanathan96/rusty-redis/blob/main/src/command.rs) (Command parsing and dispatch), [`src/db.rs`](https://github.com/sdevanathan96/rusty-redis/blob/main/src/db.rs) (Database and expiry), [`src/keyspace.rs`](https://github.com/sdevanathan96/rusty-redis/blob/main/src/keyspace.rs) (Keyspace task), [`src/connection.rs`](https://github.com/sdevanathan96/rusty-redis/blob/main/src/connection.rs) (Client connections)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_transport["Transport and Protocol"]
  node_server["Startup and listener<br/>[main.rs]"]
  node_connection["Client connections<br/>[connection.rs]"]
  node_resp["RESP codec<br/>[resp.rs]"]
  node_pending["Pending requests<br/>[pending.rs]"]
end

subgraph group_commands["Command Handling"]
  node_command["Command parsing and dispatch<br/>[command.rs]"]
  node_args["Argument parsing<br/>[args.rs]"]
  node_errors["Command errors<br/>[error.rs]"]
  node_generic["Generic commands<br/>[generic.rs]"]
  node_strings["String commands<br/>[string.rs]"]
  node_lists["List commands<br/>[list.rs]"]
  node_streams["Stream commands<br/>[stream.rs]"]
  node_integers["Strict integer parsing<br/>[int.rs]"]
end

subgraph group_coordination["Keyspace Coordination"]
  node_keyspace["Keyspace task<br/>[keyspace.rs]"]
  node_waiters["Blocking waiters<br/>[keyspace.rs]"]
  node_watchers["WATCH tracking<br/>[watchers.rs]"]
end

subgraph group_storage["In-Memory Data"]
  node_db[("Database and expiry<br/>[db.rs]")]
  node_dbstrings["String storage<br/>[string.rs]"]
  node_dblists["List storage<br/>[list.rs]"]
  node_dbstreams["Stream storage<br/>[stream.rs]"]
  node_clock["Expiry clock<br/>[clock.rs]"]
end

subgraph group_transactions["Transactions"]
  node_transactions["Transaction handling<br/>[transaction.rs]"]
end

node_client(("Redis client"))

node_client -->|"connects to"| node_server
node_server -->|"spawns clients"| node_connection
node_server -->|"listens for"| node_client
node_connection -->|"encodes replies"| node_resp
node_connection -->|"queues requests"| node_pending
node_connection -->|"submits requests"| node_keyspace
node_pending -->|"parses frames"| node_resp
node_pending -->|"parses commands"| node_command
node_keyspace -->|"executes commands"| node_command
node_command -->|"dispatches"| node_generic
node_command -->|"dispatches"| node_strings
node_command -->|"dispatches"| node_lists
node_command -->|"dispatches"| node_streams
node_command -->|"uses parsers"| node_args
node_command -->|"returns errors"| node_errors
node_args -->|"parses integers"| node_integers
node_generic -->|"accesses data"| node_db
node_strings -->|"accesses data"| node_db
node_lists -->|"accesses data"| node_db
node_streams -.->|"accesses data"| node_db
node_db -->|"delegates storage"| node_dbstrings
node_db -->|"delegates storage"| node_dblists
node_db -->|"delegates storage"| node_dbstreams
node_db -->|"uses clock"| node_clock
node_keyspace -->|"tracks watches"| node_watchers
node_keyspace -->|"manages blockers"| node_waiters
node_transactions -->|"submits transaction"| node_keyspace
node_transactions -->|"queues parsed commands"| node_pending

click node_server "https://github.com/sdevanathan96/rusty-redis/blob/main/src/main.rs"
click node_connection "https://github.com/sdevanathan96/rusty-redis/blob/main/src/connection.rs"
click node_resp "https://github.com/sdevanathan96/rusty-redis/blob/main/src/resp.rs"
click node_pending "https://github.com/sdevanathan96/rusty-redis/blob/main/src/connection/pending.rs"
click node_command "https://github.com/sdevanathan96/rusty-redis/blob/main/src/command.rs"
click node_args "https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/args.rs"
click node_errors "https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/error.rs"
click node_generic "https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/generic.rs"
click node_strings "https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/string.rs"
click node_lists "https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/list.rs"
click node_streams "https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/stream.rs"
click node_integers "https://github.com/sdevanathan96/rusty-redis/blob/main/src/int.rs"
click node_keyspace "https://github.com/sdevanathan96/rusty-redis/blob/main/src/keyspace.rs"
click node_waiters "https://github.com/sdevanathan96/rusty-redis/blob/main/src/keyspace.rs"
click node_watchers "https://github.com/sdevanathan96/rusty-redis/blob/main/src/keyspace/watchers.rs"
click node_db "https://github.com/sdevanathan96/rusty-redis/blob/main/src/db.rs"
click node_dbstrings "https://github.com/sdevanathan96/rusty-redis/blob/main/src/db/string.rs"
click node_dblists "https://github.com/sdevanathan96/rusty-redis/blob/main/src/db/list.rs"
click node_dbstreams "https://github.com/sdevanathan96/rusty-redis/blob/main/src/db/stream.rs"
click node_clock "https://github.com/sdevanathan96/rusty-redis/blob/main/src/db/clock.rs"
click node_transactions "https://github.com/sdevanathan96/rusty-redis/blob/main/src/connection/transaction.rs"

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_connection,node_resp,node_pending toneBlue
class node_command,node_args,node_errors,node_generic,node_strings,node_lists,node_streams,node_integers,node_client toneAmber
class node_keyspace,node_waiters,node_watchers toneMint
class node_db,node_dbstrings,node_dblists,node_dbstreams,node_clock toneRose
class node_transactions toneIndigo
```

## Components

### Transport and Protocol

- [Startup and listener](https://github.com/sdevanathan96/rusty-redis/blob/main/src/main.rs): `src/main.rs`
- [Client connections](https://github.com/sdevanathan96/rusty-redis/blob/main/src/connection.rs): `src/connection.rs`
- [RESP codec](https://github.com/sdevanathan96/rusty-redis/blob/main/src/resp.rs): `src/resp.rs`
- [Pending requests](https://github.com/sdevanathan96/rusty-redis/blob/main/src/connection/pending.rs): `src/connection/pending.rs`

### Command Handling

- [Command parsing and dispatch](https://github.com/sdevanathan96/rusty-redis/blob/main/src/command.rs): `src/command.rs`
- [Argument parsing](https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/args.rs): `src/command/args.rs`
- [Command errors](https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/error.rs): `src/command/error.rs`
- [Generic commands](https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/generic.rs): `src/command/generic.rs`
- [String commands](https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/string.rs): `src/command/string.rs`
- [List commands](https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/list.rs): `src/command/list.rs`
- [Stream commands](https://github.com/sdevanathan96/rusty-redis/blob/main/src/command/stream.rs): `src/command/stream.rs`
- [Strict integer parsing](https://github.com/sdevanathan96/rusty-redis/blob/main/src/int.rs): `src/int.rs`

### Keyspace Coordination

- [Keyspace task](https://github.com/sdevanathan96/rusty-redis/blob/main/src/keyspace.rs): `src/keyspace.rs`
- [Blocking waiters](https://github.com/sdevanathan96/rusty-redis/blob/main/src/keyspace.rs): `src/keyspace.rs`
- [WATCH tracking](https://github.com/sdevanathan96/rusty-redis/blob/main/src/keyspace/watchers.rs): `src/keyspace/watchers.rs`

### In-Memory Data

- [Database and expiry](https://github.com/sdevanathan96/rusty-redis/blob/main/src/db.rs): `src/db.rs`
- [String storage](https://github.com/sdevanathan96/rusty-redis/blob/main/src/db/string.rs): `src/db/string.rs`
- [List storage](https://github.com/sdevanathan96/rusty-redis/blob/main/src/db/list.rs): `src/db/list.rs`
- [Stream storage](https://github.com/sdevanathan96/rusty-redis/blob/main/src/db/stream.rs): `src/db/stream.rs`
- [Expiry clock](https://github.com/sdevanathan96/rusty-redis/blob/main/src/db/clock.rs): `src/db/clock.rs`

### Transactions

- [Transaction handling](https://github.com/sdevanathan96/rusty-redis/blob/main/src/connection/transaction.rs): `src/connection/transaction.rs`

### Other components

- **Redis client**

## Connections

- Redis client → Startup and listener: connects to (evidence: `README.md`)
- Startup and listener → Client connections: spawns clients (evidence: `README.md`)
- Startup and listener → Redis client: listens for (evidence: `README.md`)
- Client connections → RESP codec: encodes replies (evidence: `src/connection.rs`)
- Client connections → Pending requests: queues requests (evidence: `src/connection.rs`)
- Client connections → Keyspace task: submits requests (evidence: `src/connection.rs`)
- Pending requests → RESP codec: parses frames (evidence: `src/connection/pending.rs`)
- Pending requests → Command parsing and dispatch: parses commands (evidence: `src/connection/pending.rs`)
- Keyspace task → Command parsing and dispatch: executes commands (evidence: `src/keyspace.rs`)
- Command parsing and dispatch → Generic commands: dispatches (evidence: `src/command.rs`)
- Command parsing and dispatch → String commands: dispatches (evidence: `src/command.rs`)
- Command parsing and dispatch → List commands: dispatches (evidence: `src/command.rs`)
- Command parsing and dispatch → Stream commands: dispatches (evidence: `src/command.rs`)
- Command parsing and dispatch → Argument parsing: uses parsers (evidence: `src/command/args.rs`)
- Command parsing and dispatch → Command errors: returns errors (evidence: `src/command.rs`)
- Argument parsing → Strict integer parsing: parses integers (evidence: `src/command/args.rs`)
- Generic commands → Database and expiry: accesses data (evidence: `src/command/generic.rs`)
- String commands → Database and expiry: accesses data (evidence: `src/command/string.rs`)
- List commands → Database and expiry: accesses data (evidence: `src/command/list.rs`)
- Stream commands → Database and expiry: accesses data
- Database and expiry → String storage: delegates storage (evidence: `src/db.rs`)
- Database and expiry → List storage: delegates storage (evidence: `src/db.rs`)
- Database and expiry → Stream storage: delegates storage (evidence: `src/db.rs`)
- Database and expiry → Expiry clock: uses clock (evidence: `src/db.rs`)
- Keyspace task → WATCH tracking: tracks watches (evidence: `src/keyspace.rs`)
- Keyspace task → Blocking waiters: manages blockers (evidence: `src/keyspace.rs`)
- Transaction handling → Keyspace task: submits transaction (evidence: `src/connection/transaction.rs`)
- Transaction handling → Pending requests: queues parsed commands (evidence: `src/connection/transaction.rs`)
