A modular, ACID-compliant embedded database written in C++ as a personal side project to learn databases.
- C++17 compatible compiler (GCC 7+ or Clang 5+)
- CMake 3.16 or higher
- Make (or equivalent build system)
- Linux, macOS, or Unix-like system
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install build-essential cmakemacOS:
brew install cmakeFedora/RHEL:
sudo dnf install gcc-c++ cmake make- ACID Compliance: Full transaction support with atomicity, consistency, isolation, and durability
- Page-based Storage: Efficient disk-based storage with page caching
- Write-Ahead Logging (WAL): Crash recovery and durability guarantees
- Lock Manager: Concurrency control with deadlock detection
- Transaction Manager: Complete transaction lifecycle management
- Interactive CLI: Simple command-line interface for database operations
StoneDB-engine is built with a modular architecture:
- StorageManager: Handles page-based storage and caching
- WALManager: Write-ahead logging for crash recovery
- LockManager: Concurrency control and deadlock detection
- TransactionManager: ACID transaction management
git clone https://github.com/ruskaruma/StoneDB-engine.git
cd StoneDB-engine# Quick build (recommended)
chmod +x build.sh
./build.sh
# Or manually
mkdir build && cd build
cmake ..
make -j$(nproc)After building, the executable will be at ./build/stone. Test it:
./build/stone --helpYou should see the help message. The build is complete!
After building, you can immediately start using the database:
# Start with default database (stonedb.sdb)
./build/stone
# Or specify a custom database file
./build/stone --db myapp.sdb
# Batch mode for scripts
echo "put key value" | ./build/stone --db myapp.sdb --batchYou'll see the interactive prompt:
StoneDB-engine v1.0.0
Database: myapp.sdb
Type 'help' for commands
stonedb>
./build/stone --db myapp.sdbCommands:
put <key> <value>- Store key-value pairget <key>- Retrieve value for keydel <key>- Delete keyscan- Show all recordsbackup <path>- Backup database to JSONrestore <path>- Restore database from JSONhelp- Show helpquit- Exit database
-d, --db PATH- Database file path (default: stonedb.sdb)-b, --batch- Batch mode (non-interactive)-q, --quiet- Suppress log messages-h, --help- Show help message
For detailed usage examples, scripting, integration, and real-world patterns, see USAGE_GUIDE.md.
stonedb> put hello world
OK
stonedb> put test 123
OK
stonedb> get hello
world
stonedb> scan
hello = world
test = 123
stonedb> quit
Goodbye!
stonedb> put user alice
OK
stonedb> get user
alice
stonedb> put user bob
OK
stonedb> get user
bob
stonedb> put temp data
OK
stonedb> get temp
data
stonedb> del temp
OK
stonedb> get temp
NOT FOUND
stonedb> put key1 value1
OK
stonedb> put key2 value2
OK
stonedb> put key3 value3
OK
stonedb> scan
key1 = value1
key2 = value2
key3 = value3
After building, run the test suite:
cd build
./test_common
./test_storage
./test_wal
./test_lockmgr
./test_transaction
./test_recovery
./test_benchmarkIndividual tests:
test_common- Common utilitiestest_storage- Storage managertest_wal- Write-ahead loggingtest_lockmgr- Lock managertest_transaction- Transaction managertest_recovery- Crash recoverytest_benchmark- Performance benchmarks
Make this into a simple embeddable DB for student or indie dev apps. Maybe release a paid binary version later.
- INSTALL.md - Detailed installation instructions
- ARCHITECTURE.md - System architecture with diagrams
- USAGE_GUIDE.md - Comprehensive usage guide
- docs/API.md - API documentation
- docs/TUTORIAL.md - Architecture tutorial
MIT License - feel free to use for learning.