Data Flow: Twitch 2K Wager
Data Flow: Twitch 2K Wager
Diagram
Components
| Component | Purpose | Notes |
|---|---|---|
| Viewer (Twitch) | End user watching Marcus's stream | Clicks link in stream description. May be on mobile. |
| Website (playme2k) | SvelteKit app handling auth, payment, status | playme2k.tail5b443a.ts.net. Server routes handle webhooks + admin. |
| Keycloak | Identity broker — Twitch OAuth mediation | Realm: twitch-2k-wager. Twitch IdP. Handles session + token refresh. |
| Twitch API | OAuth provider | Scopes: user:read:email. Returns twitch_id, username, email. |
| Stripe | Payment + Connect payouts | Checkout for buy-ins. Connect Express for winner payouts. Webhooks for both. |
| Postgres | Game state persistence | Shared CNPG cluster. Stores challengers, games, payments, payouts, revenue splits. |
| Operator (Lucas) | Manually declares game results | Admin endpoint. No automation for result determination. |
Key Decisions
- Keycloak brokers Twitch OAuth — app never touches raw OAuth. Standard OIDC session.
- Stripe Connect Express with deferred onboarding — challenger KYCs only after winning. First win triggers onboarding. Repeat winners skip it.
- Two webhook flows — checkout.session.completed (payment) and account.updated (Connect onboarding). Both hit the same webhook endpoint.
- Manual result declaration — operator calls admin endpoint. Simple and reliable.
- Tiered buy-in selection — $15/$30/$45. Stored in Stripe metadata and DB.
Related
- arch-domain-twitch-2k-wager — entity model
- arch-deployment-twitch-2k-wager — where it runs
- project-twitch-2k-wager — project page