How jusxtdev/kv-store works
This is a single-process HTTP key–value store. Clients use its JSON API to create, read, update, delete, list, or clear values; mutations are logged before the in-memory map changes. On startup, the application loads snapshot state and replays later WAL records, then periodically writes snapshots. Replication and inter-node communication are documented as future ideas, not implemented. The graph follows documented architecture and sampled source; some finer recovery and HTTP wiring details are not shown beyond those sources.
Main entry points: main.go API server · snapshot.go Snapshot manager · wal.go WAL operations · memory.go In-memory store
Components 12
HTTP API
- Health handler
internal/handler/health.go - KV handlers
internal/handler/kv.go - JSON responses
internal/handler/common.go
Key-Value Storage
- Store interface
internal/repository/interface.go - In-memory store
internal/repository/memory.go
Durability and Recovery
- WAL operations
internal/wal/wal.go - WAL records
internal/wal/record.go - Snapshot manager
internal/snapshot/snapshot.go - wal.log
- snapshot.json
Application Lifecycle
- API server
cmd/api/main.go
Other components
- HTTP client
Connections 18
- HTTP client → API server: sends HTTP
- API server → Health handler: routes health
- API server → KV handlers: routes KV
- Health handler → JSON responses: writes JSON
- KV handlers → Store interface: calls operations
- KV handlers → JSON responses: writes JSON
- In-memory store → Store interface: implements
- In-memory store → WAL operations: appends mutations
- WAL operations → WAL records: parses records
- WAL operations → wal.log: appends and replays
- API server → WAL operations: opens and replays
- API server → Snapshot manager: initializes and restores
- API server → In-memory store: restores and enables logging
- Snapshot manager → In-memory store: reads state
- Snapshot manager → WAL operations: reads checkpoint
- Snapshot manager → snapshot.json: writes snapshot
- Snapshot manager → snapshot.json: loads snapshot
- API server → Snapshot manager: triggers every 10 seconds