v1.1.0 ยท Open Source ยท MIT License

STARKDB

A key-value based, B-tree implemented local database
designed for games, mobile apps & desktop applications.
Fast. Light. Simple.

B-Tree Engine ACID Compliant 0.5 ยตs Reads < 1 MB File Size 2โ€“5 MB RAM CLI + C++ API
scroll
Overview

How STARK Works

STARK works with .dat and .idx files to save data. It supports ACID properties, ensuring safe and reliable data persistence. After building STARK, users can add data via either the STARK CLI or directly through C++ code.

As mentioned above, you can use STARK via the CLI or embed it in your C++ project.


Setup

Installation

One-time setup. Takes about 5 minutes.

DOWNLOAD
# 1. Download STARK
# Click here and download the ZIP file
# Extract it to your project folder C:\my_project
# You must get a path like: C:\my_project\starkdb

# 2. Open Command Prompt as Administrator
# Press Windows Key, type "cmd", right-click, "Run as Administrator"

# 3. Go to STARK folder
cd C:\my_project\starkdb
mkdir build
cd build

# 4. Build
cmake .. -G "MinGW Makefiles" -DBUILD_SHARED=ON
mingw32-make

# 5. Install (copy to MinGW)
copy libstark.dll C:\mingw64\bin\
copy libstark.dll.a C:\mingw64\lib\
copy ..\bindings\cpp\stark.hpp C:\mingw64\include\
copy ..\core\include\stark.h C:\mingw64\include\

# DONE! One-time setup complete.
# 1. Open Terminal (Ctrl+Alt+T) and go to your project folder
cd Desktop/my_project

# 2. Download and build
git clone https://github.com/abdullahtnz/starkdb.git
cd starkdb
mkdir build
cd build
cmake .. -DBUILD_SHARED=ON
make

# 3. Install
sudo make install
sudo ldconfig

# DONE! One-time setup complete.

CLI

Using STARK in CLI

Works identically on Windows and Linux.
# Go to stark/build folder
cd C:\my_project\build
./stark_cli filename   # Creates or opens a file in the build folder

# To open/create a file in another directory:
cd C:\my_project\my_folder
stark_cli filename
General Commands
helpSee all possible commands and usage
exitSave and quit
Numeric Key Commands
addn key valueAdd a numeric key with value (value can be string or num)
getn keyGet a numeric key and its value
deln keyDelete a numeric key and its value
existsn keyCheck if a numeric key exists
String Key Commands
adds key valueAdd a string key with value (value can be string or num)
gets keyGet a string key and its value
dels keyDelete a string key and its value
exist_str keyCheck if a string key exists
Type Commands
define name { ... }Define a new user-defined type with typed fields
undefine nameDelete a type definition
desc nameInspect a type and its fields
add typename key ...Add a record of a specific type
get typename keyGet a typed record by key
Transaction Commands
beginStart the transaction process
commitEnd and save the transaction
rollbackUndo changes if the transaction fails

Walkthrough

Types in Action

Types are user-defined, flexible structures โ€” perfect for game entities like players, items, or enemies.

When defining string fields in a type, you must specify the string size. Use string(255) if memory usage isn't a concern.
# 1. Open your database
stark_cli mygame

# 2. Define a player type
stark> define player {
    name  string(32)
    hp    int
    level int
    gold  int
    class string(16)
}

# 3. Add players (key = 1 and key = 2)
stark> add player 1 name="Hero" hp=100 level=5 gold=250 class="warrior"
stark> add player 2 name="Mage" hp=80  level=7 gold=450 class="wizard"

# 4. Get player data
stark> get player 1
# Output: name="Hero" hp=100 level=5 gold=250 class="warrior"

# 5. Check for non-existent key
stark> get player 3
# Output: player:3 not found

# 6. View type definition
stark> desc player

# 7. Update player (overwrites existing record)
stark> add player 1 name="Hero" hp=85 level=6 gold=300 class="warrior"

# 8. Check database stats
stark> stats

# 9. Exit and save
stark> exit

Transactions Example

Transactions work like a surgeon โ€” begin, do the job, commit. Best used when updating values that must succeed atomically.

stark> define player { id int hp int level int }
stark> add player 1 id=123 hp=100 level=0

# Player won a fight โ€” update atomically
stark> begin
stark> add player 1 id=123 hp=45 level=1
stark> commit

C++ Integration

