What is STARKDB?
STARKDB is a lightweight embedded key-value database written in C. It stores data using a B-tree index across two files (.idx and .dat), delivering sub-microsecond reads with a footprint of only 2–5 MB of RAM. Built for offline games, mobile and desktop apps — where speed and simplicity matter most.
Why STARKDB?
B-tree indexed lookups are effectively instant. Faster than SQLite, Redis, and MongoDB for single-record operations in local environments.
Ultra-compact storage. A database with 1,000 records takes only ~100 KB. Perfect for resource-constrained environments.
O(log n) lookups, inserts, and deletes. Keys stay sorted. Range queries are efficient. No hash collisions on numeric keys.
Atomic, Consistent, Isolated, Durable. Transactions with begin, commit, and rollback. Crash-safe append-only writes.
Define typed records with int and string(N) fields. Store game entities, configs, and inventory — all in one database.
Use uint32 numeric keys for IDs, string keys for settings (djb2 hashed), or typed records for structured game data.
One Line. All It Takes.
# Open a database
stark_cli mygame
# Save data
stark> addn 1 "Hero"
stark> addn 2 "100 HP"
# Read it back
stark> getn 1
# Output: Hero
# Type system
stark> define player { name string(32) hp int level int }
stark> add player 1 name="Aldric" hp=120 level=8
stark> get player 1
// Include and open
#include <stark.hpp>
stark::Database db("save");
// Save player data
db.add(1, "Hero");
db.add(2, "100 HP");
// Load it instantly
std::cout << db.get(1);
// Typed data
db.define_type("player", {
Field("name", TYPE_STRING, 32),
Field("hp", TYPE_INT)
});
db.add_typed("player", 1,
"name=Hero hp=100");
By The Numbers
Should You Use STARKDB?
STARKDB excels at what it's designed for: simple, fast, local key-value storage. See the full documentation to explore all commands and APIs, or try the Lab to experiment interactively.
Try STARKDB in Your Browser
The interactive lab lets you run STARKDB commands, visualize B-tree operations, explore djb2 hashing, and solve practice challenges — all without installing anything.
Questions or Feedback?
For questions, advice, or to report an issue, feel completely free to reach out.
✉ [email protected]