Core Architectural Principles
Decentralization First
Data and media exchange occurs directly between peers with no central bottleneck
Simplicity through Abstraction
Clean event-driven API hides WebRTC complexity
Room-Based Scoping
Logical “rooms” provide natural containers for peer groups
Secure by Design
Built-in E2E encryption for signaling and data channels
Architectural Components
1. Signaling Layer (Peer Discovery)
GenosRTC uses the decentralized Nostr network for signaling instead of custom WebSocket servers. Relay Selection Strategy:Immediate Connection
Connects instantly to developer-provided or built-in relays for zero-latency startup
Dynamic Fallback
Loads extended relay list from local cache (updated from nostr.watch) and schedules background connections
2. P2P Transport Layer (WebRTC)
Manages direct, low-latencyRTCPeerConnections between peers:
- WebRTC ICE Framework: Traverses NATs and firewalls using STUN/TURN
- Encrypted by Default: DTLS-SRTP encryption for all data/media
- Direct Connections: Peer-to-peer links minimize latency
3. Session Management (The Room)
Thedb.room object orchestrates the P2P session lifecycle:
4. Communication Abstractions
Data Channels
Built onRTCDataChannel for structured data:
Media Streams
Optimized for real-time audio/video:Lifecycle of a Peer Connection
Cellular Mesh Architecture
For large-scale applications (100+ peers), GenosRTC offers an optional Cellular Mesh Overlay:- Reduces connections from O(N²) to O(N)
- Supports 10,000+ peers
- ~log(N) hop latency vs. single-hop traditional mesh
- Automatic cell sizing and bridge selection
Security Model
Transport Encryption
Transport Encryption
All WebRTC communications are encrypted using DTLS (data) and SRTP (media), preventing eavesdropping on P2P links.
End-to-End Encryption (E2EE)
End-to-End Encryption (E2EE)
Optional Even Nostr relays cannot decipher the application’s data.
password parameter encrypts all signaling and data channel messages:Cellular Mesh Security
Cellular Mesh Security
In cellular mode, inter-cell messages maintain encryption. Bridge nodes forward encrypted payloads without accessing plaintext.
Performance Characteristics
| Metric | Traditional Mesh | Cellular Mesh |
|---|---|---|
| Connections/peer | O(N) | O(√N) |
| Message latency | 1 hop | ~log(N) hops |
| Max practical peers | ~100 | Massive scale |
| Bandwidth/peer | High | Optimized |
Complete Example
Related Pages
Nostr Signaling
Run your own Nostr relay
Cellular Mesh
Scalable mesh architecture
Fallback Server
Optional reliability enhancement