Skip to main content

NEDB — a versioned, self-compressing, time-traveling embedded database (replay-protected, idempotent, relational, searchable). Native Rust core with a pure-Python fallback.

Project description

NEDB

A versioned, self-compressing, time-traveling embedded database.

Replay-protected · idempotent · relational · filterable · sortable · searchable · provable. One Rust core → ships to PyPI and npm from a single source.


Why NEDB

Redis is fast because it's in-memory and simple — but relations are hand-rolled, history is gone the moment you overwrite, and every call pays a network hop. NEDB keeps the speed and adds the things real systems actually need:

  • Faster-than-Redis latency where it's honest to claim it — NEDB runs embedded, in-process, so point reads pay no socket hop. The networked server (nedbd, RESP-compatible) competes on the Rust core's merits.
  • Replay protection + idempotency in the core, not the app. Every write carries a strictly-monotonic per-client nonce and an optional idempotency key. Retries are no-ops; stale/out-of-order ops are rejected. This is built into one hash-chained, append-only log.
  • Time-travel. Read the database exactly as it existed at any past sequence — AS OF seq. Debugging, audit, MVCC snapshots, and deterministic replay all fall out of the same log.
  • First-class relations. Adjacency-list graph edges with O(1) traversal — and the graph time-travels too.
  • Filter / sort / search. Equality, ordered, and full-text inverted indexes, maintained incrementally.
  • git-style files with maximum compression. Content-defined chunking + content-addressed dedup + temperature tiers (fast warm codec, max-ratio cold archival). Every file version has a Merkle root you can anchor on-chain.

The keystone: one nonce-enforced append-only log is the substrate for idempotency, replay protection, crash recovery, MVCC, and time-travel — simultaneously.


Quickstart (Python reference engine — runs today, zero build)

git clone https://github.com/Eth-Interchained/nedb && cd nedb
pip install -e .                 # pure-Python reference; no toolchain needed
python3 examples/demo.py         # see every feature
python3 tests/test_nedb.py       # 10/10 invariants
from nedb import NEDB

db = NEDB()
db.create_index("users", "status", "eq")
db.create_index("users", "age", "ordered")
db.create_index("users", "bio", "search")

db.put("users", "alice", {"name": "Alice", "age": 31, "status": "active",
                          "city": "Austin", "bio": "rust systems hacker"})

# Idempotent, replay-protected write (safe to retry forever):
db.put("orders", "o1", {"total": 42}, client="checkout", nonce=7, idem="charge-o1")

# NQL — filter + sort
db.query('FROM users WHERE age >= 25 AND status = "active" ORDER BY age DESC')

# Full-text search
db.query('FROM users SEARCH "rust"')

# Relations + graph traversal
db.link("users:alice", "follows", "users:bob")
db.q("users").where("_id", "=", "alice").traverse("follows").run()

# Time-travel
s = db.seq
db.put("users", "alice", {"name": "Alice", "city": "Lisbon", "age": 31, "status": "active"})
db.get("users", "alice", as_of=s)["city"]      # -> "Austin"

# git-style files with Cascade compression + provable history
v1 = db.put_file("notes.txt", open("notes.txt","rb").read())
db.file_root("notes.txt", v1)                  # Merkle root — anchorable on ITC

NQL — the NEDB Query Language

One small grammar; the Rust parser is the single source of truth so Python and Node share identical semantics. A fluent builder compiles to the same plan.

FROM <collection>
  [ AS OF <seq> ]
  [ WHERE <field> <op> <value> (AND ...)* ]      op ∈ = != < <= > >=
  [ SEARCH "<text>" ]
  [ ORDER BY <field> [ASC|DESC] ]
  [ TRAVERSE <relation> ]
  [ LIMIT <n> ]

What's measured (reference engine, pure Python, 2 vCPU)

Operation Result
GET (embedded, in-process) ~1.2M ops/s (~800 ns/op)
SET (logged + indexed) ~77K ops/s
Indexed query latency ~75 µs
File compression — warm (zlib stand-in) 39.9×
File compression — cold (LZMA archival) 88.9×
Cross-version dedup 20 of 22 chunks reused on edit

The reference engine proves the architecture. The Rust core (rust/) is the speed target — see bench/bench_redis.py for the embedded-vs-Redis harness.


