# drunktrader/rediscli architecture

> Architecture diagram of the GitHub repository drunktrader/rediscli, 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/drunktrader/rediscli
- Repository: https://github.com/drunktrader/rediscli

## Overview

mazoni-redis CLI is a C++ Redis client whose main workflow accepts command-line arguments, connects to Redis, encodes and sends commands, then parses and displays RESP2 replies. With no command arguments it runs an interactive REPL; that mode also supports a separate Pub/Sub loop that polls terminal input and the Redis socket. The source excerpts show these runtime paths and the socket/protocol layers. README capabilities such as IPv4/IPv6, one-shot commands, and Redis command families are documented, but command families are forwarded rather than implemented as separate client subsystems.

Main entry points: [`Client/src/CLI.cpp`](https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp) (Interactive REPL), [`Client/src/RedisClient.cpp`](https://github.com/drunktrader/rediscli/blob/main/Client/src/RedisClient.cpp) (TCP client), [`Client/src/CommandHandler.cpp`](https://github.com/drunktrader/rediscli/blob/main/Client/src/CommandHandler.cpp) (Argument and RESP encoder), [`Client/src/ResponseParser.cpp`](https://github.com/drunktrader/rediscli/blob/main/Client/src/ResponseParser.cpp) (RESP2 response parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["CLI experience"]
  node_entry["Argument entry<br/>[main.cpp]"]
  node_runtime["CLI runtime<br/>[CLI.cpp]"]
  node_repl["Interactive REPL<br/>[CLI.cpp]"]
  node_oneshot["One-shot execution<br/>[CLI.cpp]"]
  node_pubsub["Pub/Sub loop<br/>[CLI.cpp]"]
end

subgraph group_protocol["Command protocol"]
  node_commands["Argument and RESP encoder<br/>[CommandHandler.cpp]"]
  node_parser["RESP2 response parser<br/>[ResponseParser.cpp]"]
end

subgraph group_network["Redis connection"]
  node_connection["TCP client<br/>[RedisClient.cpp]"]
end

node_user(("CLI user"))
node_redis[("Redis server")]

node_user -->|"invokes"| node_entry
node_entry -->|"starts"| node_runtime
node_runtime -->|"connects"| node_connection
node_runtime -->|"dispatches"| node_oneshot
node_runtime -->|"enters"| node_repl
node_repl -->|"tokenizes and encodes"| node_commands
node_oneshot -->|"encodes"| node_commands
node_repl -->|"sends command"| node_connection
node_oneshot -->|"sends command"| node_connection
node_connection -->|"sends over TCP"| node_redis
node_repl -->|"parses reply"| node_parser
node_oneshot -->|"parses reply"| node_parser
node_repl -->|"dispatches SUBSCRIBE"| node_pubsub
node_pubsub -->|"encodes subscription"| node_commands
node_pubsub -->|"sends subscription"| node_connection
node_pubsub -->|"parses messages"| node_parser
node_pubsub -->|"streams messages"| node_redis

click node_entry "https://github.com/drunktrader/rediscli/blob/main/Client/main.cpp"
click node_runtime "https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp"
click node_repl "https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp"
click node_oneshot "https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp"
click node_pubsub "https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp"
click node_commands "https://github.com/drunktrader/rediscli/blob/main/Client/src/CommandHandler.cpp"
click node_parser "https://github.com/drunktrader/rediscli/blob/main/Client/src/ResponseParser.cpp"
click node_connection "https://github.com/drunktrader/rediscli/blob/main/Client/src/RedisClient.cpp"

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_entry,node_runtime,node_repl,node_oneshot,node_pubsub,node_user toneBlue
class node_commands,node_parser,node_redis toneAmber
class node_connection toneMint
```

## Components

### CLI experience

- [Argument entry](https://github.com/drunktrader/rediscli/blob/main/Client/main.cpp): `Client/main.cpp`
- [CLI runtime](https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp): `Client/src/CLI.cpp`
- [Interactive REPL](https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp): `Client/src/CLI.cpp`
- [One-shot execution](https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp): `Client/src/CLI.cpp`
- [Pub/Sub loop](https://github.com/drunktrader/rediscli/blob/main/Client/src/CLI.cpp): `Client/src/CLI.cpp`

### Command protocol

- [Argument and RESP encoder](https://github.com/drunktrader/rediscli/blob/main/Client/src/CommandHandler.cpp): `Client/src/CommandHandler.cpp`
- [RESP2 response parser](https://github.com/drunktrader/rediscli/blob/main/Client/src/ResponseParser.cpp): `Client/src/ResponseParser.cpp`

### Redis connection

- [TCP client](https://github.com/drunktrader/rediscli/blob/main/Client/src/RedisClient.cpp): `Client/src/RedisClient.cpp`

### Other components

- **CLI user**
- **Redis server**

## Connections

- CLI user → Argument entry: invokes (evidence: `README.md`)
- Argument entry → CLI runtime: starts (evidence: `Client/main.cpp`)
- CLI runtime → TCP client: connects (evidence: `Client/src/CLI.cpp`)
- CLI runtime → One-shot execution: dispatches (evidence: `Client/src/CLI.cpp`)
- CLI runtime → Interactive REPL: enters (evidence: `Client/src/CLI.cpp`)
- Interactive REPL → Argument and RESP encoder: tokenizes and encodes (evidence: `Client/src/CLI.cpp`)
- One-shot execution → Argument and RESP encoder: encodes (evidence: `Client/src/CLI.cpp`)
- Interactive REPL → TCP client: sends command (evidence: `Client/src/CLI.cpp`)
- One-shot execution → TCP client: sends command (evidence: `Client/src/CLI.cpp`)
- TCP client → Redis server: sends over TCP (evidence: `Client/src/RedisClient.cpp`)
- Interactive REPL → RESP2 response parser: parses reply (evidence: `Client/src/CLI.cpp`)
- One-shot execution → RESP2 response parser: parses reply (evidence: `Client/src/CLI.cpp`)
- Interactive REPL → Pub/Sub loop: dispatches SUBSCRIBE (evidence: `Client/src/CLI.cpp`)
- Pub/Sub loop → Argument and RESP encoder: encodes subscription (evidence: `Client/src/CLI.cpp`)
- Pub/Sub loop → TCP client: sends subscription (evidence: `Client/src/CLI.cpp`)
- Pub/Sub loop → RESP2 response parser: parses messages (evidence: `Client/src/CLI.cpp`)
- Pub/Sub loop → Redis server: streams messages (evidence: `README.md`)
