# veeravardhan35/nexus-kv architecture

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

- Interactive diagram: https://gitdiagram.com/veeravardhan35/nexus-kv
- Repository: https://github.com/veeravardhan35/nexus-kv

## Overview

NexusKV is a miniature in-memory key-value store exposed through a REST API, with consistent-hash sharding, replicated writes, TTL expiry, WAL durability and crash recovery. The main workflow is an HTTP key operation entering the server, passing validation, reaching KVEngine for shard selection and replication, then operating on shard memory and its WAL. The dashboard adds live topology, operation and recovery controls. The README and excerpts establish the core flow; some dashboard/admin endpoint wiring and engine internals are only partially sampled, so uncertain links are omitted or marked unverified.

Main entry points: [`src/server.js`](https://github.com/veeravardhan35/nexus-kv/blob/main/src/server.js) (REST Server), [`src/core/KVEngine.js`](https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/KVEngine.js) (KV Engine), [`src/routes/kv.routes.js`](https://github.com/veeravardhan35/nexus-kv/blob/main/src/routes/kv.routes.js) (KV Routes), [`src/core/StorageShard.js`](https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/StorageShard.js) (Storage Shard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP and Dashboard"]
  node_dashboard["Interactive Dashboard<br/>[app.js]"]
  node_dashboard_setup["Dashboard Setup<br/>[setup.js]"]
  node_server["REST Server<br/>[server.js]"]
  node_routes["KV Routes<br/>[kv.routes.js]"]
  node_validator["Request Validation<br/>[validator.js]"]
  node_config["Runtime Config<br/>[config.js]"]
  node_bootstrap["Alternate Bootstrap<br/>[index.js]"]
end

subgraph group_engine["Routing and Replication"]
  node_engine["KV Engine<br/>[KVEngine.js]"]
  node_ring["Hash Ring"]
end

subgraph group_storage["Shard Storage"]
  node_shard["Storage Shard<br/>[StorageShard.js]"]
  node_memory[("Shard Map<br/>[StorageShard.js]")]
end

subgraph group_durability["Durability"]
  node_wal["WAL Manager<br/>[WALManager.js]"]
  node_wal_files[("Shard WAL Files")]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_server
node_dashboard -->|"polls and operates"| node_server
node_dashboard_setup -.->|"requests reinit"| node_server
node_server -->|"dispatches operations"| node_engine
node_server -->|"imports validation"| node_validator
node_server -->|"loads settings"| node_config
node_bootstrap -->|"registers router"| node_routes
node_routes -->|"validates requests"| node_validator
node_routes -->|"dispatches operations"| node_engine
node_engine -->|"selects shards"| node_ring
node_engine -->|"reads and writes"| node_shard
node_shard -->|"updates entries"| node_memory
node_shard -->|"appends and replays"| node_wal
node_wal -->|"persists records"| node_wal_files

click node_dashboard "https://github.com/veeravardhan35/nexus-kv/blob/main/dashboard/app.js"
click node_dashboard_setup "https://github.com/veeravardhan35/nexus-kv/blob/main/dashboard/setup.js"
click node_server "https://github.com/veeravardhan35/nexus-kv/blob/main/src/server.js"
click node_routes "https://github.com/veeravardhan35/nexus-kv/blob/main/src/routes/kv.routes.js"
click node_validator "https://github.com/veeravardhan35/nexus-kv/blob/main/src/middleware/validator.js"
click node_config "https://github.com/veeravardhan35/nexus-kv/blob/main/src/config.js"
click node_bootstrap "https://github.com/veeravardhan35/nexus-kv/blob/main/src/index.js"
click node_engine "https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/KVEngine.js"
click node_ring "https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/ConsistentHashRing.js"
click node_shard "https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/StorageShard.js"
click node_memory "https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/StorageShard.js"
click node_wal "https://github.com/veeravardhan35/nexus-kv/blob/main/src/persistence/WALManager.js"

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_dashboard,node_dashboard_setup,node_server,node_routes,node_validator,node_config,node_bootstrap,node_client toneBlue
class node_engine,node_ring toneAmber
class node_shard,node_memory toneMint
class node_wal,node_wal_files toneRose
```

## Components

### HTTP and Dashboard

- [Interactive Dashboard](https://github.com/veeravardhan35/nexus-kv/blob/main/dashboard/app.js): `dashboard/app.js`
- [Dashboard Setup](https://github.com/veeravardhan35/nexus-kv/blob/main/dashboard/setup.js): `dashboard/setup.js`
- [REST Server](https://github.com/veeravardhan35/nexus-kv/blob/main/src/server.js): `src/server.js`
- [KV Routes](https://github.com/veeravardhan35/nexus-kv/blob/main/src/routes/kv.routes.js): `src/routes/kv.routes.js`
- [Request Validation](https://github.com/veeravardhan35/nexus-kv/blob/main/src/middleware/validator.js): `src/middleware/validator.js`
- [Runtime Config](https://github.com/veeravardhan35/nexus-kv/blob/main/src/config.js): `src/config.js`
- [Alternate Bootstrap](https://github.com/veeravardhan35/nexus-kv/blob/main/src/index.js): `src/index.js`

### Routing and Replication

- [KV Engine](https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/KVEngine.js): `src/core/KVEngine.js`
- [Hash Ring](https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/ConsistentHashRing.js): `src/core/ConsistentHashRing.js`

### Shard Storage

- [Storage Shard](https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/StorageShard.js): `src/core/StorageShard.js`
- [Shard Map](https://github.com/veeravardhan35/nexus-kv/blob/main/src/core/StorageShard.js): `src/core/StorageShard.js`

### Durability

- [WAL Manager](https://github.com/veeravardhan35/nexus-kv/blob/main/src/persistence/WALManager.js): `src/persistence/WALManager.js`
- **Shard WAL Files**

### Other components

- **API Client**

## Connections

- API Client → REST Server: sends requests (evidence: `README.md`)
- Interactive Dashboard → REST Server: polls and operates (evidence: `dashboard/app.js`)
- Dashboard Setup → REST Server: requests reinit
- REST Server → KV Engine: dispatches operations (evidence: `src/server.js`)
- REST Server → Request Validation: imports validation (evidence: `src/server.js`)
- REST Server → Runtime Config: loads settings (evidence: `src/server.js`)
- Alternate Bootstrap → KV Routes: registers router (evidence: `src/index.js`)
- KV Routes → Request Validation: validates requests (evidence: `src/routes/kv.routes.js`)
- KV Routes → KV Engine: dispatches operations (evidence: `src/routes/kv.routes.js`)
- KV Engine → Hash Ring: selects shards (evidence: `src/core/KVEngine.js`)
- KV Engine → Storage Shard: reads and writes (evidence: `src/core/KVEngine.js`)
- Storage Shard → Shard Map: updates entries (evidence: `src/core/StorageShard.js`)
- Storage Shard → WAL Manager: appends and replays (evidence: `src/core/StorageShard.js`)
- WAL Manager → Shard WAL Files: persists records (evidence: `src/persistence/WALManager.js`)
