CoCreateDB is a client-server database engine for building distributed databases. The same asynchronous CRUD engine runs locally in a browser client or a Node server. await createDB(server, options) and await createDB.init(server, options) expose asynchronous send(request) and config. A standalone instance requires no server. Primary server instances execute local CRUD; DB composes a worker Server's send() with the db.forward request and registers the matching primary handler. A custom forward(request) can replace the worker transport. Explicit primary status takes precedence. Cluster retains ownership of IPC transport; DB owns its primary/worker request composition.
Internally one UUID-keyed leaf Map, one key/type tree catalog and a root manager maintain live data. Index entries reference leaves directly. Offloaded terminal branches are stored separately from leaves; the root/parent branch catalog is not yet restored on restart. Configuration defines allowed hierarchy and structural identities; it is not a data snapshot.
The default mode is adaptive; the default acknowledgement is memory. Adaptive keeps a Hot working set in memory and can use Warm local disk for write-through, recovery and branch offload. The default requested memory budget is 25% of total system memory, capped by memory available at startup. It is a soft DB-residency target, not a hard process-memory cap. Disk-first remains an explicit mitigation mode and is also used temporarily by adaptive handling at high pressure. Disk-cache starts with a cleared DB-managed local base.
The package has one src/index.js entry and one composition lifecycle for both environments. It wires Tree, CRUD, query planning, optional Persistence and optional Disk. Index composes Disk by assigning the initialized resource directly to tree.disk. Tree maps config, branch and leaf operations to provider requests internally. Tree and CRUD do not import platform APIs. Without an attached Disk resource, the DB operates in memory; pruned branch entries can be rebuilt from resident leaf index entries. Disk initialization and directory selection belong to the Disk provider. OPFS is scoped to the browser origin, requires a secure context and is subject to browser quota management.
Successful object.create, object.update, and object.delete requests in adaptive mode acknowledge after their in-memory leaf-map mutation. Create assigns or accepts a UUID and stores the leaf; update mutates the leaf; delete removes it from the resident map and records a pending local deletion. Supplied-UUID create, cold-leaf hydration, and query matching can require work before the mutation itself is applied.
After acknowledgement, Warm local work proceeds in order: persist changed or deleted leaves, reconcile the derived in-memory indexes, then persist changed index branches and config. flushIndex() waits for index reconciliation; flushDisk() waits for local disk work. Disk-first uses the same memory acknowledgement and local flush path, then releases processed leaves and resident index branches while retaining their disk files. Memory acknowledgement means the mutation was accepted in this DB's memory; it does not certify that this server's disk write has completed. Client copies and peer delivery may add system-level redundancy, but are owned by the surrounding distributed application. Neither acknowledgement is a multi-object transaction. External Persistence is a separately attached resource; db.persist() delegates to that resource if it exposes persist(). It is separate from the local durability boundary. The separate Persistence Tree and Cold archives remain outside the implemented engine.
CoCreateDB supplies the local database at either end of a client-server application. CoCreate CRUD routes authorized requests to an instance, then invokes a configurable workflow with the request and response. Workflow/AST can acquire missing data and schedule or await persistence orchestration. Socket, IPC and Mesh own transport, awareness, recipient selection and peer communication; DB composes primary/worker DB requests over the Server's generic send interface. These surrounding layers use database instances to form a distributed database; the DB package itself does not open connections, discover peers or replicate changes automatically. Persistence accepts an adapter supplied by its host; Workflow integration is external to the DB package.
Index owns telemetry-based memory pressure policy and calls tree.prune() with the selected strategy and limit. Tree prunes eligible branch contents only, keeps leaf objects resident, and preserves query paths. With local Disk attached, branches are written before release; without Disk, Tree rebuilds pruned entries from resident leaves when needed. Local success does not establish global completeness or external durability. Pruning mitigates DB-managed memory use; it cannot protect total server RSS from unbounded requests or server queues. Process-level OOM protection belongs to server telemetry and network traffic management, including admission control, draining and client backoff. See CRUD, indexes, persistence and awareness.