Logo
Logo

Architecture

Append-only logs, a write-ahead log, a SHA-256 hash chain, file indexes and modular Go engines.

One binary, several engines

GenesisDB is one Go module. Each engine is its own package with a single job, and the engines use the Go standard library only:

EngineJob
storageAppend-only event logs, write-ahead log, reference data, system events
indexFixed-shard file indexes by subject and type
cacheBounded LRU cache of recently read events
queryGDBQL parser, planner and executor
schemaValidation of event data against registered schemas
storeThe complete embedded database, composed of the engines above
serverThe HTTP API

Each engine can be imported on its own, see Embedded in Go.

Writes

A commit is checked against its preconditions and schemas under the writer lock, written to a checksummed write-ahead log, appended to the event log, fsynced, and only then published to the indexes and acknowledged. A crash at any point is recovered on the next start by replaying the write-ahead log, so a batch is either fully visible or not at all.

Hash chain

Every event carries a SHA-256 hash and the predecessorhash of the event before it. The hash binds the predecessor, the hash version, the metadata and the payload. GET /api/v2/admin/audit walks the whole chain and reports the first mismatch.

A hash chain detects accidental corruption and modification without write access to the history. It is not a signature: someone with write access to the data directory can rewrite a whole chain. Keep independent backups and external checkpoints if that matters.

Indexes

Indexes map subjects and types to event positions. They are updated on every commit and can be rebuilt from the event logs at any time. GDBQL conditions on e.subject and e.type use them, and the planner picks the most selective one in an AND chain.

Durability

Durability relies on a filesystem and hardware that honor file and directory synchronization. GenesisDB is a single node database: one process owns a data directory, there is no replication or consensus.

Authentication

Every route except /ping requires a bearer token:

text
Authorization: Bearer <token>

There are three roles: the administrator token (GENESISDB_AUTH_TOKEN), an optional writer token and an optional reader token. See Security.