Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

FoundationDB Layers — Go Implementations

Five self-contained Go implementations that show different ways to build a “layer” on top of FoundationDB. Modeled after real projects (mvsqlite, fdb-record-layer) but pared down for clarity.

Layout

FolderPlugs inTeaches
option-a-leveldbAbove LevelDBLevelDB’s external API: iterators, snapshots, write batches
option-a-sqliteAbove SQLiteHow SQL decomposes into storage ops; vtab query planning
option-b-leveldbBelow LevelDBLevelDB internals: SST files, WAL, MANIFEST, CURRENT
option-b-sqliteBelow SQLiteSQLite internals: page model, VFS, journaling
option-c-record-layerDirectly on FDBNative FDB layer: records + secondary indexes

Prerequisites

  1. Docker — to run a local single-node FDB cluster
  2. FoundationDB client library on the host (libfdb_c) — required by the Go bindings (CGO)
    • macOS: brew install foundationdb (or install the official .pkg from Apple’s release page)
  3. Go 1.22+

Bootstrap the cluster

docker compose up -d
./scripts/bootstrap-fdb.sh

This creates ./fdb.cluster at the repo root. Every demo reads it via the relative path ../fdb.cluster.

To shut down: docker compose down (data persists in ./fdb-data).

To wipe everything: docker compose down -v && rm -rf fdb-data fdb-config fdb.cluster.

Running a demo

Each option is an independent Go module:

cd option-a-leveldb
go run ./demo

See each folder’s docs/ for an architecture walk-through.

Documentation (mdbook)

The docs are structured as an mdbook under book/. To read them locally:

# Install mdbook (once)
brew install mdbook

# Build the book (output → book/dist/)
mdbook build

# Or serve with live-reload
mdbook serve --port 3001

The book is organized into two parts:

  • Background — The Hitchhiker’s Guide split into six chapters (storage stack, FDB internals, the layer concept, real-world systems, repo overview, further reading)
  • Labs — One overview + architecture walk-through per option