# vikasjha2003/concurrent-kv architecture

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

- Interactive diagram: https://gitdiagram.com/vikasjha2003/concurrent-kv
- Repository: https://github.com/vikasjha2003/concurrent-kv

## Overview

Concurrent-KV is a single-node, multithreaded TCP key-value server. Its main workflow accepts newline-delimited client commands, parses and dispatches them, performs synchronized store operations, and returns protocol responses. The store also provides LRU eviction, TTL expiration, and manual binary snapshots; a separate benchmark client drives concurrent traffic. The source excerpts show the server-to-processor-to-store calls and snapshot operations. The README documents the benchmark and its connection to the server; internal benchmark implementation details were not sampled.

Main entry points: [`src/store/kv_store.cpp`](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp) (Key-Value Store), [`src/server/tcp_server.cpp`](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/server/tcp_server.cpp) (TCP Server), [`src/main.cpp`](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/main.cpp) (Startup), [`src/command/command_processor.cpp`](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/command/command_processor.cpp) (Command Processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server Runtime"]
  node_main["Startup<br/>[main.cpp]"]
  node_tcp["TCP Server<br/>[tcp_server.cpp]"]
end

subgraph group_protocol["Command Protocol"]
  node_processor["Command Processor"]
end

subgraph group_storage["Store and Persistence"]
  node_kv["Key-Value Store<br/>[kv_store.cpp]"]
  node_lru["LRU Eviction<br/>[kv_store.cpp]"]
  node_ttl["TTL Expiration<br/>[kv_store.cpp]"]
  node_snapshot["Snapshot Persistence<br/>[kv_store.cpp]"]
  node_snapshotfile[("Snapshot File")]
end

subgraph group_benchmark["Load Testing"]
  node_bench["Benchmark Client<br/>[bench.cpp]"]
end

node_client(("TCP Client"))

node_main -->|"creates and loads"| node_kv
node_main -->|"creates"| node_processor
node_main -->|"runs"| node_tcp
node_client -->|"sends commands"| node_tcp
node_tcp -->|"processes lines"| node_processor
node_processor -->|"dispatches operations"| node_kv
node_kv -->|"maintains recency"| node_lru
node_kv -->|"checks and sweeps"| node_ttl
node_kv -->|"loads and saves"| node_snapshot
node_snapshot -->|"reads and writes"| node_snapshotfile
node_bench -->|"drives traffic"| node_tcp

click node_main "https://github.com/vikasjha2003/concurrent-kv/blob/main/src/main.cpp"
click node_tcp "https://github.com/vikasjha2003/concurrent-kv/blob/main/src/server/tcp_server.cpp"
click node_processor "https://github.com/vikasjha2003/concurrent-kv/blob/main/src/command/command_processor.cpp"
click node_kv "https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp"
click node_lru "https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp"
click node_ttl "https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp"
click node_snapshot "https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp"
click node_bench "https://github.com/vikasjha2003/concurrent-kv/blob/main/src/bench/bench.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_main,node_tcp,node_client toneBlue
class node_processor toneAmber
class node_kv,node_lru,node_ttl,node_snapshot,node_snapshotfile toneMint
class node_bench toneRose
```

## Components

### Server Runtime

- [Startup](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/main.cpp): `src/main.cpp`
- [TCP Server](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/server/tcp_server.cpp): `src/server/tcp_server.cpp`

### Command Protocol

- [Command Processor](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/command/command_processor.cpp): `src/command/command_processor.cpp`

### Store and Persistence

- [Key-Value Store](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp): `src/store/kv_store.cpp`
- [LRU Eviction](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp): `src/store/kv_store.cpp`
- [TTL Expiration](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp): `src/store/kv_store.cpp`
- [Snapshot Persistence](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/store/kv_store.cpp): `src/store/kv_store.cpp`
- **Snapshot File**

### Load Testing

- [Benchmark Client](https://github.com/vikasjha2003/concurrent-kv/blob/main/src/bench/bench.cpp): `src/bench/bench.cpp`

### Other components

- **TCP Client**

## Connections

- Startup → Key-Value Store: creates and loads (evidence: `src/main.cpp`)
- Startup → Command Processor: creates (evidence: `src/main.cpp`)
- Startup → TCP Server: runs (evidence: `src/main.cpp`)
- TCP Client → TCP Server: sends commands (evidence: `README.md`)
- TCP Server → Command Processor: processes lines (evidence: `src/server/tcp_server.cpp`)
- Command Processor → Key-Value Store: dispatches operations (evidence: `src/command/command_processor.cpp`)
- Key-Value Store → LRU Eviction: maintains recency (evidence: `src/store/kv_store.cpp`)
- Key-Value Store → TTL Expiration: checks and sweeps (evidence: `src/store/kv_store.cpp`)
- Key-Value Store → Snapshot Persistence: loads and saves (evidence: `src/store/kv_store.cpp`)
- Snapshot Persistence → Snapshot File: reads and writes (evidence: `src/store/kv_store.cpp`)
- Benchmark Client → TCP Server: drives traffic (evidence: `README.md`)
