
MiniDB
A custom lightweight, schema-driven database engine built from scratch in C++.
Timeline
Experimental Mode
Role
Systems Engineer
Team
Solo
Status
CompletedTechnology Stack
Key Challenges
- Binary Serialization
- Memory Management
- Polyglot Communication
Key Learnings
- Database Internals
- Low-level File I/O
- Data Structures
Overview
MiniDB is my answer to the question: "How does a database actually work under the hood?"
While most developers spend their time learning how to query databases, I wanted to learn how to build one. MiniDB isn't a wrapper around SQLite or MySQL. It is a raw, high-performance database engine written in C++17 that handles its own memory, file I/O, and binary serialization.
To make it usable for humans, I built a modern Flask (Python) web interface that communicates with the C++ engine via system subprocesses.
Key Features
Raw Engineering
- Custom Binary Storage: Data isn't saved as text; it's serialized into binary packets. This teaches the fundamentals of how real DBMS systems optimize storage.
- Dynamic Schema System: Just like a real DB, you define structure in
schema.txt, and the engine adapts its binary parsing logic instantly. - 5,200 Ops/Sec: Benchmarked to handle heavy read/write loads efficiently for a file-based system.
The Full-Stack Bridge
- Polyglot Architecture: The backend is C++ (for speed), the middleware is Python (for logic), and the frontend is HTML/JS (for interaction).
- Logical Deletes: Implemented "Soft Delete" mechanisms to preserve data integrity before purging.
System Architecture
The project demonstrates a clean separation of concerns between the Data Engine and the User Interface.
The Schema Logic
Everything starts with the schema.txt. The C++ engine reads this on boot to understand how to parse the binary blocks.
// schema.txt
id:int,name:string,age:int,class:char
The Data Flow
# How the stack communicates
1. User clicks "Save" on Web UI
2. Flask server catches request
3. Python spawns a C++ Subprocess:
$ ./mydb.exe insert id=1 name=Herin age=21
4. C++ Engine serializes data -> writes to dbfile.db (Binary)
5. Success/Error code returned to UI
