RustIRC follows a modular, event-driven architecture designed for extensibility, performance, and maintainability. The system is built as a collection of loosely coupled crates that communicate through well-defined interfaces.
┌─────────────────────────────────────────────────────────┐
│ User Interface │
│ ┌─────────────────┐ ┌──────────────────┐ │
│ │ GUI (Iced) │ │ TUI (Ratatui) │ │
│ └────────┬────────┘ └────────┬─────────┘ │
└───────────┼────────────────────────────────┼────────────┘
│ │
┌───────────▼────────────────────────────────▼───────────┐
│ Core Client │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │Event Bus │ │State Manager │ │Config Manager│ │
│ └──────┬───────┘ └──────┬───────┘ └──────────────┘ │
│ │ │ │
│ ┌──────▼───────┐ ┌──────▼───────┐ ┌──────────────┐ │
│ │Connection Mgr│ │Buffer Manager│ │Command Queue │ │
│ └──────┬───────┘ └──────────────┘ └──────────────┘ │
└─────────┼──────────────────────────────────────────────┘
│
┌─────────▼────────────────────────────────────────────────┐
│ Protocol Layer │
│ ┌──────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │Message Parser│ │Message Builder│ │Capability Mgr │ │
│ └──────────────┘ └───────────────┘ └───────────────┘ │
└──────────────────────────────────────────────────────────┘
│
┌─────────▼──────────────────────────────────────────────┐
│ Network Layer │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │TCP/TLS Socket│ │DCC Handler │ │SASL Auth │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└────────────────────────────────────────────────────────┘
│
┌─────────▼──────────────────────────────────────────────┐
│ Extension System │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │Lua Scripts │ │Python Scripts│ │Native Plugins│ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└────────────────────────────────────────────────────────┘
- Central message routing system
- Priority-based event handlers
- Async event processing
- Plugin event injection points
- Immutable state transitions
- Event sourcing for history
- Subscription-based updates
- State persistence/restoration
- Multi-server connections
- Connection pooling
- Automatic reconnection
- Network state tracking
- Message history management
- Virtual scrolling for performance
- Search and filtering
- Log persistence
- IRC message parsing/building
- IRCv3 capability negotiation
- SASL authentication
- DCC protocol support
- Lua scripting engine
- Python integration (future)
- Native plugin loading
- Sandboxed execution
- Network socket receives data
- Protocol parser validates and parses message
- Message converted to internal event
- Event published to event bus
- Handlers process event in priority order
- State manager updates state
- UI components receive state updates
- Plugins/scripts receive filtered events
- User action or script triggers command
- Command validated and queued
- Message builder creates IRC message
- Rate limiting applied if needed
- Message sent through network socket
- Confirmation event generated
- State updated with sent message
Core client functionality:
- Client manager
- Event system
- State management
- Configuration
IRC protocol implementation:
- Message parsing/building
- Command definitions
- Numeric replies
- IRCv3 capabilities
GUI implementation using Iced:
- Main application window
- Custom widgets
- Theme management
- Platform integration
TUI implementation using Ratatui:
- Terminal rendering
- Keyboard input handling
- Buffer visualization
- Status displays
Scripting engine:
- Lua runtime management
- Script API
- Sandboxing
- Resource limits
Plugin system:
- Plugin loading
- API definitions
- IPC communication
- Resource management
All components communicate through events, enabling:
- Loose coupling between modules
- Easy testing and mocking
- Plugin integration points
- Async processing
User actions and script commands use command pattern:
- Undoable operations
- Command queuing
- Rate limiting
- Validation
State changes notify observers:
- UI updates
- Plugin notifications
- Logging
- Persistence
Pluggable algorithms for:
- Authentication methods
- Encoding strategies
- Connection methods
- UI rendering
- TLS by default
- Certificate validation
- Certificate pinning support
- SASL authentication
- Sandboxed execution
- Resource limits
- Permission system
- No direct file/network access
- Process isolation (future)
- Capability-based permissions
- Signed plugins (future)
- Resource quotas
- Lazy loading of history
- Virtual scrolling
- Buffer size limits
- Message compression
- Async I/O throughout
- Work stealing scheduler
- Parser optimization
- Batch processing
- Connection pooling
- Message batching
- Compression support
- Smart reconnection
Plugins can hook into:
- Pre/post message processing
- State changes
- UI events
- Network events
Extensions can register:
- Slash commands
- Aliases
- Keyboard shortcuts
- Context menu items
Plugins can:
- Add custom widgets
- Create dialogs
- Modify themes
- Add status indicators
- Default values
- System configuration
- User configuration
- Runtime overrides
- TOML files
- Environment variables
- Command-line arguments
- UI preferences
- Individual component testing
- Mock implementations
- Property-based testing
- Fuzzing
- Multi-component interaction
- Protocol compliance
- Network simulation
- Plugin integration
- Load testing
- Memory profiling
- Latency measurement
- Throughput benchmarks
- Web UI support
- Mobile companion app
- Cloud synchronization
- Voice/video integration
- Clustering support
- Distributed state
- Load balancing
- Horizontal scaling
- WASM compilation
- Mobile platforms
- Embedded systems
- Cloud deployment