A local-first, crash-resilient medical inventory system powered by a custom B-Tree database engine.
AnchorMed is a desktop application designed for medical clinics in low-connectivity environments. Unlike traditional apps that rely on SQLite or cloud databases, AnchorMed runs on a custom-built storage engine engineered from scratch in Python.
It features a Write-Ahead Log (WAL) to ensure data integrity (ACID compliance), meaning zero data loss even if the power cuts out or the application crashes.
The core goal of this project was to implement Database Internals rather than just using them.
Instead of import sqlite3, I implemented a B-Tree (Order t=3) data structure in Python.
- Search Complexity: O(log n)
- Disk Storage: JSON-based serialization for portability.
- Logic: Handles complex node splitting and merging algorithms manually.
To prevent data corruption during crashes:
- Every transaction (Add/Update) is first appended to
recovery.wal. - Only after a successful log write is the data committed to the B-Tree memory.
- Crash Recovery: On startup, the engine checks the WAL. If it finds uncommitted logs (from a crash), it "replays" them to restore the database state automatically.
- Architecture: The UI (React) runs in Electron, while the Logic (B-Tree) runs as a spawned Python child process.
- Lifecycle Management: Implemented a robust "Zombie Killer" routine. When the main Electron window closes, it explicitly hunts down and terminates the Python background process to prevent memory leaks.
- Implemented a "Two-Step Handshake" protocol allowing multiple instances of AnchorMed to discover each other on a local Wi-Fi network and merge B-Tree states without a central server.
- Go to the Releases tab.
- Download
Anchor-Med Setup 3.0.0.exe. - Run the installer and follow the setup wizard.
- Note: No Python or Node.js installation required.
If you want to modify the B-Tree logic or the React frontend:
- Node.js (v18+)
- Python (v3.10+)
# Clone the repository
git clone [https://github.com/YOUR_USERNAME/Anchor-Med.git](https://github.com/YOUR_USERNAME/Anchor-Med.git)
cd anchor-med
# Install Frontend Dependencies
npm install
# Install Backend Dependencies
pip install flask flask-cors python-dotenv requests
[V SS Karthik] - Lead Engineer (Backend Architecture, B-Tree Engine, WAL Implementation)
- [Mouktika] - Frontend Developer / UI Design
- [Avinash] - Flask and WAL Implementation, Frontend Developer / UI Design
Anchor-Med is an active systems project.
Core functionality (custom B-Tree storage, WAL-based crash recovery, and
Flask integration) is implemented and manually stress-tested.
Known limitations and planned improvements are tracked transparently in the GitHub Issues tab.
The database engine has been manually stress-tested for crash recovery.
Testing methodology:
- Continuous insert and update operations under load
- Backend process forcefully terminated at random points
- Application restarted to trigger WAL replay
Results:
- WAL replay consistently restored a valid B-Tree state
- No partial or corrupted records observed
- Operations were either fully applied or safely ignored
Automated crash-recovery tests are planned as a future improvement.
Some advanced features (transaction boundaries, and full duplicate-key enforcement) They are under active development.
Please have a look at the Issues tab for detailed, tracked limitations and fixes.
For a detailed list of planned technical improvements, including B-Tree checkpointing and AES-256 encryption, please see: 👉 Future Enhancements
AnchorMed is a technical demonstration of database internals. It has not undergone HIPAA/GDPR certification. Use in a live clinical setting is at the user's own risk.