@toolkit-p2p/graph
v0.1.0
Published
Property graph database with CRDT synchronization for toolkit-p2p
Downloads
11
Maintainers
Readme
@toolkit-p2p/graph
Property graph database with CRDT synchronization for distributed P2P applications
Part of toolkit-p2p - Build serverless P2P web apps.
Features
- Property Graph Model - Nodes and edges with arbitrary properties
- CRDT Synchronization - Conflict-free distributed updates using LWW-Map
- IndexedDB Persistence - Browser-native storage with TTL expiration
- Query API - Find nodes/edges, traverse graphs, calculate trust scores
- Signature Verification - Ed25519 signatures for security
Installation
pnpm add @toolkit-p2p/graphQuick Start
import { GraphCore } from '@toolkit-p2p/graph';
// Create graph instance
const graph = new GraphCore('peer-id-123');
// Add nodes
const alice = await graph.addNode({
type: 'Person',
props: { handle: 'alice', emoji: '🎧' }
}, { ttlSec: 172800 }); // 48 hours
const bob = await graph.addNode({
type: 'Person',
props: { handle: 'bob', emoji: '🏀' }
}, { ttlSec: 172800 });
// Add edge
await graph.addEdge({
from: alice.id,
to: bob.id,
type: 'trusts',
props: { score: 0.9, context: 'brought the speaker' }
}, { ttlSec: 86400 }); // 24 hours
// Query
const people = await graph.findNodes('Person');
const trusted = await graph.findEdges(undefined, bob.id, 'trusts');
const trustScore = await graph.getTrustScore(alice.id, bob.id);
console.log(`Trust score from Alice to Bob: ${trustScore}`);Status
Version: 0.1.0 Phase: Phase 3 (Week 2-3) of Constellation v0.5 implementation
This package is under active development as part of the Constellation v0.5 specification (TASK-023 to TASK-032).
License
MIT
