How polyphony-chat/chorus works
Main Components
a) Core Library Components:
• Instance Manager
• Authentication System
• Gateway System
• Voice System
• Rate Limiter
• API Endpoints Handler
b) External Interfaces:
• Chat Services (Spacebar/Discord/Polyphony)
• WebSocket Connections
• UDP Connections (for voice)
• HTTP REST APIs
┌─────────────────────────────────────────────────────────────┐
• Client Applications │
• ┘
• ▲
┌─────────────────────────────────────────────────────────────┐
• Chorus Library API │
• ┬──────────────┬─────────────┬─────────────────┤
• Instance │ Gateway │ Voice │ API Endpoints │
• Manager │ System │ System │ Handler │
• ┴──────────────┴─────────────┴─────────────────┤
• Core Services │
• ┬──────────────┬─────────────┬─────────────────┤
• Auth │ Rate Limiter │ WebSocket │ UDP │
• Manager │ │ Backend │ Backend │
• ┴──────────────┴─────────────┴─────────────────┘
• ▲
┌─────────────────────────────────────────────────────────────┐
• External Chat Services │
• (Spacebar / Discord / Polyphony Servers) │
• ┘
Component Details
Instance Manager:
• Handles multiple server connections
• Manages instance configuration
• Coordinates authentication and session management
Gateway System:
• WebSocket connection management
• Event handling and distribution
• Heartbeat maintenance
• Connection state management
Voice System:
• UDP communication
• Voice data encryption
• Session management
• Backend implementations (tokio/wasm)
API Endpoints Handler:
• REST API interactions
• Request/response management
• Error handling
• Type-safe interfaces
Important Relationships
• Bidirectional communication between Gateway and External Services
• One-way dependencies from Client Applications to Library API
• Internal communication between components
• Rate limiter intercepting API calls
• Authentication flow through the system
Additional Elements
• Version compatibility information
• Platform-specific implementations
• Error handling paths
• Rate-limited pathways
Implementation Notes
• Notes about minimum Rust version requirements
• Thread boundaries and async contexts
• UML notation
• Custom styling
• Layered architecture representation
• Clear typography
• Export to vector formats
Remember to maintain a balance between detail and clarity, focusing on the key architectural decisions while avoiding overwhelming technical minutiae.