TrainDB

P2P Decentralized Key-Value Database with Bluetooth Low Energy Support for Hostile Network Conditions

Features

Built for reliability, scalability, and resilience in challenging network environments

🌐

P2P Networking

Decentralized peer-to-peer communication using TCP/GossipSub for reliable data synchronization across nodes.

🔵

Bluetooth Low Energy

BLE device discovery and scanning for mesh-like communication without traditional network infrastructure.

High Performance

Built in Rust with RocksDB storage engine for fast, persistent key-value operations.

🛡️

Fault Tolerant

Designed for hostile network conditions with automatic peer discovery and connection recovery.

🔗

Multi-Transport

Dual transport layer using both TCP/IP and Bluetooth for maximum connectivity and resilience.

🌐

REST API

Simple HTTP REST API for easy integration with existing applications and services.

Tech Stack

Built with modern, reliable technologies

🦀

Rust

Memory-safe systems programming

🪨

RocksDB

High-performance storage engine

🌐

libp2p

Modular P2P networking stack

🔵

btleplug

Cross-platform Bluetooth LE

📡

GossipSub

Mesh networking protocol

Tokio

Async runtime for Rust

Quick Demo

Get TrainDB running in minutes

# Clone and build
git clone https://github.com/abhiraj-mengade/train-db.git
cd train-db
cargo build --features bluetooth --release

# Start first node with API
./target/release/train-db --db-path ./node1 start-with-api \
    --node-port 4001 --api-port 8001

# Start second node
./target/release/train-db --db-path ./node2 start-with-api \
    --node-port 4002 --api-port 8002 \
    --bootstrap /ip4/127.0.0.1/tcp/4001

# Use the REST API
curl -X POST "http://localhost:8001/api/keys" \
     -H "Content-Type: application/json" \
     -d '{"key": "hello", "value": "world"}'

curl "http://localhost:8001/api/keys"

Getting Started

Follow these simple steps to set up TrainDB

1

Install Rust

Make sure you have Rust installed on your system. Visit rustup.rs for installation instructions.

2

Clone & Build

Clone the repository and build TrainDB with Bluetooth support using Cargo.

3

Start Nodes

Launch multiple TrainDB nodes and connect them to form a decentralized network.

4

Use the API

Interact with your distributed database using the simple REST API endpoints.