# tmz16th/mini-redis architecture

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

- Interactive diagram: https://gitdiagram.com/tmz16th/mini-redis
- Repository: https://github.com/tmz16th/mini-redis

## Overview

mini-redis is a small in-memory key-value server. A client connects over TCP, sends newline-delimited commands, and receives command responses; SET, GET, and DEL operate on the shared store, while PING and QUIT are handled by the server. The TCP listener starts one thread per client, and an Arc<RwLock<Store>> coordinates concurrent access. The graph reflects the two implemented layers; persistence, snapshots, and async execution are roadmap items, not current components.

Main entry points: [`src/main.rs`](https://github.com/tmz16th/mini-redis/blob/master/src/main.rs) (TCP Listener), [`src/store.rs`](https://github.com/tmz16th/mini-redis/blob/master/src/store.rs) (In-Memory Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_network["TCP Server"]
  node_listener["TCP Listener<br/>[main.rs]"]
  node_session["Client Session<br/>[main.rs]"]
  node_commands["Command Handler<br/>[main.rs]"]
end

subgraph group_storage["Shared Storage"]
  node_shared["Shared Store Lock<br/>[main.rs]"]
  node_store[("In-Memory Store<br/>[store.rs]")]
end

node_client(("TCP Client"))

node_client -->|"connects"| node_listener
node_listener -->|"spawns per client"| node_session
node_session -->|"dispatches commands"| node_commands
node_listener -->|"initializes"| node_shared
node_commands -->|"reads or writes"| node_shared
node_shared -->|"protects"| node_store
node_session -->|"writes responses"| node_client
node_commands -->|"calls CRUD methods"| node_store

click node_listener "https://github.com/tmz16th/mini-redis/blob/master/src/main.rs"
click node_session "https://github.com/tmz16th/mini-redis/blob/master/src/main.rs"
click node_commands "https://github.com/tmz16th/mini-redis/blob/master/src/main.rs"
click node_shared "https://github.com/tmz16th/mini-redis/blob/master/src/main.rs"
click node_store "https://github.com/tmz16th/mini-redis/blob/master/src/store.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_listener,node_session,node_commands,node_client toneBlue
class node_shared,node_store toneAmber
```

## Components

### TCP Server

- [TCP Listener](https://github.com/tmz16th/mini-redis/blob/master/src/main.rs): `src/main.rs`
- [Client Session](https://github.com/tmz16th/mini-redis/blob/master/src/main.rs): `src/main.rs`
- [Command Handler](https://github.com/tmz16th/mini-redis/blob/master/src/main.rs): `src/main.rs`

### Shared Storage

- [Shared Store Lock](https://github.com/tmz16th/mini-redis/blob/master/src/main.rs): `src/main.rs`
- [In-Memory Store](https://github.com/tmz16th/mini-redis/blob/master/src/store.rs): `src/store.rs`

### Other components

- **TCP Client**

## Connections

- TCP Client → TCP Listener: connects (evidence: `README.md`)
- TCP Listener → Client Session: spawns per client (evidence: `src/main.rs`)
- Client Session → Command Handler: dispatches commands (evidence: `src/main.rs`)
- TCP Listener → Shared Store Lock: initializes (evidence: `src/main.rs`)
- Command Handler → Shared Store Lock: reads or writes (evidence: `src/main.rs`)
- Shared Store Lock → In-Memory Store: protects (evidence: `src/main.rs`)
- Client Session → TCP Client: writes responses (evidence: `src/main.rs`)
- Command Handler → In-Memory Store: calls CRUD methods (evidence: `src/main.rs`)
