How antonbsa/twitch-radar works
Twitch Radar is a mobile-first PWA for receiving alerts when followed Twitch broadcasters switch into selected categories. A viewer signs in, chooses followed channels and category preferences, and registers a push endpoint; the API synchronizes Twitch data and EventSub subscriptions, then processes verified stream events and delivers matching alerts. The graph also captures account/language settings and snoozes. Source excerpts establish the webhook queue handoff and browser push behavior; some service-to-service wiring is represented only where the repository structure or README supports it.
Main entry points: schema.ts D1 database · index.ts API worker · api.ts API client · service-worker.js Push worker
Components 26
Viewer PWA
- PWA routes
apps/web/src/App.tsx - API client
apps/web/src/lib/api.ts - Channel settings
apps/web/src/routes/channels.tsx - Alert settings
apps/web/src/routes/alerts.tsx - Account settings
apps/web/src/routes/account.tsx - Push worker
apps/web/public/service-worker.js
API and identity
- API worker
apps/api/src/index.ts - OAuth routes
apps/api/src/http/routes/auth.ts - Session service
apps/api/src/services/session.ts - Channel routes
apps/api/src/http/routes/channels.ts - Preference routes
apps/api/src/http/routes/preferences.ts - Push routes
apps/api/src/http/routes/push-subscriptions.ts
Stream tracking
- Twitch sync
apps/api/src/services/twitch/sync.ts - EventSub manager
apps/api/src/services/eventsub/reconcile.ts - EventSub webhook
apps/api/src/http/routes/webhooks.ts - Event processor
apps/api/src/services/eventsub/process.ts
Alert delivery
- Preference matcher
apps/api/src/services/notifications/match.ts - Push delivery
apps/api/src/services/notifications/deliver.ts - Snooze handling
apps/api/src/services/notifications/snooze-sweep.ts
Persistent state
- Event queue
- D1 database
apps/api/src/db/schema.ts - Cloudflare KV
apps/api/src/services/session.ts
Other components
- Viewer
- Twitch
- Web Push service
- Browser push
Connections 38
- Viewer → PWA routes: uses
- PWA routes → API client: requests
- Channel settings → API client: loads and saves
- Alert settings → API client: loads and saves
- Account settings → API client: manages account
- API client → API worker: HTTP requests
- API worker → OAuth routes: dispatches
- API worker → Channel routes: dispatches
- API worker → Preference routes: dispatches
- API worker → Push routes: dispatches
- OAuth routes → Twitch: OAuth requests
- OAuth routes → Session service: creates sessions
- Session service → Cloudflare KV: reads and writes
- Channel routes → Twitch sync: syncs follows
- Twitch sync → Twitch: fetches Twitch data
- Channel routes → D1 database: reads and writes
- Preference routes → D1 database: reads and writes
- Push routes → D1 database: stores subscriptions
- Push routes → Push worker: provides push setup
- Twitch sync → EventSub manager: reconciles subscriptions
- EventSub manager → Twitch: manages subscriptions
- Twitch → EventSub webhook: sends events
- EventSub webhook → Event queue: enqueues events
- EventSub webhook → D1 database: updates subscription state
- Event queue → Event processor: dispatches events
- Event processor → D1 database: checks and records events
- Event processor → Preference matcher: matches changes
- Preference matcher → D1 database: reads preferences
- Event processor → Push delivery: requests delivery
- Push delivery → D1 database: records deliveries
- Push delivery → Web Push service: sends notification
- Web Push service → Browser push: delivers push
- Browser push → Push worker: dispatches push
- Push worker → Viewer: shows alert
- Viewer → Push worker: requests snooze
- Push worker → API client: posts snooze
- API worker → Snooze handling: dispatches snooze work
- Snooze handling → D1 database: reads and writes