Architecture
Repository layout and the current responsibility split across Chabi packages and apps.
Workspace Layout
Rust Packages
-
packages/chabi-coreContains RESP types, command implementations, storage types, and shared primitives. -
packages/chabi-serverThe main runtime. It wires the command registry, Redis TCP server, HTTP server, metrics, and snapshot persistence. -
packages/chabi-redis-handlerExperimental reusable RESP server components. -
packages/chabi-http-handlerExperimental reusable HTTP handler components.
Rust Apps
-
apps/chabi-testerEnd-to-end integration tests across Redis and HTTP. -
apps/membenchGo benchmark harness used for local and CI performance measurements.
Docs App
apps/docsStatic Next.js + Fumadocs site for Chabi documentation.
Runtime Shape
At startup, packages/chabi-server/src/main.rs:
- Parses CLI flags.
- Resolves environment-driven ports and snapshot settings.
- Creates a snapshot directory if one was not explicitly provided.
- Starts the Redis TCP server and HTTP server concurrently.
Redis Server Design
The Redis server:
- Keeps
16logical databases. - Builds one command registry per database.
- Tracks connection counts and total command counters for metrics.
- Handles some commands through special dispatch logic rather than the per-db registry.
That special path is where SELECT, FLUSHALL, transaction commands, pattern subscriptions, and SAVE live.
HTTP Server Design
The HTTP server is intentionally direct and minimal:
GET /health responseGET /metricsPrometheus textGET /snapshotJSON representation of the current snapshot state
It is not currently a second client API for reading and writing arbitrary keys.
Persistence Design
Chabi builds point-in-time snapshots from the in-memory stores, serializes them into redb, and restores them on boot.
Snapshot coverage includes:
- strings
- lists
- sets
- hashes
- sorted sets
- HyperLogLog
- expirations
The file path is always:
<snapshot_dir>/chabi.kdb