Overview
The SS Integrated Management Server is a distributed system that bridges Discord, osu! Bancho IRC, and a PostgreSQL database to provide automated tournament management. The system orchestrates match automation, scheduling, and real-time communication between multiple platforms.Core Components
The system is built on four primary architectural pillars:Discord Manager
The DiscordManager (Discord/DiscordManager.cs:15) serves as the central orchestrator that:- Manages the Discord bot lifecycle and slash command registration
- Creates and manages per-match Discord threads for communication
- Bridges messages between Discord and Bancho IRC lobbies
- Spawns and tracks AutoRef instances for active matches
- Maintains concurrent dictionaries of active channels and matches
Each match gets its own dedicated Discord thread and AutoRef worker instance, ensuring isolation and independent state management.
AutoRef System
The AutoRef automation engine implements theIAutoRef interface and comes in two flavors:
Qualifier AutoRef
Manages linear mappool progression with automatic map loading and timer management
Elimination AutoRef
Handles complex pick/ban phases, timeouts, and match point detection
- Connect to Bancho IRC using referee credentials
- Parse BanchoBot messages to drive state machines
- Execute commands automatically (
!mp map,!mp start, etc.) - Relay all lobby activity to Discord threads
- Persist match state to the database
Database Layer
Built on Entity Framework Core with PostgreSQL, the database stores:- Match schedules and configurations (
MatchRoom,QualifierRoom) - Tournament rounds with mappools and rules (
Round) - User and player registration data (
User,OsuUser,Player) - Referee credentials for IRC authentication (
RefereeInfo) - Match results and score history (
ScoreResults)
Bancho IRC Client
The system uses BanchoSharp to communicate with osu! servers:- Authenticates referees via IRC credentials
- Creates tournament lobbies with
MakeTournamentLobbyAsync - Sends multiplayer commands to control match flow
- Listens for BanchoBot events to detect state changes
- Parses score results from match completion messages
Technology Stack
Runtime & Framework
Runtime & Framework
- .NET 9: Modern C# runtime with performance optimizations
- Async/Await: Fully asynchronous I/O for concurrent match handling
Discord Integration
Discord Integration
- Discord.Net: Discord API wrapper with interaction service
- Slash Commands: Modern Discord command registration
- Thread Management: Per-match isolated communication channels
osu! Integration
osu! Integration
- BanchoSharp: IRC client library for osu! Bancho
- Tournament Lobby API:
!mpcommand automation - Score Parsing: Regex-based result extraction
Data Persistence
Data Persistence
- PostgreSQL: Relational database for tournament data
- Entity Framework Core: ORM with LINQ query support
- JSON Columns: Flexible storage for picks, bans, and mappools
Data Flow for Matches
Here’s how a typical match flows through the system:Key Flow Stages
- Initialization: Referee triggers match start via Discord slash command
- Environment Setup: DiscordManager loads DB config and spawns AutoRef worker
- IRC Connection: AutoRef authenticates and creates tournament lobby
- Automation Loop: State machine responds to BanchoBot events and team input
- Score Processing: Results are parsed from IRC and relayed to Discord
- Persistence: Final match state is saved to database on closure
Communication Patterns
Discord → IRC Bridge
Messages sent in a match’s Discord thread are forwarded to the Bancho lobby:IRC → Discord Bridge
All lobby activity is streamed to Discord in real-time:Concurrency Model
The system handles multiple simultaneous matches using:- ConcurrentDictionary: Thread-safe storage for active matches
- Independent AutoRef Workers: Each match runs in its own async context
- Per-Match IRC Connections: Separate BanchoSharp clients per referee
- Fire-and-Forget Tasks: Non-blocking message relay with
Task.Run
The server can manage dozens of concurrent matches without interference, as each AutoRef maintains isolated state.
Entry Point
The application starts in Program.cs:16:Next Steps
Database Schema
Explore entity relationships and data models
Automation Overview
Learn how state machines drive match automation