Architecture Overview #
System Architecture #
IceFireDB-SQLite is designed as a decentralized SQL database system that combines traditional SQLite storage with peer-to-peer networking capabilities. The architecture consists of several key components:
Core Components #
MySQL Protocol Handler
- Listens on configured port (default: 23306)
- Parses MySQL wire protocol requests
- Handles authentication and connection management
- Translates SQL commands to SQLite operations
SQLite Storage Engine
- Local SQLite database file storage
- Transaction management and query execution
- Data persistence and integrity maintenance
P2P Networking Layer
- libp2p-based decentralized networking
- Peer discovery and automatic node connection
- Data synchronization and conflict resolution
- Gossip protocol for state propagation
Synchronization Engine
- Change detection and propagation
- Conflict detection and resolution strategies
- Eventual consistency maintenance
- Transaction ordering and sequencing
Architectural Diagram #
+----------------+ +-----------------+ +----------------+
| MySQL Client | --> | MySQL Protocol | --> | SQLite Storage |
| (Application) | | Handler | | Engine |
+----------------+ +-----------------+ +----------------+
| |
v v
+-----------------+ +----------------+
| P2P Networking | <-> | Synchronization|
| Layer | | Engine |
+-----------------+ +----------------+
|
v
+-----------------+
| Other IceFireDB |
| SQLite Nodes |
+-----------------+
Data Flow #
- Client Request: MySQL client connects and sends SQL commands
- Protocol Processing: MySQL protocol handler parses and validates requests
- Local Execution: SQL commands executed on local SQLite database
- Change Detection: Synchronization engine detects data changes
- Network Propagation: Changes propagated to other nodes via P2P network
- Consistency Maintenance: All nodes eventually reach consistent state
Networking Model #
IceFireDB-SQLite uses a decentralized P2P networking model with:
- Service Discovery: Automatic peer discovery using DHT (Distributed Hash Table)
- Topic-based Messaging: PubSub system for efficient data propagation
- NAT Traversal: Support for nodes behind firewalls and NAT devices
- Connection Management: Automatic reconnection and fault tolerance
Consistency Model #
The system implements eventual consistency with:
- Last-Write-Wins: Conflict resolution based on timestamps
- Causal Ordering: Preservation of operation causality
- Background Synchronization: Continuous data synchronization
- Conflict Detection: Automatic detection of conflicting changes
Performance Characteristics #
- Low Latency: Local SQLite operations for fast response times
- High Throughput: Parallel processing of requests and synchronization
- Scalability: Horizontal scaling through additional nodes
- Resource Efficiency: Lightweight SQLite storage with minimal overhead
Security Features #
- Transport Encryption: TLS encryption for network communications
- Authentication: MySQL protocol authentication with configurable users
- Access Control: Tenant-based data isolation
- Network Security: Secure peer authentication and authorization