railgundb
v1.0.2
Published
Decentralized, encrypted, peer-to-peer database with cryptographic identity
Downloads
323
Maintainers
Readme
Railgun
A decentralized, encrypted, peer-to-peer database with cryptographic identity and deterministic conflict resolution.
Railgun provides a secure, distributed storage layer for decentralized applications. It combines cryptographic identity (Ed25519), content-addressable storage (Merkle Tries), and peer-to-peer networking (WebRTC) into a simple, easy-to-use API.
Documentation
Comprehensive documentation is available in the docs/ directory:
- Getting Started: Installation, quick start, and basic usage.
- Core Concepts: Deep dive into Identity, Data Spaces, and P2P Sync.
- API Reference: Detailed documentation for all methods and classes.
- Architecture: System design, layers, and storage adapters.
Features
- Cryptographic Identity: Secure user accounts using Ed25519 keypairs.
- Suffix-Based Handles: Human-readable display names with deterministic suffixes (e.g.,
alice#K9FQ). - Merkle Trie Storage: Verifiable, content-addressable data structure.
- P2P Sync: Real-time synchronization between peers using WebRTC.
- Data Spaces: Granular control over data visibility and mutability (
all,frozen,user). - Platform Agnostic: Runs in Node.js (File System) and Browsers (IndexedDB).
Installation
npm install railgundbQuick Start
import { Railgun } from 'railgundb';
// 1. Initialize
const db = await Railgun.create();
// 2. Create Identity
const { handle } = await db.signup('alice', 'my-secure-password');
console.log(`Signed up as ${handle}`);
// 3. Store Data (Encrypted)
await db.put('notes/secret', 'This is private', { space: 'user' });
// 4. Connect to Network
await db.connect('http://localhost:3000');Signalling Server
Railgun includes a built-in signalling server for P2P discovery.
Basic Usage
npm run server
# Running on 0.0.0.0:3000Secure WebSocket (WSS) Support
To enable WSS (required for HTTPS web deployments), provide SSL certificates via environment variables:
Option A: File Paths
export SSL_KEY_PATH="/path/to/privkey.pem"
export SSL_CERT_PATH="/path/to/fullchain.pem"
npm run serverOption B: Direct Content
export SSL_KEY="-----BEGIN PRIVATE KEY-----..."
export SSL_CERT="-----BEGIN CERTIFICATE-----..."
npm run serverLicense
MIT