Using STARK in C++

Just add #include <stark.hpp> to your project. The installation step already handles everything else.

// main.cpp
#include <stark.hpp>

int main() {
    // Open database (creates "save.idx" and "save.dat")
    stark::Database db("save");

    // Save player
    db.add(1, "Hero");
    db.add(2, "100 HP");

    // Load player
    std::cout << db.get(1) << std::endl;  // Shows: Hero

    return 0;
}

Numeric Keys

db.add(1, "value");
std::string v = db.get(1);
db.remove(1);
if (db.exists(1)) {}

String Keys

db.put_str("key", "value");
std::string v = db.get_str("key");
db.remove_str("key");
if (db.exists_str("key")) {}

Typed Data

db.define_type("name", {{"field", TYPE_INT}});
db.add_typed("name", 1, "field=100");
std::string v = db.get_typed("name", 1);
auto fields = db.describe_type("name");
db.undefine_type("name");

Transactions

db.begin();
db.commit();
db.rollback();
if (db.in_transaction()) {}

Utilities

db.sync();
auto stats = db.stats();
std::string err = db.get_last_error();

Summary

These are summary of how to use STARK in C++. More languages and explanation will be added in further updates.


Benchmarks

How STARK Compares

Core Features

FeatureSTARKSQLiteRedisMongoDBLevelDB
TypeKey-ValueRelationalKey-ValueDocumentKey-Value
LanguageCCCC++C++
Setup Time5 min5 min10 min15 min5 min
Memory Usage2โ€“5 MB5โ€“10 MB5โ€“10 MB100+ MB5โ€“10 MB
File Size< 1 MB1โ€“5 MBN/A (RAM)200+ MB1โ€“5 MB
Learning Curve20 min1 hour30 min2 hours30 min
Transactionsโœ…โœ…โœ…โœ…โŒ
ACIDโœ…โœ…Partialโœ…โŒ
SQL SupportโŒโœ…โŒโŒโŒ
Network SupportโŒโŒโœ…โœ…โŒ
Multi-userโŒโœ…โœ…โœ…โŒ

Usage & Developer Experience

FeatureSTARKSQLiteRedisMongoDB
Save Player Dataโœ… 1 line5 lines SQL2 lines3 lines JSON
Load in 1 secโœ… 0.5 ยตs3 ยตs1 ยตs50 ยตs
Offline Useโœ… Yesโœ… YesโŒ NoโŒ No
Simple Syntaxโœ… add(1, "Hero")INSERT INTO โ€ฆSET key valdb.insert()
FocusOffline appsGeneral purposeCacheWeb apps

Size per 1,000 Records

DatabaseFile Size
STARK~100 KB
SQLite~150 KB
LevelDB~120 KB
MongoDB~2 MB

Speed Benchmark

OperationSTARKSQLiteRedisMongoDB
Write 1 record0.8 ยตs5 ยตs1 ยตs50 ยตs
Read 1 record0.5 ยตs3 ยตs0.8 ยตs30 ยตs
Write 1,000 records0.8 ms5 ms1 ms50 ms
Read 1,000 records0.5 ms3 ms0.8 ms30 ms

As estimated values show, STARK is faster and leaner than comparable local databases. What makes STARK stand out is its strict focus on core functions โ€” it's designed for specific use cases, and that's what makes it excel at them.


Decision Guide

Should You Use STARK?

๐Ÿ‘ Choose STARK whenโ€ฆ
โšก
You need simplicity 1 line to save, 1 line to load
๐Ÿชถ
You need a tiny footprint 2 MB memory, < 1 MB file size
๐Ÿš€
You need raw speed 0.5 ยตs reads โ€” effectively instant
๐ŸŽฎ
You're making a game Built specifically for game developers
๐Ÿ†“
You want it free Open source, MIT license
๐Ÿ‘Ž Skip STARK whenโ€ฆ
๐Ÿ—ƒ๏ธ
You need SQL queries Use SQLite instead
๐ŸŒ
You need network access Use Redis or MongoDB instead
๐Ÿ‘ฅ
You have multiple users Use PostgreSQL instead
๐Ÿ“Š
You're doing big data analytics Use MongoDB instead
๐Ÿ“ฑ
You need complex queries on mobile Use SQLite instead

Contact

Questions or Feedback?

For questions, advice, or to report an issue, feel completely free to reach out.

โœ‰ [email protected]