Skip to content

gotchoices/Optimystic

Repository files navigation

Optimystic

Optimystic is a distributed database system built on peer-to-peer networks. It provides a robust, scalable foundation for applications requiring consistent data storage, distributed transactions, and efficient peer coordination across decentralized networks.

Features

  • Distributed Database Core - Transactional database with ACID properties across peer-to-peer networks
  • Block-based Storage - Versioned data blocks with efficient storage and retrieval
  • Block Restoration - Automatic recovery of missing blocks from cluster peers (Ring Zulu)
  • Matchmaking System - Efficient peer discovery and task coordination via FRET
  • Archival Storage - Scalable long-term storage through the Arachnode system
  • Cross-Collection Transactions - Support for complex operations spanning multiple data collections

See the following documentation:

Packages

  • Database Core - packages/db-core - Database core functionality, not specific to any particular storage topology
  • Database P2P - packages/db-p2p - Database integration with libp2p, including Arachnode ring discovery (also exports @optimystic/db-p2p/rn for React Native — see below)
  • Database P2P Storage (Filesystem) - packages/db-p2p-storage-fs - Node.js filesystem storage backend
  • Database P2P Storage (NativeScript) - packages/db-p2p-storage-ns - NativeScript storage backend using SQLite
  • Database P2P Storage (React Native) - packages/db-p2p-storage-rn - React Native storage backend using LevelDB
  • Database P2P Storage (Web) - packages/db-p2p-storage-web - Browser storage backend using IndexedDB
  • Reference Peer - packages/reference-peer - CLI for testing peer-to-peer functionality (run via optimystic-peer)
  • Quereus Plugin Crypto - packages/quereus-plugin-crypto - Quereus plugin providing cryptographic functions
  • Quereus Plugin Optimystic - packages/quereus-plugin-optimystic - Quereus plugin for Optimystic distributed tree collections
  • Demo - packages/demo - Hello world demo app exercising Tree and Diary collections across the full stack
  • Substrate Simulator - packages/substrate-simulator - Discrete-event virtual-clock engine for the design simulator (mock-only dev tooling; not shipped to runtime consumers)

How to use:

Host a stand-alone node

Stand-alone nodes can be hosted on any platform supporting Node.js. A node can be configured as either of the following:

  • Transaction Node - limited storage capacity
    • Facilitates data storage and matchmaking operations, such as:
      • Processing distributed transactions
      • Coordinating peer matchmaking
      • Maintaining short-term data caches
  • Storage Node - server or cloud service with long-term storage capability
    • Typical users: enterprises, service providers, institutions
    • Facilitates:
      • Long-term data durability and availability
      • Archival of historical data
      • Network stability and robustness

Whether transactional or storage-focused, a stand-alone node can optionally serve as:

  • Public Gateway - providing a public IP/DNS address for incoming connections from mobile apps and NAT traversal
  • Bootstrap Node - providing stable entry points for new nodes joining the network

React Native

@optimystic/db-p2p/rn provides a Metro/Hermes-safe entrypoint that excludes Node-only transports (@libp2p/tcp). Callers must supply their own transports:

import { webSockets } from '@libp2p/websockets';
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2';
import { createLibp2pNode } from '@optimystic/db-p2p/rn';

const node = await createLibp2pNode({
    networkName: 'mynet',
    bootstrapNodes: ['/dns4/relay.example.com/tcp/443/wss/p2p/12D3...'],
    transports: [webSockets(), circuitRelayTransport()],
});

For persistent storage on RN, use @optimystic/db-p2p-storage-rn (LevelDB backend via rn-leveldb). It shares the same native module as @quereus/plugin-react-native-leveldb, so apps embedding both stacks install one binding.

Hermes requires polyfills for several globals (crypto, structuredClone, Promise.withResolvers, EventTarget, etc.) and Metro module aliases for Node.js built-ins (os, crypto, stream, buffer). See packages/db-p2p README for the full polyfill checklist and recommended shims.

Use Cases

Optimystic is suitable for applications requiring:

  • Distributed Ledgers - Tamper-evident records across multiple parties
  • Content Distribution - Reliable data replication across geographic regions
  • Collaborative Applications - Shared data structures for multiple users
  • Audit Trails - Immutable logs of system events and changes
  • Decentralized Storage - Resilient data storage without central points of failure

Testing

An automated test suite with VS Code debugging is ready for use:

# Quick test with detailed output
yarn workspace @optimystic/reference-peer build
yarn workspace @optimystic/reference-peer test:quick

📖 See START-HERE.md to begin using the automated test loop!

Additional documentation:

Contributing

If you would like to help out, the following skills will be most useful:

  • TypeScript
  • Node.js
  • React Native
  • libp2p

We can always use help with documentation, testing, translation, and other tasks.

Submit pull requests to the Optimystic repository

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors