# dimpleh21/memstore architecture

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

## Overview

MemStore is a Redis-like in-memory key-value server with a command-line client. The main workflow is client input → command encoding and TCP transport → server command processing → shared data store → RESP response. The database also supports list and hash operations, key management, and persistence. The excerpts establish client startup and server startup/persistence; several internal client/server handoffs are documented only broadly, so those links are marked unverified rather than treated as inspected calls.

Main entry points: [`client/src/CLI.cpp`](https://github.com/dimpleh21/memstore/blob/main/client/src/CLI.cpp) (Interactive CLI), [`server/src/RedisDatabase.cpp`](https://github.com/dimpleh21/memstore/blob/main/server/src/RedisDatabase.cpp) (Dump and load), [`server/src/RedisServer.cpp`](https://github.com/dimpleh21/memstore/blob/main/server/src/RedisServer.cpp) (TCP server), [`server/src/main.cpp`](https://github.com/dimpleh21/memstore/blob/main/server/src/main.cpp) (Server entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_entry["Client entry<br/>[main.cpp]"]
  node_cli["Interactive CLI<br/>[CLI.cpp]"]
  node_arg_codec["Command codec<br/>[CommandHandler.cpp]"]
  node_socket_client["TCP client<br/>[RedisClient.cpp]"]
  node_response_parser["Response parser<br/>[ResponseParser.cpp]"]
end

subgraph group_server["Server"]
  node_server_entry["Server entry<br/>[main.cpp]"]
  node_tcp_server["TCP server<br/>[RedisServer.cpp]"]
  node_command_dispatch["Command processor"]
end

subgraph group_data["Data and persistence"]
  node_database[("Redis database<br/>[RedisDatabase.cpp]")]
  node_persistence["Dump and load<br/>[RedisDatabase.cpp]"]
  node_dump_file["Persistence file<br/>[dump.my_rdb]"]
end

node_user(("CLI user"))
node_redis_cli(("Redis CLI"))

node_user -->|"starts"| node_client_entry
node_client_entry -->|"runs"| node_cli
node_cli -.->|"encodes commands"| node_arg_codec
node_cli -.->|"sends commands"| node_socket_client
node_cli -.->|"parses replies"| node_response_parser
node_redis_cli -.->|"sends commands"| node_tcp_server
node_server_entry -->|"runs"| node_tcp_server
node_tcp_server -.->|"dispatches commands"| node_command_dispatch
node_command_dispatch -->|"reads and writes"| node_database
node_server_entry -->|"loads and dumps"| node_persistence
node_persistence -->|"reads and writes"| node_dump_file
node_persistence -->|"persists state"| node_database

click node_client_entry "https://github.com/dimpleh21/memstore/blob/main/client/src/main.cpp"
click node_cli "https://github.com/dimpleh21/memstore/blob/main/client/src/CLI.cpp"
click node_arg_codec "https://github.com/dimpleh21/memstore/blob/main/client/src/CommandHandler.cpp"
click node_socket_client "https://github.com/dimpleh21/memstore/blob/main/client/src/RedisClient.cpp"
click node_response_parser "https://github.com/dimpleh21/memstore/blob/main/client/src/ResponseParser.cpp"
click node_server_entry "https://github.com/dimpleh21/memstore/blob/main/server/src/main.cpp"
click node_tcp_server "https://github.com/dimpleh21/memstore/blob/main/server/src/RedisServer.cpp"
click node_command_dispatch "https://github.com/dimpleh21/memstore/blob/main/server/src/RedisCommandHandler.cpp"
click node_database "https://github.com/dimpleh21/memstore/blob/main/server/src/RedisDatabase.cpp"
click node_persistence "https://github.com/dimpleh21/memstore/blob/main/server/src/RedisDatabase.cpp"
click node_dump_file "https://github.com/dimpleh21/memstore/blob/main/server/dump.my_rdb"

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_client_entry,node_cli,node_arg_codec,node_socket_client,node_response_parser,node_user toneBlue
class node_server_entry,node_tcp_server,node_command_dispatch,node_redis_cli toneAmber
class node_database,node_persistence,node_dump_file toneMint
```

## Components

### Client

- [Client entry](https://github.com/dimpleh21/memstore/blob/main/client/src/main.cpp): `client/src/main.cpp`
- [Interactive CLI](https://github.com/dimpleh21/memstore/blob/main/client/src/CLI.cpp): `client/src/CLI.cpp`
- [Command codec](https://github.com/dimpleh21/memstore/blob/main/client/src/CommandHandler.cpp): `client/src/CommandHandler.cpp`
- [TCP client](https://github.com/dimpleh21/memstore/blob/main/client/src/RedisClient.cpp): `client/src/RedisClient.cpp`
- [Response parser](https://github.com/dimpleh21/memstore/blob/main/client/src/ResponseParser.cpp): `client/src/ResponseParser.cpp`

### Server

- [Server entry](https://github.com/dimpleh21/memstore/blob/main/server/src/main.cpp): `server/src/main.cpp`
- [TCP server](https://github.com/dimpleh21/memstore/blob/main/server/src/RedisServer.cpp): `server/src/RedisServer.cpp`
- [Command processor](https://github.com/dimpleh21/memstore/blob/main/server/src/RedisCommandHandler.cpp): `server/src/RedisCommandHandler.cpp`

### Data and persistence

- [Redis database](https://github.com/dimpleh21/memstore/blob/main/server/src/RedisDatabase.cpp): `server/src/RedisDatabase.cpp`
- [Dump and load](https://github.com/dimpleh21/memstore/blob/main/server/src/RedisDatabase.cpp): `server/src/RedisDatabase.cpp`
- [Persistence file](https://github.com/dimpleh21/memstore/blob/main/server/dump.my_rdb): `server/dump.my_rdb`

### Other components

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

## Connections

- CLI user → Client entry: starts (evidence: `README.md`)
- Client entry → Interactive CLI: runs (evidence: `client/src/main.cpp`)
- Interactive CLI → Command codec: encodes commands
- Interactive CLI → TCP client: sends commands (evidence: `README.md`)
- Interactive CLI → Response parser: parses replies
- Redis CLI → TCP server: sends commands (evidence: `README.md`)
- Server entry → TCP server: runs (evidence: `server/src/main.cpp`)
- TCP server → Command processor: dispatches commands
- Command processor → Redis database: reads and writes (evidence: `server/src/RedisCommandHandler.cpp`)
- Server entry → Dump and load: loads and dumps (evidence: `server/src/main.cpp`)
- Dump and load → Persistence file: reads and writes (evidence: `README.md`)
- Dump and load → Redis database: persists state (evidence: `server/src/RedisDatabase.cpp`)
