What is Nucleus?

View as Markdown

Nucleus is a multi-model database engine written in Rust. It provides 14 data models through a single server, accessed via the standard PostgreSQL wire protocol. Any PostgreSQL client, driver, or ORM works out of the box.

Why Nucleus?

Most applications need more than one type of database. A typical stack might include PostgreSQL for relational data, Redis for caching, Elasticsearch for search, a vector database for AI, and InfluxDB for metrics. Nucleus combines all of these into one.

  • One connection string — No more managing 5 database connections
  • One query language — SQL extended with model-specific functions
  • One operational surface — One backup, one monitor, one deploy
  • PostgreSQL compatible — Use psql, pgx, asyncpg, or any PostgreSQL driver

Data Models

| Model | Use Case | Access Pattern | |-------|----------|---------------| | SQL | Relational data, joins, transactions | Standard SQL | | Key-Value | Caching, sessions, counters | KV_SET, KV_GET, TTL | | Vector | Similarity search, RAG, embeddings | VECTOR_DISTANCE, HNSW/IVFFlat | | Document | Flexible schemas, nested data | JSONB, ->, ->>, GIN | | Graph | Relationships, networks, paths | Cypher queries | | Full-Text Search | Search, autocomplete, facets | FTS_SEARCH, BM25 | | Time Series | Metrics, IoT, logs | Gorilla compression, continuous aggs | | Columnar | Analytics, aggregations | Vectorized execution, LZ4/Zstd | | Blob | Files, images, media | Chunked, content-addressed, dedup | | Datalog | Logic programming, rules | Semi-naive evaluation | | Streams | Event sourcing, queues | Append-only, consumer groups | | Geospatial | Maps, location queries | R-tree, point-in-radius | | CDC | Change tracking | Change Data Capture | | Pub/Sub | Real-time notifications | LISTEN/NOTIFY |

Connecting

Nucleus speaks the PostgreSQL wire protocol. Connect with any PostgreSQL client:

# psql
psql -h localhost -p 5432 -U neutron

# Connection string
postgresql://neutron:password@localhost:5432/mydb

From any language framework:

// TypeScript (@neutron-build/nucleus)
import { createClient, withSQL } from "@neutron-build/nucleus";
const db = await createClient({ url: process.env.DATABASE_URL! })
  .use(withSQL)
  .connect();
const users = await db.sql.query("SELECT * FROM users");
// Rust (sqlx, diesel, or raw pgx)
let rows = sqlx::query("SELECT * FROM users")
    .fetch_all(&pool).await?;
// Go (pgx/v5)
rows, err := pool.Query(ctx, "SELECT * FROM users")
# Python (asyncpg)
rows = await conn.fetch("SELECT * FROM users")

Architecture

Nucleus is a single statically-linked binary. No JVM, no runtime dependencies.

  • Storage: Pluggable engines (in-memory, disk, buffered, columnar, LSM)
  • MVCC: Snapshot isolation with row-level versioning
  • WAL: Write-ahead log for crash recovery
  • Indexes: B-tree, hash, GIN, R-tree, HNSW, IVFFlat
  • Compression: LZ4, Zstd, Gorilla (time series)

License

Nucleus uses the Business Source License 1.1 (BSL). Its Additional Use Grant permits production use unless Nucleus is offered to third parties on a hosted or embedded basis as a database service or database engine. Uses outside that grant require a commercial license. Each version converts to MIT on its applicable change date; the current license lists 2046-01-01 or the fourth anniversary of that version's first public distribution, whichever comes first.