How pomdap/twitchteamlivestats works
Project Type and Purpose
• This is a small .NET console application (“TwitchTeamLiveStats”) that uses Twitch’s PubSub API to monitor viewer counts for a list of channels and writes various summary and per-channel files to a local output directory. It’s intended to be run during events or as a team-wide viewer counter (for example, inside OBS via Text (GDI+)).
High-Level Component Analysis
Top-level files and folders:
• Program.cs – application entry point
• appsettings.json – configuration for the TeamSupervisor and TeamWriter
• TwitchTeamLiveStats.csproj / .sln – .NET build artifacts
From the README, the code is organised around two main logical components:
a. TeamSupervisor – subscribes to Twitch PubSub, maintains channel live state and viewer counts, tracks timeouts for stale channels
b. TeamWriter – takes the statistics from the supervisor and writes them into files in the configured output directory
Key External Dependency
• Twitch PubSub API (external service over WebSocket/HTTP)
• Configuration Loader (reads appsettings.json)
• Program (composition root)
• TeamSupervisor
• TeamWriter
• Twitch PubSub Service (external)
• File System (Output Directory)
1. On startup, Program reads Configuration → passes ChannelIds and TimeoutInterval to TeamSupervisor; passes writer settings to TeamWriter.
2. TeamSupervisor establishes a connection to Twitch PubSub Service → subscribes to events for each ChannelId.
3. As messages arrive (viewer counts), TeamSupervisor updates its internal state and emits events or calls into TeamWriter.
4. TeamWriter writes/overwrites files in Output Directory:
– total.viewers, live.channels, total.channels
– {ChannelId}.viewers for each channel
5. File System persists these files for external consumption (e.g., OBS).
c. Architectural patterns / principles:
• Single-responsibility: Supervisor vs. Writer
• Dependency injection in Program.cs to wire Supervisor and Writer with configuration
• Event-driven flow: Supervisor publishes viewer updates → Writer consumes them
• External boundary clearly drawn around the Twitch PubSub service and the local file system
d. Relevant Technologies & Frameworks:
• .NET Console App (C#)
• Microsoft.Extensions.Configuration (for appsettings.json)
• Twitch PubSub WebSocket/HTTP API
• System.IO for file writes