Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions docs/ai/on-device.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,33 @@ NodeDB-Lite compiles to WebAssembly. Run semantic search in the browser with no

```javascript
// Load NodeDB-Lite WASM module
import { NodeDB } from "nodedb-lite-wasm";
import init, { NodeDbLiteWasm } from "nodedb-lite-wasm";

const db = await NodeDB.open("my-search-app");
await init();

const db = await NodeDbLiteWasm.openInMemory();

// Create collection and index
await db.exec(`CREATE COLLECTION docs TYPE document`);
await db.exec(
await db.executeSql(`CREATE COLLECTION docs TYPE document`);
await db.executeSql(
`CREATE VECTOR INDEX idx_docs_embedding ON docs METRIC cosine DIM 384`,
);

// Load a static snapshot (pre-built dataset)
await db.loadSnapshot("/data/docs-snapshot.ndb");
// Index a vector
await db.vectorInsert("docs", "doc-1", embedding);

// Search in the browser — no backend needed
const results = await db.query(
`SEARCH docs USING VECTOR(embedding, ARRAY[${queryVector.join(",")}], 10)`,
);
const results = await db.vectorSearch("docs", queryVector, 10);
```


**Use cases:**

- Documentation search widgets (embed in any website)
- Demo applications (show vector search without a server)
- Privacy-sensitive search (data never leaves the browser)
- Offline-capable progressive web apps

**Static snapshots:** Pre-build a dataset on your server, export as a snapshot file, host on a CDN. The WASM module loads the snapshot at startup — no live database connection needed.

## Privacy Model

All data stays on the device by default. Sync is opt-in and explicit.
Expand Down
46 changes: 46 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# CLI

The server binary is `nodedb`. There is no separate client binary: query clients speak pgwire,
HTTP, the native protocol, or RESP — see [Protocols](protocols.md).

```
nodedb — NodeDB server + operator tooling

USAGE:
nodedb [CONFIG_FILE] Run the server (default mode)
nodedb --version Print version and exit
nodedb regen-certs --data-dir D --node-id N
Reissue this node's cert under the existing CA
nodedb rotate-ca --stage --data-dir D Generate a new CA, write to ca.d/, emit staged bundle
nodedb rotate-ca --finalize --remove FP Ask the running node to remove CA with fingerprint FP
nodedb join-token --create --data-dir D --for-node N [--ttl 10m]
Emit a one-time HMAC token for a joining node
nodedb healthcheck [--port N] Probe local HTTP /health (exit 0=healthy, 1=unhealthy)
nodedb help Print this message
```

Running with no argument reads the default config path; `nodedb /etc/nodedb.toml` reads that
file instead. Every flag above is parsed by hand — the binary deliberately does not pull in a
CLI framework.

## Reserved verbs

These are parsed but not implemented; each exits with the usage message:

```
nodedb migrate Schema/data migration
nodedb backup Online backup
nodedb restore Restore from backup
nodedb verify Consistency check
nodedb repair Repair corrupted data
nodedb dump Logical export
nodedb fsck Filesystem consistency check
```

Online backup and restore are driven from SQL instead today (`BACKUP TENANT`, `RESTORE TENANT`).

## Health probe

`nodedb healthcheck` exits `0` when the local HTTP endpoint answers healthy and `1` otherwise,
which is the intended Kubernetes liveness/readiness probe. The endpoint itself is the HTTP
`/healthz` family described in [Architecture](architecture.md).
5 changes: 4 additions & 1 deletion docs/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,11 @@ Uses:
- `Strong` — returns `STALE_READ_NOT_LEADER` with source endpoint hint
- `Eventual` — served immediately

The level is a session setting, not a query clause:

```sql
SELECT * FROM orders CONSISTENCY='bounded_staleness'; -- served from mirror
SET default_read_consistency = 'bounded_staleness:5s'; -- served from the mirror
SELECT * FROM orders;
```

### Bootstrap and Lag
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ tar -xzf nodedb.tar.gz
# Optional: install system-wide
sudo mv nodedb /usr/local/bin/

