RustVault is a high-performance, ACID-compliant custom database engine built from scratch in Rust. It features a Write-Ahead Log (WAL) with CRC32 verification, snapshot compaction, an ACID transaction manager, a multi-dialect query parser/engine (supporting both Key-Value and SQL-like commands), an interactive terminal CLI REPL, an asynchronous REST API server, and an embedded modern Web GUI dashboard.
- Custom Durable Storage Engine:
- MemTable: In-memory B-Tree index for microsecond reads and sorted range scans.
- Write-Ahead Logging (WAL): Append-only persistent journal with binary framing and CRC32 checksums for deterministic crash recovery.
- Snapshot Compaction: Point-in-time state checkpointing and automatic WAL truncation.
- Time-to-Live (TTL): Automatic record expiration and lazy background cleanup.
- ACID Transaction Management:
- Staging buffers with snapshot isolation.
- Full
BEGIN,COMMIT, andROLLBACKsupport with atomic batch writes.
- Rich Query Engine & Parser:
- Lexer and recursive descent parser.
- Key-Value dialect:
SET,GET,DEL,EXISTS,KEYS,SCAN. - SQL-like dialect:
SELECT ... FROM ... WHERE ... LIMIT ...,INSERT INTO ...,UPDATE ...,DELETE FROM .... - Admin commands:
STATS,COMPACT,PING,HELP.
- Async HTTP REST API & Web GUI:
- High-throughput asynchronous server powered by
TokioandAxum. - Embedded modern Web Dashboard with live Query Console, Key-Value Explorer, and System Metrics.
- High-throughput asynchronous server powered by
- Interactive CLI & REPL:
- Colored interactive terminal shell with command execution timing and history.
+---------------------------------------+
| Clients & Interfaces |
| CLI REPL | REST API | Web GUI |
+-------------------+-------------------+
|
v
+---------------------------------------+
| Lexer, Parser & Query AST |
+-------------------+-------------------+
|
v
+---------------------------------------+
| ACID Transaction Manager |
| (Staged Writes & Isolation) |
+-------------------+-------------------+
|
v
+---------------------------------------+
| Storage Engine |
| +----------------+ +---------------+ |
| | MemTable | | WAL | |
| | (B-Tree Index) | | (CRC32 Frame) | |
| +----------------+ +---------------+ |
| +----------------------------------+ |
| | Snapshots & Compactor | |
| +----------------------------------+ |
+---------------------------------------+
cargo run -- democargo run -- server --port 8080 --dir ./vault_dataOpen your browser and visit: http://127.0.0.1:8080/
cargo run -- cli --dir ./vault_datacargo run -- exec "SET user:1 'Aditya Pandey' TTL 3600"
cargo run -- exec "GET user:1"
cargo run -- exec "SELECT * FROM user"| Command | Description | Example |
|---|---|---|
SET <key> <value> [TTL <secs>] |
Store a key-value pair with optional TTL | SET session:123 "active" TTL 300 |
GET <key> |
Retrieve value for key | GET session:123 |
DEL <key> |
Delete a key | DEL session:123 |
EXISTS <key> |
Check if a key exists (returns 1 or 0) | EXISTS session:123 |
KEYS [pattern] |
List matching keys (supports * and ?) |
KEYS user:* |
SCAN [start] [end] [LIMIT n] |
Range scan sorted keys | SCAN user:001 user:100 LIMIT 10 |
| Statement | Description | Example |
|---|---|---|
SELECT * FROM <table> [WHERE ...] [LIMIT n] |
Query table documents | SELECT * FROM users WHERE id = '101' |
INSERT INTO <table> <key> <val> |
Insert record into table | INSERT INTO users 101 '{"name":"Aditya"}' |
UPDATE <table> SET col = <val> [WHERE ...] |
Update matching records | UPDATE users SET value = '{"name":"Aditya P"}' WHERE id = '101' |
DELETE FROM <table> [WHERE ...] |
Delete matching table records | DELETE FROM users WHERE id = '101' |
BEGIN;
SET account:A "900";
SET account:B "350";
COMMIT; -- Or ROLLBACK to abort and discard changesSTATS: Display active keys, WAL size, IO throughput, and uptime.COMPACT: Persist MemTable snapshot and truncate WAL logs.PING: Check server liveness (returnsPONG).HELP: Display query syntax cheatsheet.
POST /api/query: Run query string ({ "query": "...", "session_id": "..." })GET /api/stats: Fetch real-time storage engine metricsGET /api/keys: List stored keys with timestamps and TTL metadataPOST /api/kv: Quick store endpoint ({ "key": "...", "value": "...", "ttl_secs": ... })DELETE /api/kv/{key}: Quick delete endpointPOST /api/compact: Trigger snapshot compactionGET /api/health: Healthcheck
Run the full test suite covering storage persistence, WAL crash recovery, ACID transactions, and query engine:
cargo test --all