Getting Started
About 220 words
Requirements
Granary needs Zig 0.17.0, the version .mise.toml pins; minimum_zig_version in build.zig.zon is the oldest it supports.
If you use mise, .mise.toml declares the toolchain and the linters, so a single command gets you set up:
mise installBuild, run, and test
zig build # compile
zig build run # run the executable
zig build test # run the full test suite (all modules)
mise run check # every gate CI runs: zig fmt --check, yamllint, actionlint, build, testsThe test suite is the best way into the code. Election, replication, WAL replay, conflict truncation, and serialization round-trips each have focused tests in their own modules, so reading them tells you how every part is meant to behave.
Project layout
src/
main.zig # executable entry point
root.zig # library root
log/ # commands, payloads, log store, WAL serialization
state/ # key-value state machine
transport/ # transport interface + RPC messages
node/ # RaftNode: the Raft protocol
testing/ # in-memory transport and test helpers
docs/
references/
wal-format.md # binary WAL layout
build.zig # build graph and module wiringFor how these modules connect at runtime, see the Architecture page.
References
- The Raft paper, In Search of an Understandable Consensus Algorithm
- raft.github.io for visualizations and resources
- Zig language reference