# Run with all defaults (data goes to ~/.nodedb/data)
# Run with all defaults (Linux data dir: ~/.local/share/nodedb)
nodedb
```

Expand Down Expand Up @@ -257,7 +257,7 @@ port named — the server never comes up missing a protocol.
| `ports.sync` | `NODEDB_PORT_SYNC` | `9090` |
| `ports.resp` | `NODEDB_PORT_RESP` | disabled |
| `ports.ilp` | `NODEDB_PORT_ILP` | disabled |
| `data_dir` | `NODEDB_DATA_DIR` | `~/.nodedb/data` (binary), `/var/lib/nodedb` (Docker) |
| `data_dir` | `NODEDB_DATA_DIR` | `$XDG_DATA_HOME/nodedb` or `~/.local/share/nodedb` (Linux), `~/Library/Application Support/nodedb` (macOS), `%LOCALAPPDATA%\nodedb\data` (Windows); `/var/lib/nodedb` (Docker) |
| `memory_limit` | `NODEDB_MEMORY_LIMIT` | `1 GiB` |
| `data_plane_cores` | `NODEDB_DATA_PLANE_CORES` | CPUs - 1 |
| `max_connections` | `NODEDB_MAX_CONNECTIONS` | `4096` |
Expand Down
40 changes: 40 additions & 0 deletions docs/lite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# NodeDB-Lite

NodeDB-Lite is the embedded build of NodeDB. It runs the same query surface and storage engines
inside your process instead of as a server, and it lives in its own repository —
[NodeDB-Lab/nodedb-lite](https://github.com/NodeDB-Lab/nodedb-lite) — because it ships on a
different cadence and targets platforms the server does not: mobile, desktop, and WASM.

## What is shared

Lite consumes the same crates the server compiles: `nodedb-array`, `nodedb-columnar`,
`nodedb-crdt`, `nodedb-fts`, `nodedb-graph`, `nodedb-spatial`, `nodedb-strict`, `nodedb-vector`,
plus the cross-cutting `nodedb-types`, `nodedb-physical`, `nodedb-mem`, `nodedb-query` and
`nodedb-codec`. An engine fix lands in both builds.

The engines without a shared crate — document, KV, timeseries, sparse vectors, HTAP — are
implemented once per repository. Their behaviour is not compared by a shared test suite today;
treat cross-build parity there as unverified.

## Sync

Lite syncs to an Origin cluster over the Sync protocol (WebSocket), so an embedded client writes
locally and replicates in the background. The protocol itself is described in
[Protocols](protocols.md); the offline patterns are in
[Offline sync patterns](offline-sync-patterns.md).

Sync coverage differs by engine: array has a dedicated subtree, the columnar family (columnar,
timeseries, spatial), vector and FTS have dedicated outbound paths, document/KV/CRDT/strict use
the generic delta path, and graph plus sparse vectors have no sync path yet.

## WASM

Lite compiles to WebAssembly for browsers and Node.js under the `nodedb-lite-wasm` crate — see
[WASM Build and Deployment](wasm.md). Lite-WASM is a client only: it never acts as a Raft member
or a vShard host.

## Where to go next

- [Getting Started](getting-started.md) — the server path
- [WASM Build and Deployment](wasm.md) — building and running Lite in a browser
- [Protocols](protocols.md) — the Sync protocol Lite speaks
6 changes: 3 additions & 3 deletions docs/query-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ AS OF VALID TIME 1700000000000;

Time values are milliseconds since Unix epoch. For current time, use `extract(epoch from now()) * 1000` or `(SELECT extract(epoch from now() at time zone 'utc') * 1000)`.

See [Bitemporal Queries](../bitemporal.md) for detailed use cases.
See [Bitemporal Queries](bitemporal.md) for detailed use cases.

## Transactions

Expand Down Expand Up @@ -1299,7 +1299,7 @@ SHOW USERS;
- [Getting Started](getting-started.md) — First queries walkthrough
- [Architecture](architecture.md) — How the three-plane execution model works
- Engine guides: [Vectors](vectors.md) | [Graph](graph.md) | [Documents](documents.md) | [KV](kv.md) | [Timeseries](timeseries.md) | [Spatial](spatial.md) | [Full-Text](full-text-search.md) | [Array](array.md)
- [Bitemporal Queries](../bitemporal.md) — System time and valid time semantics
- [WASM](../wasm.md) — Browser and Node.js deployment
- [Bitemporal Queries](bitemporal.md) — System time and valid time semantics
- [WASM](wasm.md) — Browser and Node.js deployment

[Back to docs](README.md)
2 changes: 1 addition & 1 deletion docs/security/encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ or be stored in shared object storage without additional encryption.

## Encryption in Transit

See [protocols.md — TLS](protocols.md#tls) for wire encryption
See [protocols.md — TLS](../protocols.md#tls) for wire encryption
configuration. All five listeners support TLS. Plaintext is the default
and is appropriate only for local development.

Expand Down
6 changes: 4 additions & 2 deletions docs/wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

NodeDB-Lite compiles to WebAssembly and exposes the same `NodeDb` trait you use in native Lite. To talk to an Origin cluster from the browser, use Lite-WASM locally and replicate via CRDT sync over WebSocket — never run Origin in the browser.

**Status: Experimental.** Lite-WASM support is feature-complete for all eight engines. Testing and CI integration are ongoing; treat the build as preview-quality. Report issues via GitHub.
**Status: Experimental.** All eight engines are implemented for the WASM build, but treat it
as preview-quality: CI integration is ongoing, and the array engine's first write fails until the
commit-clock fix lands in the storage layer. Report issues via GitHub.

## Building for WASM

Expand Down Expand Up @@ -191,7 +193,7 @@ See [NodeDB-Lite](https://github.com/NodeDB-Lab/nodedb-lite) for full CRDT sync
## Limitations and Known Issues

- **Lite only — no Origin in WASM.** The distributed Origin server is not a WASM target. Browser/Node clients run Lite-WASM locally and sync to a separately-deployed Origin cluster over WebSocket
- **No file persistence** — WASM runs in-memory only. For persistence, use `localStorage` or IndexedDB via a wrapper
- **Persistence needs the OPFS worker** — `openPersistent*` keeps data in the Origin Private File System through `run_opfs_worker`. The default constructors (`open`, `openInMemory`) are in-memory only
- **Single-threaded** — no thread-per-core, no parallel execution; everything runs on the JS/WASM main thread
- **No io_uring, no native sockets** — storage and network I/O go through JS host APIs (`fetch`, IndexedDB, WebSocket); there is no NVMe path
- **No cluster role** — Lite-WASM is a client/edge node only. It cannot act as a Raft member or vShard host
Expand Down
4 changes: 2 additions & 2 deletions nodedb/src/control/server/http/routes/promql/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1

//! Prometheus-compatible PromQL HTTP API at `/obsv/api/v1/*`.
//! Prometheus-compatible PromQL HTTP API at `/v1/obsv/api/v1/*`.
//!
//! Grafana data source URL: `http://nodedb:6480/obsv/api`
//! Grafana data source URL: `http://nodedb:6480/v1/obsv/api`

pub mod buildinfo;
pub mod handlers;
Expand Down
Loading