Database engine · built from scratch
ArcaDB (arca is Latin for a strongbox, the chest where valuables are kept safe) is a relational database I wrote from nothing: a SQL parser, a query planner that chooses between index lookups, range scans, hash joins and nested loops, B-tree storage with real splits and merges, transactions, and a write-ahead log that survives crashes. It runs entirely in your browser. Every query shows you exactly what it did.
Run a SELECT, UPDATE or DELETE to see the plan the optimizer chose and how many rows and pages each step touched. Prefix a query with EXPLAIN to see the plan without running it.
All memory is gone.
Under the hood
Each table is a B-tree keyed on its primary key. Full nodes split and push their middle key up. Underfull nodes borrow from a sibling or merge with it, so the tree always stays balanced and every lookup costs O(log n).
CREATE INDEX builds another B-tree keyed on (value, primary key), so duplicate values are fine. Lookups use the index, then fetch each row by key: the same “bookmark lookup” real databases do.
WHERE conditions are split on AND and pushed down to the table they mention. Equality on an indexed column beats a range, which beats a full scan. Joins on an indexed column use an index nested-loop join; other equi-joins get a hash join.
BEGIN, COMMIT, ROLLBACK. Every change is logged with a before-image, so rollback replays the log backwards. A failed statement undoes its own partial work, so a bad multi-row INSERT leaves nothing behind.
Changes reach the log before they count as committed. On startup the engine loads the last checkpoint and replays only committed transactions. Hit “Simulate crash” in the middle of a transaction and watch the uncommitted work vanish.
The B-tree is fuzzed with 16,000 random inserts and deletes against a reference model, and its invariants are checked throughout: key order, node fill, equal leaf depth. SQL, joins, aggregates, transactions and recovery all have tests.