How sourcenetwork/defradb works
Main Components
a. Core Components:
• HTTP API Layer (port 9181)
• P2P Network Layer (port 9171)
• Query Engine (DQL)
• Storage Layer (BadgerDB)
• Schema Management
• Access Control System (ACP)
• Key Management System
• MerkleCRDT Engine
b. External Interfaces:
• GraphQL API Endpoint
• CLI Client Interface
• P2P Network Interface
• Backup/Restore Interface
[HTTP/GraphQL API] --- [CLI Client] --- [P2P Network Interface]
[Query Engine (DQL)] --- [Schema Manager] --- [Access Control]
[MerkleCRDT Engine] -------- [Core DB] ----- [Key Management]
[BadgerDB Storage] --- [P2P Sync] --- [Backup/Restore]
Connection Types
• Double lines: Data flow
Key Interactions to Highlight
a. Data Flow:
• Client requests through HTTP/GraphQL API
• Query processing through DQL engine
• Storage operations in BadgerDB
• P2P synchronization of updates
• Access control checks
b. Security Flow:
• Key management for encryption
• Access control policy enforcement
• P2P authentication
Component Details
Annotations for key components:
HTTP API:
• Port: 9181
• Endpoints: /api/v0/graphql
• CORS support
• Optional TLS
P2P Network:
• Port: 9171
• PubSub peering
• Replicator peering
• Document synchronization
Storage:
• BadgerDB backend
• MerkleCRDT structure
• Backup/restore capability
Additional Elements
Callouts for:
• Configuration options
• Default ports
• Key file locations
• Security considerations
• Scaling capabilities
Implementation Notes
• The modular nature of the system
• Security integration points
• Extensibility options
• Data flow patterns
• Synchronization mechanisms