A production-ready, segmented key-value storage engine written in Go
Features β’ Quick Start β’ Architecture β’ API Documentation β’ Contributing
Mini KV Store Go is a Go port of the original Rust implementation (mini-kvstore-v2).
Itβs a high-performance, append-only key-value storage engine with HTTP API, implementing segmented logs, compaction, bloom filters, index snapshots, and crash recovery.
Why This Project?
A direct translation from Rust to Go, keeping the original architecture, and showing that clear DB design patterns are language-agnostic.
Leverages Goβs concurrency and simplicity for production-like services.
Core Storage Engine
- Durable & crash-safe (append-only log with fsync)
- Segmented architecture with automatic rotation
- O(1) fast reads via in-memory HashMap index
- Manual compaction for space reclamation
- CRC32 checksums for data integrity
- Index snapshots enable quick restarts
- Tombstone deletions efficiently mark deleted keys
- Bloom filters speed up negative lookups
Production Ready
- HTTP REST API (Gorilla Mux)
- Interactive CLI (REPL) for testing and exploration
/metricsendpoint for monitoring/healthendpoint for load balancers- Graceful shutdown (SIGTERM/SIGINT with snapshot saving)
- Unit and integration test suites
- Docker & docker-compose support
- CI/CD pipeline for automated testing and builds
- Configurable request body limits
Developer Experience
- Clean, idiomatic Go code
- Modular, maintainable design
- Makefile for common tasks
- Configurable via environment variables
Prerequisites:
- Go 1.21+ (install)
- Make (optional)
- Git
git clone https://github.com/whispem/mini-kvstore-go
cd mini-kvstore-go
go mod download
make build
make testREPL CLI:
make run
# > set key Alice
# > get key
# > list
# > stats
# > compact
# > quitHTTP server:
make server
# or:
PORT=9000 VOLUME_ID=my-vol DATA_DIR=./data go run ./cmd/volume-server/healthβ server health/metricsβ real-time statsPOST /blobs/:keyβ store blobGET /blobs/:keyβ fetch blobDELETE /blobs/:keyβ delete blobGET /blobsβ list all keys
Examples:
curl -X POST http://localhost:9002/blobs/user:123 -d "Hello, World!"
curl http://localhost:9002/blobs/user:123
curl -X DELETE http://localhost:9002/blobs/user:123[CLI / HTTP Client]
β
[HTTP Server]
β
[Blob Storage]
β
[KVStore Core]
/ | \
[Index][Segments][Bloom]
- Append-only segments on disk, in-memory index and bloom for speed
- Snapshot & compaction for instant restart / low disk use
store, err := pkgstore.Open("data")
store.Set("foo", []byte("bar"))
val, _ := store.Get("foo")
// ...
store.Compact()
store.SaveSnapshot()Standalone:
docker build -t mini-kvstore-go:latest .
docker run -d -p 9002:9002 -v $(pwd)/data:/data --name kvstore mini-kvstore-go:latestCluster:
docker-compose up -d
# nodes: localhost:9001 ... :9003
docker-compose logs -fmake test
go test -v -cover ./...- Unit & integration tests for core & API
mini-kvstore-go/
βββ cmd/
βββ pkg/
βββ internal/
βββ examples/
βββ .github/
βββ Dockerfile
βββ docker-compose.yml
βββ Makefile
βββ go.mod
βββ README.md
- Formatting:
go fmt - Linting:
golangci-lint - Tests: Makefile or
go test ./... - Pre-commit checks:
make pre-commit
- Segmented log, in-memory index
- Compaction, crash safety
- CLI, HTTP, Docker, CI
- Bloom filters, index snapshots
- Background compaction
- Range queries
- WAL, compression
- Replication, gRPC, Prometheus
- Found a bug? Create an issue!
- Suggest a feature or improvement
- PRs to docs, examples, or code are welcome
MIT β see LICENSE
Em' (@whispem) β Go port of the Rust engine, made to understand DBs from the inside.
Built with β€οΈ in Go