NetStoreDB

2 min read

NetStoreDB

NetStoreDB is a peer-to-peer distributed key-value store built in Rust, designed to leverage asynchronous networking, multi-threaded execution (Tokio), and decentralized storage. It features UDP-based peer discovery, TCP communication for reliability, and a CLI for direct node interaction. The goal is to showcase Rust’s memory safety, concurrency model, and efficiency in distributed systems.

Key Features:

  • UDP Handshake: Utilizes UDP broadcasts for efficient peer discovery
  • TCP Communication: Ensures reliable communication between nodes
  • Concurrent Access: Leverages Tokio for a multi-threaded approach
  • Key-Value Store: Uses a straightforward data model that can be extended
  • CLI: Provides a command-line interface for managing nodes and data

Project Structure:

  • cli/: Contains the CLI application.
  • src/: Houses the core library code.
  • Cargo.toml: Manages the project’s dependencies.

Installation:

  1. Ensure Rust and Cargo are installed.

  2. Clone the repository:

    git clone https://gitlab.com/surajraika1/NetStoreDB.git
    
  3. Build the project:

    cd NetStoreDB
    cargo build --release
    

    If set up as a workspace, the CLI can be built separately:

    cargo build --release -p cli
    

Usage:

  1. Run the CLI binary:

    ./target/release/netstoredb
    

    The node should automatically discover and communicate with other nodes on the network.

  2. Interact with the database using the CLI commands:

    • Set a Value:

      ./netstoredb set --node 0.0.0.0:9000 "testKey" "testValue"
      
    • Get a Value:

      ./netstoredb get --node 0.0.0.0:9000 "testKey"
      

      Replace 0.0.0.0:9000 with the node’s address and the keys/values with the desired input.