A distributed key-value store built from scratch in Python with the Raft consensus algorithm for strong consistency across a cluster of nodes.
Leader-based replication with Raft consensus
Automatic leader election with term-based consistency
Receives heartbeats
Replicates log entries
Requests votes
Runs for leader
Handles all writes
Sends heartbeats
Everything you need for a distributed KV store
Term-based elections with randomized timeouts. Automatic failover when the leader goes down.
Append-only log with conflict detection and resolution. Entries committed when replicated to majority.
Linearizable reads and writes. All operations go through the elected leader.
Durable persistence with crash recovery. JSONL WAL with atomic state saves.
Log compaction via periodic snapshots. Prevents unbounded log growth.
One-command 3-node cluster with docker-compose. Health checks included.
RESTful HTTP API for clients + internal Raft RPC
| Method | Endpoint | Description |
|---|---|---|
| GET | /kv/{key} | Read a value |
| PUT | /kv/{key} | Set a key-value pair |
| DELETE | /kv/{key} | Delete a key |
| GET | /kv | List all keys and values |
| GET | /cluster/status | Full cluster status |
| GET | /cluster/leader | Current leader info |
| GET | /health | Health check |
| POST | /raft/vote | RequestVote RPC (internal) |
| POST | /raft/append | AppendEntries RPC (internal) |
Get a cluster running in seconds