Lightweight, offline-first embedded SQL database for African edge payments. Built for Pesapal Junior Dev Challenge '26. Features hash indexing, type-safe schema enforcement, and a merchant transaction dashboard.
# PesaTrack & PesaDB
> **Pesapal Junior Dev Challenge '26 Submission**
**PesaTrack** is a Merchant Transaction Dashboard powered by **PesaDB**, a custom-built, lightweight, embedded Relational Database Management System (RDBMS) designed for offline-first payment systems in African markets.
---
## Table of Contents
* The Vision
* Quick Start
* Features
* Architecture
* Performance
* Usage Examples
* Testing
* Project Structure
---
## The Vision: "Payments at the Edge"
In many African markets, internet connectivity can be intermittent. Relying on cloud-only databases for Point-of-Sale (POS) systems can lead to lost transactions.
**PesaDB** is designed as an **embedded, offline-first SQL engine** that runs locally on the merchant's device, ensuring:
1. **Zero Latency**: Transactions are recorded instantly in-memory
2. **Data Integrity**: Type-safe schema enforcement prevents bad data entry
3. **Persistence**: Data is flushed to disk (`pesadb.json`) for durability
4. **Simplicity**: A lightweight REPL and SQL interface for easy debugging
---
## Quick Start
### Prerequisites
- Node.js (v16+)
### Installation & Setup
```bash
# Install dependencies
npm install
# Seed the database with sample data
npx ts-node seed.ts
# Option 1: Run the REPL (Interactive SQL Mode)
npx ts-node src/repl/index.ts
# Option 2: Run the Web Dashboard
npx ts-node src/server/index.ts
# Then open
localhost in your browser
```
### Test the Database
```bash
# Run basic database tests
npx ts-node test_db.ts
# Test enhanced JOIN operations
npx ts-node test_enhanced_join.ts
# Test B-Tree indexing
npx ts-node test_btree.ts
```
---
## Features
### Core Database Features
#### 1. **Relational Database Management System**
- Custom SQL engine with typed columns (`string`, `number`, `boolean`)
- Primary keys and unique constraints
- Full CRUD operations (CREATE, INSERT, SELECT, UPDATE, DELETE)
- Type enforcement and validation
- Data persistence to JSON
#### 2. **Advanced J …