System Architecture Overview
ErikrafT Drop implements a hybrid client-server architecture where the server facilitates peer discovery and signaling, while actual file transfers occur directly between peers using WebRTC.Architecture Components
Client-Side Architecture
Core Classes
The client application is built around several key JavaScript classes:File Transfer System
- FileChunker: Breaks files into 64KB chunks with 1MB partitions
- FileDigester: Reassembles received chunks into complete files
- MIME Detection: Automatic MIME type identification for transferred files
Server-Side Architecture
WebSocket Server
The Node.js server (ws-server.js) handles:
Peer Management
- Peer Class: Represents connected clients with metadata and capabilities
- Room System: Groups peers by IP, secret, or public room IDs
- Rate Limiting: Prevents abuse with 10 requests per 10 seconds limit
Data Flow Architecture
Connection Establishment Flow
File Transfer Flow
Network Topology
Local Network Mode
- IP-Based Rooms: Devices with same public IP are grouped together
- Direct P2P: WebRTC establishes direct connections when possible
- LAN Optimization: No internet bandwidth used for file transfers
Remote Pairing Mode
- Secret-Based Rooms: 256-character encrypted room secrets
- Persistent Connections: Paired devices remain discoverable across networks
- Cross-Network: Works even when devices are on different networks
Security Architecture
Encryption Layers
WebRTC Encryption
Server Security
- No File Storage: Server never handles file content
- Hashed Identifiers: Peer IDs are salted with SHA3-512
- Rate Limiting: Prevents brute force attacks
- LAN Mode: Optional restriction to local networks only
Authentication Model
Device Identification
Pairing Authentication
- Room Secrets: 256-character cryptographically random strings
- Persistent Storage: IndexedDB stores pairing information
- Hash Verification: SHA3-512 ensures secret integrity
Performance Architecture
Memory Management
File Chunking Strategy
iOS Memory Limits
Network Optimization
Connection Pooling
- Multiple Rooms: Single peer can participate in multiple room types
- Connection Reuse: Existing WebRTC connections are reused when possible
- Fallback Mechanism: WebSocket fallback when WebRTC fails
Bandwidth Management
- Adaptive Chunking: Smaller chunks for unstable connections
- Progress Tracking: Real-time transfer progress monitoring
- Error Recovery: Automatic retry mechanisms for failed chunks
Scalability Considerations
Server Scalability
- Stateless Design: Server maintains minimal state
- Room Distribution: Efficient room-based message routing
- Connection Limits: Configurable rate limiting and connection caps
Client Scalability
- Memory Efficiency: Streaming file processing
- Browser Limits: Respects browser memory constraints
- Concurrent Transfers: Multiple simultaneous file transfers supported
Deployment Architecture
Production Deployment
- Node.js Server: Express.js with WebSocket support
- Reverse Proxy: Optional nginx/Apache for SSL termination
- Process Management: PM2 or similar for production stability
Development Environment
- Docker Support: Containerized development environment
- Hot Reload: Development server with auto-restart
- Debug Mode: Enhanced logging for development
Monitoring and Observability
Server Metrics
- Connection Count: Active WebSocket connections
- Room Statistics: Room usage and distribution
- Error Rates: Connection failures and transfer errors
Client Metrics
- Transfer Speed: Real-time bandwidth monitoring
- Connection Quality: WebRTC connection state tracking
- Error Reporting: Client-side error collection