Transactions first
MVCC with snapshot and serializable isolation — its histories checked by Jepsen's Elle — over a write-ahead log and a crash-safe B+tree (or an LSM tree for write-heavy tables), underneath every model.
nucleus is a layered, multi-model database written in Rust from scratch. A transactional key-value core sits at the centre — SQL, documents and distribution are built around it, without rewriting what is inside.
# a key-value store, transactional from the first byte
$ nucleus kv ./mydb put greeting "hello world"
# SQL on the same core
$ nucleus sql ./mydb -c "CREATE TABLE t (id INT PRIMARY KEY, name TEXT)"
# serve it — nucleus protocol, and PostgreSQL's too
$ nucleus server ./mydb --pg-compat
nucleus 0.1.0 listening on 127.0.0.1:20035 (nucleus protocol) and 127.0.0.1:5432 (PostgreSQL compatibility) …Not a mock-up: nucleus's embedded edition compiled to WebAssembly, running in a worker through the same JavaScript driver a program uses. Nothing to install, no server behind it.
Run starts the database: the whole engine, compiled to WebAssembly, downloads once (2–3 MB, compressed) and runs here — no server. A table of 20 000 orders, a few notes with vectors, a collection of product documents and a small graph of who follows whom are waiting in it.
nc_catalog. It suggests as you type; Ctrl+Space asks.The engine is nucleus at 9842ac2, under the GNU AGPL-3.0; the driver is MIT; third-party notices.Get the key-value contract right, and everything above it can grow — or move onto a cluster — without a rewrite. The pattern behind FoundationDB and CockroachDB, built from the ground up.
An ordered, transactional key-value engine: a crash-safe copy-on-write B+tree (or an LSM tree, chosen per table), a write-ahead log and MVCC with snapshot and serializable isolation. Everything else is built on this contract.
A PostgreSQL-like dialect mapped onto keys and values — joins of every kind, CTEs, foreign keys, upserts, savepoints and sequences, a rich type system and a cost-based optimizer.
Collections of documents on the same core, in the same transactions as the tables — MongoDB-style queries compiled to SQL/JSON. No second engine, no second set of guarantees.
The keyspace cut into ranges, each replicated by Raft: nodes join, fail and are replaced, and a linearizable key-value store runs across them today. SQL across ranges — distributed transactions — is next, on the same contract.
The core, SQL and documents are here, replicated with automatic failover, along with the things a real deployment needs around them.
MVCC with snapshot and serializable isolation — its histories checked by Jepsen's Elle — over a write-ahead log and a crash-safe B+tree (or an LSM tree for write-heavy tables), underneath every model.
Its own protocol and the ncsql shell — and others as modules, like every type and operator: with --pg-compat, psql and PostgreSQL drivers connect as they are; with --mongo-compat, mongosh and MongoDB’s drivers.
CREATE COLLECTION: JSON documents keyed by _id. Filters, updates and upserts in MongoDB’s own form — in SQL, in every driver and in the shell — served by path and multi-valued indexes, in one transaction with the tables.
Tables stored as compressed column segments; scans, filters and aggregates run in batches through SIMD kernels on every core. Results arrive as columns — straight into numpy, Arrow, pandas and polars.
Vectors with HNSW indexes, full-text search ranked by BM25, and both fused in one query. Embeddings made by the database itself — a provider’s model or one it runs locally.
Append-only streams numbered by the commit, and changefeeds of every committed change of a table. Consumer groups move in the consumer’s own transaction: each batch handled exactly once, with its work.
CREATE QUEUE: TAKE leases the next task by priority, FINISH TASK commits in the work’s transaction, FAIL TASK retries with backoff or moves it to dead letters. Every driver runs a worker in one call.
SUBSCRIBE to a query, and each commit sends what it changed in the result. A query over one table is kept by the rows the commit wrote — the batch arrives 0.2 ms after it — without running it again.
A built-in Model Context Protocol server — local, or remote at the server’s /mcp — and memory for agents. Comments explain the schema, errors come with a hint, and the dialect is documented for models.
CREATE BRANCH copies the whole database in milliseconds, at any size. With a history kept, AS OF reads a table — or all of them — as it was.
Read replicas that follow every branch, asynchronous or synchronous — a commit in 0.31 ms with one replica. Automatic failover by election, a witness voting, no confirmed commit lost; drivers find the new primary on their own.
Users, roles, privileges and row-level security. SCRAM-SHA-256, TLS and client certificates, OpenID Connect, LDAP and a hash-chained audit log.
Prometheus metrics, alerts and OpenTelemetry traces. Incremental backups to disk or S3 — compressed, encrypted, scheduled, tested — restored to any point. Indexes, columns and types changed online, under writes.
Migrations with dry runs on a branch, schema diffs and dumps, and typed code generated for TypeScript, Rust, Python and Java — from the tables or from named queries.
Property graphs over the tables — CREATE PROPERTY GRAPH, then MATCH paths and shortest paths in GRAPH_TABLE. Recursive queries with SEARCH, CYCLE and USING KEY: shortest paths over 100,000 nodes in a fifth of a second.
Pages, log and backups encrypted at rest, the root key in AWS, Google Cloud or Azure KMS, Vault or an HSM. Rows sealed under each person’s own key, which FORGET SUBJECT destroys; columns the drivers encrypt, the server holding only ciphertext.
Link it into an application like SQLite, run it as a server — or open it in a web page, compiled to WebAssembly and kept in OPFS. Pages and edge functions reach a server over a WebSocket or HTTP. One engine, the same guarantees everywhere.
A phone, a browser or a program holds a server’s rows — the shapes its queries select, under the user’s own privileges and row-level security — writes them offline, and syncs both ways when a connection comes back.
Beside the nucleus protocol: GraphQL with subscriptions and REST in PostgREST’s forms on the web front end, and a gRPC service per table with --grpc — each made from the catalog as the caller sees it, under the same logins and access rules.
The keyspace cut into ranges, split and merged by size and load. Across servers, each range is a Raft group placed by locality rules; nodes join, are decommissioned or fail and are replaced. SQL across ranges is next.
Query time relative to PostgreSQL — lower is faster. Every answer checked against PostgreSQL's.
PostgreSQL 18.7 = 1.00×, native and tuned for the machine; medians of warm runs on an Apple M2 Pro. The method and every query: benchmarks.
Until the first release, build it from source — the toolchain installs itself. Or skip all of it: the playground runs it right here.
$ git clone https://github.com/davidsarosi92/nucleus.git
$ cd nucleus && cargo build --release
$ ./target/release/nucleus --help