Architecture

            ┌──────────────────────────────────────────────┐
  put/del → │  OpLog  (append-only · BLAKE3 hash chain ·    │ ← single source of truth
  link      │          per-client nonce · idempotency keys) │
            └───────────────┬──────────────────────────────┘
            deterministic fold │ (state = pure function of the log)
        ┌──────────────┬───────┴────────┬───────────────────┐
        ▼              ▼                ▼                   ▼
   MVCC store     Relations         Indexes            BlobStore (Cascade)
   (time-travel)  (graph, AS OF)    eq/ordered/search  CDC+dedup+tiers, Merkle roots

One Rust core (nedb-core) → PyO3 wheels (PyPI) and napi-rs binaries (npm), plus a future nedbd server (RESP-compatible) and a WASM build for browser/edge.

Full design: docs/SPEC.md.


Repo layout

nedb/            pure-Python reference engine (this is what `pip install` ships today)
rust/            production core — nedb-core + nedb-py (PyO3) + nedb-node (napi-rs)
examples/demo.py end-to-end walkthrough
tests/           invariant tests
bench/           embedded micro-bench + Redis head-to-head harness
docs/SPEC.md     architecture specification
.github/         release CI → PyPI + npm on tag

Roadmap

  • Reference engine: log, MVCC, relations, indexes, NQL, Cascade, Merkle
  • Rust core parity + criterion benches + cargo test
  • PyO3 wheels + napi-rs binaries published on tag
  • nedbd server: RESP-compatible + native protocol
  • Similarity-picked deltas + schema-aware columnar transforms
  • On-chain (ITC) root anchoring; WASM build

License

Apache-2.0. Part of the Interchained ecosystem.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nedb_engine-0.1.4.tar.gz (23.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nedb_engine-0.1.4-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

nedb_engine-0.1.4-cp38-abi3-win_amd64.whl (191.9 kB view details)

Uploaded CPython 3.8+Windows x86-64

nedb_engine-0.1.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (318.4 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

nedb_engine-0.1.4-cp38-abi3-macosx_11_0_arm64.whl (276.5 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file nedb_engine-0.1.4.tar.gz.

File metadata

  • Download URL: nedb_engine-0.1.4.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for nedb_engine-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d1bfbdc0b83aebdd1ba94626159a7203bc2a83970c44d7e464ce6a37637178dd
MD5 575f902b33d150b18dc611f4bf50cb11
BLAKE2b-256 a2864f856f5f1ca059af84dd3eb605265c005194b1a43e0e26c9fc325b2525dd

See more details on using hashes here.

File details

Details for the file nedb_engine-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: nedb_engine-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for nedb_engine-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1bf105e9315c7c3d4bfb2e25041fa8270a5b09e1018ce1dd20457d4586865aa2
MD5 9ea01b59170b1aa05eff0a99e68fbf47
BLAKE2b-256 e2a9d63d687da559577168a61fcfd072b996a149567672402fdb5dce13328e5c

See more details on using hashes here.

File details

Details for the file nedb_engine-0.1.4-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: nedb_engine-0.1.4-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 191.9 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for nedb_engine-0.1.4-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5f37b2b539f1b10f2bb208609378306fb02eacc963f389650c109ae3e70cd1f9
MD5 143c1063b9be1ffb9c98aca31db837bc
BLAKE2b-256 025a7cc0a2e08f1a6771cbd2d4d6c272257c40a6d704484424ae1c3fbfe8a5b9

See more details on using hashes here.

File details

Details for the file nedb_engine-0.1.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nedb_engine-0.1.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84e90fa840b7371a54d1f94aa05bf85f2a4b000f2e4f1b12daf323d8ba84f057
MD5 d5cfa7b7ec449ea9b475e8dfd1c6fdbb
BLAKE2b-256 d39e5ea9196cbfe733cddfe97ab4d2ffb2cf83053092680c124d321f92f6e2a3

See more details on using hashes here.

File details

Details for the file nedb_engine-0.1.4-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nedb_engine-0.1.4-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c3c8712fbfc0b987149586d1f55e3ca12d9fbe109f76704d89166280d1f5575b
MD5 74781b4d91967b9e5100f25a6da138a6
BLAKE2b-256 ec34028ad1579c0cafa6c3c3c504d15403973ed7e9e95b61fcf2a4699b380020

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page