# akshaydubey05/goredis architecture

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

- Interactive diagram: https://gitdiagram.com/akshaydubey05/goredis
- Repository: https://github.com/akshaydubey05/goredis

## Overview

GoRedis is a Redis-compatible key-value store whose principal workflow accepts RESP commands, proposes them through Raft, applies committed commands to a deterministic state machine, and replies to clients. It also provides a simulated-cluster HTTP API and dashboard for observing elections and injecting faults. The README and excerpts establish the main runtime wiring; unsampled Raft internals are represented as one subsystem rather than asserting unsupported internal calls.

Main entry points: [`web/src/App.tsx`](https://github.com/akshaydubey05/goredis/blob/main/web/src/App.tsx) (Dashboard app), [`internal/gateway/gateway.go`](https://github.com/akshaydubey05/goredis/blob/main/internal/gateway/gateway.go) (HTTP gateway), [`internal/raft`](https://github.com/akshaydubey05/goredis/tree/main/internal/raft) (Raft consensus), [`internal/sim/sim.go`](https://github.com/akshaydubey05/goredis/blob/main/internal/sim/sim.go) (Cluster simulator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client access"]
  node_resp_server["RESP server<br/>[server.go]"]
  node_resp_codec["RESP codec<br/>[resp.go]"]
  node_cluster_node["Cluster node<br/>[node.go]"]
end

subgraph group_consensus["Raft storage"]
  node_raft["Raft consensus"]
  node_raft_storage[("Raft persistence<br/>[storage.go]")]
  node_tcp_transport["TCP transport<br/>[tcp.go]"]
  node_fsm["Deterministic FSM<br/>[fsm.go]"]
  node_store[("Key-value store<br/>[store.go]")]
end

subgraph group_simulation["Simulation API"]
  node_sim["Cluster simulator<br/>[sim.go]"]
  node_simnet["Fault network<br/>[simnet.go]"]
  node_gateway["HTTP gateway<br/>[gateway.go]"]
  node_gateway_main["Gateway startup<br/>[main.go]"]
end

subgraph group_dashboard["Web dashboard"]
  node_app["Dashboard app<br/>[App.tsx]"]
  node_stream_hook["Cluster stream"]
  node_node_card["Node controls<br/>[NodeCard.tsx]"]
  node_terminal["Command terminal<br/>[Terminal.tsx]"]
end

node_redis_client(("Redis client"))
node_browser(("Dashboard visitor"))

node_redis_client -->|"sends RESP"| node_resp_server
node_resp_server -->|"parses replies"| node_resp_codec
node_resp_server -->|"dispatches commands"| node_cluster_node
node_cluster_node -->|"proposes commands"| node_raft
node_raft -->|"applies commits"| node_fsm
node_fsm -->|"executes commands"| node_store
node_raft -.->|"persists state"| node_raft_storage
node_tcp_transport -->|"serves peer RPCs"| node_raft
node_gateway_main -->|"creates cluster"| node_sim
node_gateway_main -->|"starts HTTP API"| node_gateway
node_sim -->|"uses network"| node_simnet
node_sim -->|"creates nodes"| node_cluster_node
node_gateway -->|"reads and controls"| node_sim
node_browser -->|"uses dashboard"| node_app
node_app -->|"subscribes state"| node_stream_hook
node_app -->|"renders controls"| node_node_card
node_app -->|"renders terminal"| node_terminal
node_stream_hook -->|"receives SSE"| node_gateway
node_terminal -->|"posts commands"| node_gateway
node_app -->|"posts fault actions"| node_gateway

click node_resp_server "https://github.com/akshaydubey05/goredis/blob/main/internal/cluster/server.go"
click node_resp_codec "https://github.com/akshaydubey05/goredis/blob/main/internal/resp/resp.go"
click node_cluster_node "https://github.com/akshaydubey05/goredis/blob/main/internal/cluster/node.go"
click node_raft "https://github.com/akshaydubey05/goredis/tree/main/internal/raft"
click node_raft_storage "https://github.com/akshaydubey05/goredis/blob/main/internal/raft/storage.go"
click node_tcp_transport "https://github.com/akshaydubey05/goredis/blob/main/internal/transport/tcp.go"
click node_fsm "https://github.com/akshaydubey05/goredis/blob/main/internal/fsm/fsm.go"
click node_store "https://github.com/akshaydubey05/goredis/blob/main/internal/store/store.go"
click node_sim "https://github.com/akshaydubey05/goredis/blob/main/internal/sim/sim.go"
click node_simnet "https://github.com/akshaydubey05/goredis/blob/main/internal/simnet/simnet.go"
click node_gateway "https://github.com/akshaydubey05/goredis/blob/main/internal/gateway/gateway.go"
click node_gateway_main "https://github.com/akshaydubey05/goredis/blob/main/cmd/gateway/main.go"
click node_app "https://github.com/akshaydubey05/goredis/blob/main/web/src/App.tsx"
click node_stream_hook "https://github.com/akshaydubey05/goredis/blob/main/web/src/useClusterStream.ts"
click node_node_card "https://github.com/akshaydubey05/goredis/blob/main/web/src/NodeCard.tsx"
click node_terminal "https://github.com/akshaydubey05/goredis/blob/main/web/src/Terminal.tsx"

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_resp_server,node_resp_codec,node_cluster_node toneBlue
class node_raft,node_raft_storage,node_tcp_transport,node_fsm,node_store,node_redis_client toneAmber
class node_sim,node_simnet,node_gateway,node_gateway_main toneMint
class node_app,node_stream_hook,node_node_card,node_terminal toneRose
class node_browser toneIndigo
```

## Components

### Client access

- [RESP server](https://github.com/akshaydubey05/goredis/blob/main/internal/cluster/server.go): `internal/cluster/server.go`
- [RESP codec](https://github.com/akshaydubey05/goredis/blob/main/internal/resp/resp.go): `internal/resp/resp.go`
- [Cluster node](https://github.com/akshaydubey05/goredis/blob/main/internal/cluster/node.go): `internal/cluster/node.go`

### Raft storage

- [Raft consensus](https://github.com/akshaydubey05/goredis/tree/main/internal/raft): `internal/raft`
- [Raft persistence](https://github.com/akshaydubey05/goredis/blob/main/internal/raft/storage.go): `internal/raft/storage.go`
- [TCP transport](https://github.com/akshaydubey05/goredis/blob/main/internal/transport/tcp.go): `internal/transport/tcp.go`
- [Deterministic FSM](https://github.com/akshaydubey05/goredis/blob/main/internal/fsm/fsm.go): `internal/fsm/fsm.go`
- [Key-value store](https://github.com/akshaydubey05/goredis/blob/main/internal/store/store.go): `internal/store/store.go`

### Simulation API

- [Cluster simulator](https://github.com/akshaydubey05/goredis/blob/main/internal/sim/sim.go): `internal/sim/sim.go`
- [Fault network](https://github.com/akshaydubey05/goredis/blob/main/internal/simnet/simnet.go): `internal/simnet/simnet.go`
- [HTTP gateway](https://github.com/akshaydubey05/goredis/blob/main/internal/gateway/gateway.go): `internal/gateway/gateway.go`
- [Gateway startup](https://github.com/akshaydubey05/goredis/blob/main/cmd/gateway/main.go): `cmd/gateway/main.go`

### Web dashboard

- [Dashboard app](https://github.com/akshaydubey05/goredis/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Cluster stream](https://github.com/akshaydubey05/goredis/blob/main/web/src/useClusterStream.ts): `web/src/useClusterStream.ts`
- [Node controls](https://github.com/akshaydubey05/goredis/blob/main/web/src/NodeCard.tsx): `web/src/NodeCard.tsx`
- [Command terminal](https://github.com/akshaydubey05/goredis/blob/main/web/src/Terminal.tsx): `web/src/Terminal.tsx`

### Other components

- **Redis client**
- **Dashboard visitor**

## Connections

- Redis client → RESP server: sends RESP (evidence: `README.md`)
- RESP server → RESP codec: parses replies (evidence: `internal/cluster/server.go`)
- RESP server → Cluster node: dispatches commands (evidence: `internal/cluster/server.go`)
- Cluster node → Raft consensus: proposes commands (evidence: `README.md`)
- Raft consensus → Deterministic FSM: applies commits (evidence: `README.md`)
- Deterministic FSM → Key-value store: executes commands (evidence: `internal/fsm/fsm.go`)
- Raft consensus → Raft persistence: persists state
- TCP transport → Raft consensus: serves peer RPCs (evidence: `internal/transport/tcp.go`)
- Gateway startup → Cluster simulator: creates cluster (evidence: `cmd/gateway/main.go`)
- Gateway startup → HTTP gateway: starts HTTP API (evidence: `cmd/gateway/main.go`)
- Cluster simulator → Fault network: uses network (evidence: `internal/sim/sim.go`)
- Cluster simulator → Cluster node: creates nodes (evidence: `internal/sim/sim.go`)
- HTTP gateway → Cluster simulator: reads and controls (evidence: `internal/gateway/gateway.go`)
- Dashboard visitor → Dashboard app: uses dashboard (evidence: `README.md`)
- Dashboard app → Cluster stream: subscribes state (evidence: `web/src/App.tsx`)
- Dashboard app → Node controls: renders controls (evidence: `web/src/App.tsx`)
- Dashboard app → Command terminal: renders terminal (evidence: `web/src/App.tsx`)
- Cluster stream → HTTP gateway: receives SSE (evidence: `web/src/useClusterStream.ts`)
- Command terminal → HTTP gateway: posts commands (evidence: `web/src/Terminal.tsx`)
- Dashboard app → HTTP gateway: posts fault actions (evidence: `web/src/App.tsx`)
