# honey-singh716/miniredis architecture

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

- Interactive diagram: https://gitdiagram.com/honey-singh716/miniredis
- Repository: https://github.com/honey-singh716/miniredis

## Overview

MiniRedis is a command-line, in-memory key-value store. A user enters commands in the interactive CLI; the parser validates and dispatches them to RedisStore, which coordinates the hash table, LRU cache, TTL scheduling, and persistence. TTL operations use absolute expiry times and version checks to avoid stale expirations; SAVE and LOAD preserve expiry timestamps across restarts. The README documents the broader command and persistence capabilities; relationships not visible in sampled source are included only where documented. The map focuses on runtime components, not benchmarks or tests.

Main entry points: [`src/RedisStore.cpp`](https://github.com/honey-singh716/miniredis/blob/main/src/RedisStore.cpp) (RedisStore), [`main.cpp`](https://github.com/honey-singh716/miniredis/blob/main/main.cpp) (Interactive CLI), [`src/CommandParser.cpp`](https://github.com/honey-singh716/miniredis/blob/main/src/CommandParser.cpp) (Command Parser), [`src/TTLManager.cpp`](https://github.com/honey-singh716/miniredis/blob/main/src/TTLManager.cpp) (TTL Manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Command Interface"]
  node_cli["Interactive CLI<br/>[main.cpp]"]
  node_parser["Command Parser<br/>[CommandParser.cpp]"]
end

subgraph group_coordination["Store Coordination"]
  node_store["RedisStore<br/>[RedisStore.cpp]"]
  node_expiry_metadata["Expiry and Version Maps<br/>[RedisStore.cpp]"]
  node_ttl["TTL Manager<br/>[TTLManager.cpp]"]
end

subgraph group_structures["Storage Structures"]
  node_hash["Hash Table<br/>[HashTable.cpp]"]
  node_lru["LRU Cache<br/>[LRUCache.cpp]"]
  node_expiry_heap["Expiry Min-Heap<br/>[TTLManager.h]"]
end

subgraph group_durability["Persistence"]
  node_persistence["Persistence<br/>[Persistence.cpp]"]
  node_db_file[("Database File<br/>[miniredis.db]")]
end

node_user(("User"))

node_user -->|"enters commands"| node_cli
node_cli -->|"tokenizes and dispatches"| node_parser
node_parser -->|"dispatches operations"| node_store
node_store -->|"reads and writes"| node_hash
node_store -->|"checks and updates"| node_lru
node_store -->|"schedules expirations"| node_ttl
node_store -->|"tracks expiry versions"| node_expiry_metadata
node_ttl -->|"adds and removes"| node_expiry_heap
node_store -->|"saves and loads"| node_persistence
node_persistence -->|"reads and writes"| node_db_file

click node_cli "https://github.com/honey-singh716/miniredis/blob/main/main.cpp"
click node_parser "https://github.com/honey-singh716/miniredis/blob/main/src/CommandParser.cpp"
click node_store "https://github.com/honey-singh716/miniredis/blob/main/src/RedisStore.cpp"
click node_expiry_metadata "https://github.com/honey-singh716/miniredis/blob/main/src/RedisStore.cpp"
click node_hash "https://github.com/honey-singh716/miniredis/blob/main/src/HashTable.cpp"
click node_lru "https://github.com/honey-singh716/miniredis/blob/main/src/LRUCache.cpp"
click node_ttl "https://github.com/honey-singh716/miniredis/blob/main/src/TTLManager.cpp"
click node_expiry_heap "https://github.com/honey-singh716/miniredis/blob/main/include/TTLManager.h"
click node_persistence "https://github.com/honey-singh716/miniredis/blob/main/src/Persistence.cpp"
click node_db_file "https://github.com/honey-singh716/miniredis/blob/main/miniredis.db"

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,node_parser,node_user toneBlue
class node_store,node_expiry_metadata,node_ttl toneAmber
class node_hash,node_lru,node_expiry_heap toneMint
class node_persistence,node_db_file toneRose
```

## Components

### Command Interface

- [Interactive CLI](https://github.com/honey-singh716/miniredis/blob/main/main.cpp): `main.cpp`
- [Command Parser](https://github.com/honey-singh716/miniredis/blob/main/src/CommandParser.cpp): `src/CommandParser.cpp`

### Store Coordination

- [RedisStore](https://github.com/honey-singh716/miniredis/blob/main/src/RedisStore.cpp): `src/RedisStore.cpp`
- [Expiry and Version Maps](https://github.com/honey-singh716/miniredis/blob/main/src/RedisStore.cpp): `src/RedisStore.cpp`
- [TTL Manager](https://github.com/honey-singh716/miniredis/blob/main/src/TTLManager.cpp): `src/TTLManager.cpp`

### Storage Structures

- [Hash Table](https://github.com/honey-singh716/miniredis/blob/main/src/HashTable.cpp): `src/HashTable.cpp`
- [LRU Cache](https://github.com/honey-singh716/miniredis/blob/main/src/LRUCache.cpp): `src/LRUCache.cpp`
- [Expiry Min-Heap](https://github.com/honey-singh716/miniredis/blob/main/include/TTLManager.h): `include/TTLManager.h`

### Persistence

- [Persistence](https://github.com/honey-singh716/miniredis/blob/main/src/Persistence.cpp): `src/Persistence.cpp`
- [Database File](https://github.com/honey-singh716/miniredis/blob/main/miniredis.db): `miniredis.db`

### Other components

- **User**

## Connections

- User → Interactive CLI: enters commands (evidence: `README.md`)
- Interactive CLI → Command Parser: tokenizes and dispatches (evidence: `main.cpp`)
- Command Parser → RedisStore: dispatches operations (evidence: `src/CommandParser.cpp`)
- RedisStore → Hash Table: reads and writes (evidence: `src/RedisStore.cpp`)
- RedisStore → LRU Cache: checks and updates (evidence: `src/RedisStore.cpp`)
- RedisStore → TTL Manager: schedules expirations (evidence: `src/RedisStore.cpp`)
- RedisStore → Expiry and Version Maps: tracks expiry versions (evidence: `src/RedisStore.cpp`)
- TTL Manager → Expiry Min-Heap: adds and removes (evidence: `src/TTLManager.cpp`)
- RedisStore → Persistence: saves and loads (evidence: `src/RedisStore.cpp`)
- Persistence → Database File: reads and writes (evidence: `README.md`)
