How rdavydov/twitch-channel-points-miner-v2 works
Main system components
a. Entry-point script:
• run.py / example.py – instantiates TwitchChannelPointsMiner and kicks off mine() or analytics()
b. Core library (TwitchChannelPointsMiner package):
• Engine: orchestrates sessions, loops through streamers, applies priority and settings
• Event manager: reacts to “streamer online/offline,” bonus claim, drops, streaks, raids, predictions
• Entities & domain classes: Streamer, EventPrediction, BetSettings, CommunityGoal, Drop, Campaign, Message, etc.
• Connectors:
– TwitchLogin (HTTP login, cookies)
– TwitchWebSocket (IRC chat & PubSub for events)
– WebSocketsPool (shared socket handling)
• Notification adapters: Discord, Telegram, Matrix, Gotify, Pushover, Generic Webhook
c. Analytics web server:
• AnalyticsServer (Flask) reads JSON from analytics folder
• Static assets (assets/*.html, script.js, style.css) render point-trend charts
d. Infrastructure & storage:
• Local volumes: cookies/, logs/, analytics/
• Docker container (Dockerfile + docker-compose example)
• CI/CD workflows (.github/workflows)
External dependencies & integrations
• Twitch platform:
– HTTP API (login, fetch drops, moments)
– WebSocket/IRC for chat and PubSub topics (predictions, raids)
• Third-party notification services:
Discord webhook URL
Telegram Bot API
Matrix homeserver
Gotify endpoint
Pushover API
Generic Webhook endpoints
Relationships & data flows
a. run.py triggers the Engine → Core library
b. Engine uses TwitchLogin to authenticate → writes cookie to cookies/
c. Engine opens TwitchWebSocket → listens for channel-points events
d. Event manager applies settings (StreamerSettings, BetSettings) → executes actions via WebSocket or HTTP
e. Outcomes: points earned → logged by Logger → stored in logs/
f. If analytics enabled: Engine writes point events to analytics/*.json → AnalyticsServer reads them → serves charts via static assets
g. Notification adapters subscribe to Engine events → push messages to external services
Architectural patterns
• Modular library design: separation between core logic, domain entities, connectors, and adapters
• Plugin/adaptor pattern for notifications – easily extendable
• Priority-driven event loop (two concurrent streams max per Twitch limit)
• MVC-like pattern for analytics UI: Flask (“Controller”), analytics JSON (“Model”), assets+chart.js (“View”)
Diagramming conventions
– Ovals for entry-point/run.py and end-user
– Rectangles for modules/packages
– Core engine & entities (blue)
– External services & APIs (green)
– Storage volumes (orange)
– UI/web server (purple)