Skip to content
DatabasePython + TypeScriptMIT licensedHigh — Core Service

eDB — Embedded Multi-Model Database

SQL · Document · Key-Value · AES-256 Encrypted

A multi-model embedded database for EoS devices. Supports SQL, document (JSON), and key-value stores in a single engine — with AES-256 at-rest encryption rooted in the eBoot chain of trust, indexed lookups across all three models, and a < 64 KB footprint.

For a shorter introduction to eDB, see the eDB overview. This page is the engineering detail.

3
Query Models (SQL, Doc, KV)
32 GB
Tested Database Size
AES-256
At-Rest Encryption
< 64 KB
Engine Footprint

How It Works

Step-by-step flow — from initialization to output.

1

Open a Database

eDB databases are single-file stores on flash or SD card. Open with edb_open(), passing the encryption key derived from the eBoot chain of trust. eDB automatically creates the file if it doesn't exist.

// Open encrypted eDB database
#include <edb/edb.h>

// Key derived from eBoot TPM measurement
uint8_t key[32];
eboot_derive_key(key, "edb_sensor_log");

edb_t db = edb_open("/flash/sensor.edb", key);
2

Create Tables (SQL Model)

Use the SQL interface for structured, relational data. eDB supports a subset of SQLite-compatible SQL: CREATE TABLE, INSERT, SELECT, UPDATE, DELETE, and JOIN.

edb_exec(db,
    "CREATE TABLE IF NOT EXISTS readings ("
    "  id       INTEGER PRIMARY KEY AUTOINCREMENT,"
    "  ts       INTEGER NOT NULL,"
    "  device   TEXT    NOT NULL,"
    "  temp_c   REAL,"
    "  hum_pct  REAL"
    ");");
3

Insert and Query Data

Insert sensor readings and query them with SQL. eDB uses a B-tree index for O(log n) lookups and supports prepared statements to avoid SQL injection.

// Insert a reading
edb_stmt_t ins = edb_prepare(db,
    "INSERT INTO readings (ts, device, temp_c, hum_pct) "
    "VALUES (?, ?, ?, ?)");
edb_bind_int(ins, 1, eos_time_ms());
edb_bind_text(ins, 2, "node-42");
edb_bind_real(ins, 3, 23.5f);
edb_bind_real(ins, 4, 60.2f);
edb_step(ins);

// Query last 100 readings
edb_stmt_t q = edb_prepare(db,
    "SELECT ts, temp_c FROM readings ORDER BY ts DESC LIMIT 100");
while (edb_step(q) == EDB_ROW) {
    printf("ts=%lld temp=%.1f\n",
           edb_column_int64(q, 0),
           edb_column_real(q, 1));
}
4

Use Document Store for Flexible Data

For schema-less data (device configs, AI model metadata, user preferences), use the document store. Documents are JSON objects stored in named collections.

// Store device config as JSON document
edb_doc_t cfg = edb_doc_new();
edb_doc_set_str(cfg, "firmware_version", "1.2.0");
edb_doc_set_int(cfg, "sample_rate_hz", 1000);
edb_doc_set_bool(cfg, "encryption_enabled", true);
edb_collection_insert(db, "device_config", cfg);

// Retrieve it
edb_doc_t loaded = edb_collection_find_one(db, "device_config",
                                             "firmware_version", "1.2.0");

Usage Examples

Real-world scenarios showing eDB in action.

Sensor Data Logger

An industrial sensor node logging 1,000 readings/second to eDB on internal flash with AES-256 encryption.

// High-throughput sensor logger
#include <edb/edb.h>

void logger_task(void *arg) {
    uint8_t key[32];
    eboot_derive_key(key, "sensor_log");
    edb_t db = edb_open("/flash/log.edb", key);

    edb_exec(db, "CREATE TABLE IF NOT EXISTS log "
                 "(ts INTEGER, ch INTEGER, val REAL)");

    edb_stmt_t ins = edb_prepare(db,
        "INSERT INTO log VALUES (?, ?, ?)");

    for (;;) {
        // Batch insert 100 readings per transaction
        edb_begin(db);
        for (int i = 0; i < 100; i++) {
            sensor_reading_t r = sensor_read_next();
            edb_bind_int(ins, 1, r.timestamp);
            edb_bind_int(ins, 2, r.channel);
            edb_bind_real(ins, 3, r.value);
            edb_step(ins);
            edb_reset(ins);
        }
        edb_commit(db);
        eos_task_delay_ms(100);
    }
}

Features

The shape of eDB at a glance.

SQL Interface

SQLite-compatible SQL: CREATE, INSERT, SELECT, UPDATE, DELETE, JOIN. Prepared statements prevent injection.

Document Store

Schema-less JSON document collections for flexible, evolving data structures.

Key-Value Store

O(1) KV store for configuration, counters, and flags. Atomic compare-and-swap.

AES-256 Encryption

At-rest encryption with keys derived from the eBoot chain of trust. Data is device-bound.

Indexed Queries

B-tree index for SQL, hash index for KV, and inverted index for document full-text search — no full-table scans for typical embedded workloads.

ACID Transactions

Full ACID guarantees with write-ahead logging. Safe across power failures.

< 64 KB Footprint

The full SQL + document + KV engine fits in 64 KB of flash.

Wear Leveling

Built-in flash wear leveling extends storage lifetime on NOR and NAND flash.

Role in the EoS Ecosystem

Why eDB matters — and what breaks without it. See how the pieces fit together in the EmbeddedOS ecosystem overview.

eDB is the persistent storage layer of the EoS ecosystem. Every component that needs to store data beyond a reboot — sensor logs, AI model metadata, user configurations, device state, health records — uses eDB. Its AES-256 encryption rooted in the eBoot chain of trust means that data is only readable on the device that created it, making eDB the right choice for medical, financial, and defense applications. The multi-model interface (SQL + document + KV) means developers don't need to choose between structured and flexible storage — eDB handles both.

Depends On

EoS Kernel — eDB runs as an EoS service task with flash HAL access
eBoot — derives the AES-256 encryption key from the eBoot TPM measurement
EIPC — inter-process database access uses EIPC for capability-secured queries

Enables / Powers

eAI — stores model bundles, training data, and inference logs
eOffice — documents, spreadsheets, and presentations are stored in eDB
eHealth365 — health records, biometric history, and device configs
eFlow — workflow state and execution history
All EoS applications — any app that needs persistent storage uses eDB

Open source on GitHub

MIT licensed and developed in the open. Issues, discussions, and pull requests welcome.

⌥ embeddedos-org/edb
Embedded Multi-Model Database
Python + TypeScriptMIT
Open the embeddedos-org/edb repository on GitHub ↗

Every EmbeddedOS repository, with install commands, is listed on the downloads page.

In the EoS stack

eDB is highlighted in the layer below.

App layer
UI / browser layer
Data layer
AI runtime
Neural interface
IPC fabric
EoS kernel + HAL
eos-platform profile
eBootloader
Build / IDE / Sim

Technical Specifications

Query ModelsSQL (SQLite-compatible), Document (JSON), Key-Value
EncryptionAES-256-GCM at rest; key derived from eBoot TPM measurement
Index StructureB-tree for SQL; hash index for KV; inverted index for document full-text search
Transaction ModelACID with write-ahead logging (WAL)
Query PathIndexed (B-tree for SQL, hash for KV, inverted for document search); actual latency depends on storage medium and workload
Engine Footprint< 64 KB flash (SQL + document + KV)
Max Database SizeLimited by storage medium; tested to 32 GB
Supported StorageNOR flash, NAND flash, eMMC, SD card, RAM (volatile)
LicenseMIT