# ixaruss/rushdb architecture

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

- Interactive diagram: https://gitdiagram.com/ixaruss/rushdb
- Repository: https://github.com/ixaruss/rushdb

## Overview

RushDB is a small Redis-inspired key-value service with a TCP server, binary request/response protocol, CLI, and snapshot persistence. The main workflow runs from a user command through CLI dispatch and a TCP query to server-side storage, then returns a response. The README documents periodic snapshots, but the sampled server code has its snapshot loop commented out; persistence load/save routines are present. Arrows rely on sampled calls or README statements, so unsampled runtime details are not inferred.

Main entry points: [`db/src/server.rs`](https://github.com/ixaruss/rushdb/blob/main/db/src/server.rs) (TCP server), [`cli/src/cmd.rs`](https://github.com/ixaruss/rushdb/blob/main/cli/src/cmd.rs) (Command dispatch), [`common/src/io.rs`](https://github.com/ixaruss/rushdb/blob/main/common/src/io.rs) (Protocol I/O), [`cli/src/shell.rs`](https://github.com/ixaruss/rushdb/blob/main/cli/src/shell.rs) (Interactive shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_cli_entry["CLI entry<br/>[main.rs]"]
  node_command_dispatch["Command dispatch<br/>[cmd.rs]"]
  node_interactive_shell["Interactive shell<br/>[shell.rs]"]
  node_shell_completion["Shell completion<br/>[util.rs]"]
  node_tcp_client["TCP client<br/>[client.rs]"]
end

subgraph group_protocol["Protocol"]
  node_protocol_io["Protocol I/O<br/>[io.rs]"]
  node_protocol_types["Request types<br/>[serevrtypes.rs]"]
  node_string_codec["String codec<br/>[str.rs]"]
end

subgraph group_server["Server"]
  node_server_entry["Server entry<br/>[main.rs]"]
  node_tcp_server["TCP server<br/>[server.rs]"]
  node_server_config["Server config<br/>[conf.rs]"]
  node_memory_store[("In-memory store<br/>[engine.rs]")]
end

subgraph group_persistence["Persistence"]
  node_snapshot_manager["Snapshot manager<br/>[persistence.rs]"]
  node_snapshot_file[("Snapshot file")]
end

node_user(("User"))

node_user -->|"runs"| node_cli_entry
node_cli_entry -->|"starts"| node_command_dispatch
node_command_dispatch -->|"queries"| node_tcp_client
node_command_dispatch -->|"starts"| node_interactive_shell
node_interactive_shell -->|"dispatches"| node_command_dispatch
node_interactive_shell -->|"uses"| node_shell_completion
node_tcp_client -->|"sends and receives"| node_protocol_io
node_tcp_client -->|"sends TCP requests"| node_tcp_server
node_protocol_io -->|"encodes and decodes"| node_protocol_types
node_protocol_io -->|"uses"| node_string_codec
node_server_entry -->|"starts"| node_tcp_server
node_tcp_server -->|"loads"| node_server_config
node_tcp_server -->|"loads snapshot"| node_snapshot_manager
node_tcp_server -->|"receives and sends"| node_protocol_io
node_tcp_server -->|"reads and mutates"| node_memory_store
node_snapshot_manager -->|"reads and writes"| node_snapshot_file
node_server_config -->|"configures path"| node_snapshot_file
node_tcp_server -.->|"periodically saves"| node_snapshot_manager

click node_cli_entry "https://github.com/ixaruss/rushdb/blob/main/cli/src/main.rs"
click node_command_dispatch "https://github.com/ixaruss/rushdb/blob/main/cli/src/cmd.rs"
click node_interactive_shell "https://github.com/ixaruss/rushdb/blob/main/cli/src/shell.rs"
click node_shell_completion "https://github.com/ixaruss/rushdb/blob/main/cli/src/util.rs"
click node_tcp_client "https://github.com/ixaruss/rushdb/blob/main/cli/src/client.rs"
click node_protocol_io "https://github.com/ixaruss/rushdb/blob/main/common/src/io.rs"
click node_protocol_types "https://github.com/ixaruss/rushdb/blob/main/common/src/serevrtypes.rs"
click node_string_codec "https://github.com/ixaruss/rushdb/blob/main/common/src/str.rs"
click node_server_entry "https://github.com/ixaruss/rushdb/blob/main/db/src/main.rs"
click node_tcp_server "https://github.com/ixaruss/rushdb/blob/main/db/src/server.rs"
click node_server_config "https://github.com/ixaruss/rushdb/blob/main/db/src/conf.rs"
click node_memory_store "https://github.com/ixaruss/rushdb/blob/main/db/src/engine.rs"
click node_snapshot_manager "https://github.com/ixaruss/rushdb/blob/main/db/src/persistence.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_cli_entry,node_command_dispatch,node_interactive_shell,node_shell_completion,node_tcp_client,node_user toneBlue
class node_protocol_io,node_protocol_types,node_string_codec toneAmber
class node_server_entry,node_tcp_server,node_server_config,node_memory_store toneMint
class node_snapshot_manager,node_snapshot_file toneRose
```

## Components

### CLI

- [CLI entry](https://github.com/ixaruss/rushdb/blob/main/cli/src/main.rs): `cli/src/main.rs`
- [Command dispatch](https://github.com/ixaruss/rushdb/blob/main/cli/src/cmd.rs): `cli/src/cmd.rs`
- [Interactive shell](https://github.com/ixaruss/rushdb/blob/main/cli/src/shell.rs): `cli/src/shell.rs`
- [Shell completion](https://github.com/ixaruss/rushdb/blob/main/cli/src/util.rs): `cli/src/util.rs`
- [TCP client](https://github.com/ixaruss/rushdb/blob/main/cli/src/client.rs): `cli/src/client.rs`

### Protocol

- [Protocol I/O](https://github.com/ixaruss/rushdb/blob/main/common/src/io.rs): `common/src/io.rs`
- [Request types](https://github.com/ixaruss/rushdb/blob/main/common/src/serevrtypes.rs): `common/src/serevrtypes.rs`
- [String codec](https://github.com/ixaruss/rushdb/blob/main/common/src/str.rs): `common/src/str.rs`

### Server

- [Server entry](https://github.com/ixaruss/rushdb/blob/main/db/src/main.rs): `db/src/main.rs`
- [TCP server](https://github.com/ixaruss/rushdb/blob/main/db/src/server.rs): `db/src/server.rs`
- [Server config](https://github.com/ixaruss/rushdb/blob/main/db/src/conf.rs): `db/src/conf.rs`
- [In-memory store](https://github.com/ixaruss/rushdb/blob/main/db/src/engine.rs): `db/src/engine.rs`

### Persistence

- [Snapshot manager](https://github.com/ixaruss/rushdb/blob/main/db/src/persistence.rs): `db/src/persistence.rs`
- **Snapshot file**

### Other components

- **User**

## Connections

- User → CLI entry: runs (evidence: `README.md`)
- CLI entry → Command dispatch: starts (evidence: `cli/src/main.rs`)
- Command dispatch → TCP client: queries (evidence: `cli/src/cmd.rs`)
- Command dispatch → Interactive shell: starts (evidence: `cli/src/cmd.rs`)
- Interactive shell → Command dispatch: dispatches (evidence: `cli/src/shell.rs`)
- Interactive shell → Shell completion: uses (evidence: `cli/src/shell.rs`)
- TCP client → Protocol I/O: sends and receives (evidence: `cli/src/client.rs`)
- TCP client → TCP server: sends TCP requests (evidence: `README.md`)
- Protocol I/O → Request types: encodes and decodes (evidence: `common/src/io.rs`)
- Protocol I/O → String codec: uses (evidence: `common/src/io.rs`)
- Server entry → TCP server: starts (evidence: `db/src/main.rs`)
- TCP server → Server config: loads (evidence: `db/src/server.rs`)
- TCP server → Snapshot manager: loads snapshot (evidence: `db/src/server.rs`)
- TCP server → Protocol I/O: receives and sends (evidence: `db/src/server.rs`)
- TCP server → In-memory store: reads and mutates (evidence: `db/src/server.rs`)
- Snapshot manager → Snapshot file: reads and writes (evidence: `db/src/persistence.rs`)
- Server config → Snapshot file: configures path (evidence: `db/src/conf.rs`)
- TCP server → Snapshot manager: periodically saves (evidence: `README.md`)
