How boltdb/bolt works
Bolt is an embedded Go key/value database: applications open a file-backed DB, run read or write transactions, and use buckets and cursors to access ordered keys and values. Writes are committed as paged data with freelist-managed allocation; platform files provide OS-specific locking and memory mapping. The CLI adds inspection, statistics, benchmarking, and compaction commands. Relationships below follow the README and shown excerpts; unsampled wiring is omitted rather than inferred.
Main entry points: db.go DB lifecycle · tx.go Transactions · bucket.go Buckets and values · node.go B-tree nodes
Components 12
Database API
- DB lifecycle
db.go - Transactions
tx.go - Buckets and values
bucket.go - Ordered traversal
cursor.go
Storage Engine
- Database file
- B-tree nodes
node.go - Page format
page.go - Page allocation
freelist.go
Platform I/O
- Unix lock and mmap
bolt_unix.go - Windows lock and mmap
bolt_windows.go
Bolt CLI
- CLI commands
cmd/bolt/main.go
Other components
- Application
Connections 12
- Application → DB lifecycle: opens
README.md - DB lifecycle → Transactions: starts
README.md - Transactions → Buckets and values: creates
tx.go - Buckets and values → Ordered traversal: seeks
bucket.go - Buckets and values → B-tree nodes: updates
bucket.go - Ordered traversal → B-tree nodes: searches
cursor.go - B-tree nodes → Page format: writes
node.go - DB lifecycle → Page allocation: allocates pages
db.go - Transactions → Page allocation: writes free list
tx.go - DB lifecycle → Database file: persists
README.md - DB lifecycle → Unix lock and mmap: uses OS I/O
- DB lifecycle → Windows lock and mmap: uses OS I/O