A key-value based, B-tree implemented local database
designed for games, mobile apps & desktop applications.
Fast. Light. Simple.
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.
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.
# 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
| help | See all possible commands and usage |
| exit | Save and quit |
| addn key value | Add a numeric key with value (value can be string or num) |
| getn key | Get a numeric key and its value |
| deln key | Delete a numeric key and its value |
| existsn key | Check if a numeric key exists |
| adds key value | Add a string key with value (value can be string or num) |
| gets key | Get a string key and its value |
| dels key | Delete a string key and its value |
| exist_str key | Check if a string key exists |
| define name { ... } | Define a new user-defined type with typed fields |
| undefine name | Delete a type definition |
| desc name | Inspect a type and its fields |
| add typename key ... | Add a record of a specific type |
| get typename key | Get a typed record by key |
| begin | Start the transaction process |
| commit | End and save the transaction |
| rollback | Undo changes if the transaction fails |
Types are user-defined, flexible structures โ perfect for game entities like players, items, or enemies.
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 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
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;
}
db.add(1, "value");
std::string v = db.get(1);
db.remove(1);
if (db.exists(1)) {}
db.put_str("key", "value");
std::string v = db.get_str("key");
db.remove_str("key");
if (db.exists_str("key")) {}
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");
db.begin();
db.commit();
db.rollback();
if (db.in_transaction()) {}
db.sync();
auto stats = db.stats();
std::string err = db.get_last_error();
These are summary of how to use STARK in C++. More languages and explanation will be added in further updates.
| Feature | STARK | SQLite | Redis | MongoDB | LevelDB |
|---|---|---|---|---|---|
| Type | Key-Value | Relational | Key-Value | Document | Key-Value |
| Language | C | C | C | C++ | C++ |
| Setup Time | 5 min | 5 min | 10 min | 15 min | 5 min |
| Memory Usage | 2โ5 MB | 5โ10 MB | 5โ10 MB | 100+ MB | 5โ10 MB |
| File Size | < 1 MB | 1โ5 MB | N/A (RAM) | 200+ MB | 1โ5 MB |
| Learning Curve | 20 min | 1 hour | 30 min | 2 hours | 30 min |
| Transactions | โ | โ | โ | โ | โ |
| ACID | โ | โ | Partial | โ | โ |
| SQL Support | โ | โ | โ | โ | โ |
| Network Support | โ | โ | โ | โ | โ |
| Multi-user | โ | โ | โ | โ | โ |
| Feature | STARK | SQLite | Redis | MongoDB |
|---|---|---|---|---|
| Save Player Data | โ 1 line | 5 lines SQL | 2 lines | 3 lines JSON |
| Load in 1 sec | โ 0.5 ยตs | 3 ยตs | 1 ยตs | 50 ยตs |
| Offline Use | โ Yes | โ Yes | โ No | โ No |
| Simple Syntax | โ add(1, "Hero") | INSERT INTO โฆ | SET key val | db.insert() |
| Focus | Offline apps | General purpose | Cache | Web apps |
| Database | File Size |
|---|---|
| STARK | ~100 KB |
| SQLite | ~150 KB |
| LevelDB | ~120 KB |
| MongoDB | ~2 MB |
| Operation | STARK | SQLite | Redis | MongoDB |
|---|---|---|---|---|
| Write 1 record | 0.8 ยตs | 5 ยตs | 1 ยตs | 50 ยตs |
| Read 1 record | 0.5 ยตs | 3 ยตs | 0.8 ยตs | 30 ยตs |
| Write 1,000 records | 0.8 ms | 5 ms | 1 ms | 50 ms |
| Read 1,000 records | 0.5 ms | 3 ms | 0.8 ms | 30 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.
For questions, advice, or to report an issue, feel completely free to reach out.
โ [email protected]