# tringuyenminh2801/multithread-redis architecture

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

- Interactive diagram: https://gitdiagram.com/tringuyenminh2801/multithread-redis
- Repository: https://github.com/tringuyenminh2801/multithread-redis

## Overview

multithread-redis is a Redis-compatible Go server whose main workflow accepts client bytes, decodes RESP commands, executes PING/GET/SET, and writes RESP replies. Configuration and observability are wired by the entrypoint; the server uses an OS event multiplexer. The README also documents optional deployment monitoring, while the bounded worker pool exists but is not used by the server. Monitoring connections are based on README documentation; deployment files were not sampled.

Main entry points: [`cmd/server/main.go`](https://github.com/tringuyenminh2801/multithread-redis/blob/main/cmd/server/main.go) (Server entrypoint), [`internal/server/server.go`](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/server/server.go) (TCP event loop), [`internal/command/orchestrator.go`](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/command/orchestrator.go) (Command orchestrator), [`internal/observability/metrics.go`](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/observability/metrics.go) (Metrics and health)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_entry["Server entrypoint<br/>[main.go]"]
  node_server["TCP event loop<br/>[server.go]"]
  node_iomux["I/O multiplexer"]
end

subgraph group_commands["Command processing"]
  node_orchestrator["Command orchestrator<br/>[orchestrator.go]"]
  node_resp["RESP codec<br/>[resp.go]"]
  node_store[("Key-value store<br/>[store.go]")]
end

subgraph group_support["Runtime support"]
  node_config["Configuration<br/>[config.go]"]
  node_kmp["CRLF search<br/>[kmp.go]"]
  node_pool["Worker pool<br/>[pool.go]"]
  node_logging["Structured logging<br/>[logging.go]"]
end

subgraph group_monitoring["Monitoring stack"]
  node_metrics["Metrics and health<br/>[metrics.go]"]
  node_collectors["Host collectors<br/>[compose.yml]"]
  node_alloy["Alloy collector<br/>[config.alloy]"]
  node_mimir["Mimir metrics<br/>[config.yaml]"]
  node_loki["Loki logs<br/>[config.yaml]"]
  node_grafana["Grafana dashboards<br/>[redis.json]"]
end

node_client(("Redis client"))

node_client -->|"sends commands"| node_server
node_entry -->|"loads settings"| node_config
node_entry -->|"sets up"| node_logging
node_entry -->|"creates"| node_store
node_entry -->|"creates handler"| node_orchestrator
node_entry -->|"configures"| node_server
node_entry -->|"starts HTTP"| node_metrics
node_server -->|"watches sockets"| node_iomux
node_server -->|"calls handler"| node_orchestrator
node_server -->|"writes replies"| node_client
node_orchestrator -->|"decodes and encodes"| node_resp
node_orchestrator -->|"reads and writes"| node_store
node_resp -->|"searches CRLF"| node_kmp
node_metrics -->|"samples connection stats"| node_server
node_client -.->|"scrapes metrics"| node_metrics
node_collectors -.->|"sends metrics"| node_alloy
node_metrics -.->|"provides metrics"| node_alloy
node_alloy -.->|"sends metrics"| node_mimir
node_alloy -.->|"sends logs"| node_loki
node_mimir -.->|"provides metrics"| node_grafana
node_loki -.->|"provides logs"| node_grafana

click node_entry "https://github.com/tringuyenminh2801/multithread-redis/blob/main/cmd/server/main.go"
click node_config "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/config/config.go"
click node_server "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/server/server.go"
click node_iomux "https://github.com/tringuyenminh2801/multithread-redis/tree/main/internal/iomux"
click node_orchestrator "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/command/orchestrator.go"
click node_resp "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/protocol/resp.go"
click node_kmp "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/algo/kmp.go"
click node_store "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/store/store.go"
click node_pool "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/pool/pool.go"
click node_logging "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/observability/logging.go"
click node_metrics "https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/observability/metrics.go"
click node_collectors "https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/app/compose.yml"
click node_alloy "https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/app/alloy/config.alloy"
click node_mimir "https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/monitoring/mimir/config.yaml"
click node_loki "https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/monitoring/loki/config.yaml"
click node_grafana "https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/monitoring/grafana/dashboards/redis.json"

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_entry,node_server,node_iomux toneBlue
class node_orchestrator,node_resp,node_store,node_client toneAmber
class node_config,node_kmp,node_pool,node_logging toneMint
class node_metrics,node_collectors,node_alloy,node_mimir,node_loki,node_grafana toneRose
```

## Components

### Server runtime

- [Server entrypoint](https://github.com/tringuyenminh2801/multithread-redis/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [TCP event loop](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/server/server.go): `internal/server/server.go`
- [I/O multiplexer](https://github.com/tringuyenminh2801/multithread-redis/tree/main/internal/iomux): `internal/iomux`

### Command processing

- [Command orchestrator](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/command/orchestrator.go): `internal/command/orchestrator.go`
- [RESP codec](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/protocol/resp.go): `internal/protocol/resp.go`
- [Key-value store](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/store/store.go): `internal/store/store.go`

### Runtime support

- [Configuration](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/config/config.go): `internal/config/config.go`
- [CRLF search](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/algo/kmp.go): `internal/algo/kmp.go`
- [Worker pool](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/pool/pool.go): `internal/pool/pool.go`
- [Structured logging](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/observability/logging.go): `internal/observability/logging.go`

### Monitoring stack

- [Metrics and health](https://github.com/tringuyenminh2801/multithread-redis/blob/main/internal/observability/metrics.go): `internal/observability/metrics.go`
- [Host collectors](https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/app/compose.yml): `deploy/app/compose.yml`
- [Alloy collector](https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/app/alloy/config.alloy): `deploy/app/alloy/config.alloy`
- [Mimir metrics](https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/monitoring/mimir/config.yaml): `deploy/monitoring/mimir/config.yaml`
- [Loki logs](https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/monitoring/loki/config.yaml): `deploy/monitoring/loki/config.yaml`
- [Grafana dashboards](https://github.com/tringuyenminh2801/multithread-redis/blob/main/deploy/monitoring/grafana/dashboards/redis.json): `deploy/monitoring/grafana/dashboards/redis.json`

### Other components

- **Redis client**

## Connections

- Redis client → TCP event loop: sends commands (evidence: `README.md`)
- Server entrypoint → Configuration: loads settings (evidence: `cmd/server/main.go`)
- Server entrypoint → Structured logging: sets up (evidence: `cmd/server/main.go`)
- Server entrypoint → Key-value store: creates (evidence: `cmd/server/main.go`)
- Server entrypoint → Command orchestrator: creates handler (evidence: `cmd/server/main.go`)
- Server entrypoint → TCP event loop: configures (evidence: `cmd/server/main.go`)
- Server entrypoint → Metrics and health: starts HTTP (evidence: `cmd/server/main.go`)
- TCP event loop → I/O multiplexer: watches sockets (evidence: `internal/server/server.go`)
- TCP event loop → Command orchestrator: calls handler (evidence: `internal/server/server.go`)
- TCP event loop → Redis client: writes replies (evidence: `internal/server/server.go`)
- Command orchestrator → RESP codec: decodes and encodes (evidence: `internal/command/orchestrator.go`)
- Command orchestrator → Key-value store: reads and writes (evidence: `internal/command/orchestrator.go`)
- RESP codec → CRLF search: searches CRLF (evidence: `internal/protocol/resp.go`)
- Metrics and health → TCP event loop: samples connection stats
- Redis client → Metrics and health: scrapes metrics (evidence: `README.md`)
- Host collectors → Alloy collector: sends metrics (evidence: `README.md`)
- Metrics and health → Alloy collector: provides metrics (evidence: `README.md`)
- Alloy collector → Mimir metrics: sends metrics (evidence: `README.md`)
- Alloy collector → Loki logs: sends logs (evidence: `README.md`)
- Mimir metrics → Grafana dashboards: provides metrics (evidence: `README.md`)
- Loki logs → Grafana dashboards: provides logs (evidence: `README.md`)
