📊 Detailed Notification Flow Diagram

Complete data flow with decision points, parallel processing, and error handling

← Scroll horizontally to see full diagram →
🏟️
Event Source
Match Venues
Match Event
Chess/Boxing action detected
Generate Event Payload
event_id, type, match_id, timestamp
POST /events/match
HTTPS + Auth Header
~5ms
🚪
API Gateway
Nginx + PHP
Authenticate Request
Validate API Key
Valid?
Yes No → 401
Validate Schema
JSON Schema validation
Rate Limit Check
Sliding window (Redis)
Allowed?
Yes No → 429
~10ms
Cache Layer
Redis Cluster
Check Dedup
SETNX event:{id}
New?
Yes No → Skip
Return 202 Accepted
Async processing begins
~5ms
Dedup Only:
User prefs resolved by workers after queue routing
🐰
Message Queue
RabbitMQ
Publish to Exchange
notification.events (topic)
Topic Routing to Queues
notifications
.web
notifications
.ios
notifications
.android
notifications
.email
~2ms (publish confirm)
Priority Queue:
KO/Checkmate events get high priority for faster delivery
⚙️
Worker Pool
K8s Auto-Scale
Consume Messages
prefetch: 100
Pull from assigned queue
Load User Prefs
GET prefs + tokens
Redis (TTL: 5 min)
Cached?
Yes No → DB
Batch Collection
Collect up to 500 tokens
Batch
Full?
Yes Wait 50ms
Build FCM Payload
title, body, data, tokens[]
Send to Firebase
POST /fcm/send
~50-100ms (batching)
Cache Miss:
Query PostgreSQL → Cache result with 5min TTL
🔥
Delivery
Firebase FCM
Process Multicast
Up to 500 tokens/request
Success?
Parallel Platform Delivery
APNs (iOS)
FCM (Android)
Web Push
~100-300ms
Error Handling:
• Invalid token (400/404) → Remove
• Rate limit (429) → Wait retry-after
• Server error (500) → Backoff 10s+
• Timeout (10s) → Requeue
📱
User Device
Web/iOS/Android
Receive Push
Service Worker / OS Handler
Parse Notification
Extract title, body, data
Display Notification
Native OS notification
Tapped?
Open App / Deep Link
Navigate to match view
~10-50ms
Total E2E:
P50: ~200ms
P95: <500ms
P99: ~800ms

📨 Event Types & Priorities

  • ♟️ Major Piece Captured - Normal priority, standard batching
  • 👑 Check - HIGH priority, elevated delivery
  • 🏆 Checkmate - CRITICAL priority, immediate flush, bypass batch
  • 👊 Power Punch - Normal priority, standard batching
  • 💥 KO / TKO - CRITICAL priority, immediate flush, bypass batch

Batching Strategy

  • 1 Collect messages until 500 tokens or 50ms timeout
  • 2 FCM multicast reduces API calls by 99.8%
  • 3 Critical events (KO) bypass batching for immediate delivery
  • 4 Platform-specific workers enable parallel processing

🔄 Error Recovery Flow (FCM Best Practices)

  • 1 500 errors: Exponential backoff (10s, 20s, 40s min)
  • 2 429 rate limit: Wait for retry-after header (default 60s)
  • 3 400/401/403/404: Do NOT retry, remove invalid tokens
  • 4 Max retries (3x): Move to Dead Letter Queue for analysis
Flow Diagram Symbols
Terminal (Start/End)
Process / Action
Decision Point
Data Store / Cache
Message Queue
Parallel Process

World ChessBoxing Championship - Detailed Notification Flow

Event Ingestion → Queue Routing (RabbitMQ) → Batch Processing (PHP) → Delivery (FCM)

Marvin the Martian
"This technology and infrastructure is better than my Illudium Q-36 Explosive Space Modulator!" ✓ Marvin the Martian Approved