You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A production-grade real-time data pipeline that ingests high-throughput e-commerce clickstream events (5,000+ events/sec), processes them through windowed aggregations, and serves a live analytics dashboard. Built to demonstrate distributed systems concepts: consumer-group fault tolerance, partitioned message processing, backpressure handling, and dead-letter queues.
Windowed Aggregations — Rolling 1-minute, 5-minute, and 15-minute windows computing event counts, top products, category breakdown, revenue, region/device distribution
Consumer-Group Fault Tolerance — Two consumer replicas in the same Kafka consumer group; if one crashes, the other picks up partitions with no data loss
Dead-Letter Queue — Malformed events (missing required fields) are routed to a separate Kafka topic for inspection instead of crashing the pipeline
Dual Storage — Redis for sub-second real-time queries (hot path) + PostgreSQL for historical batch analytics (cold path)
Live Dashboard — Next.js + Recharts frontend polling the FastAPI backend every 2 seconds with area charts, bar charts, pie charts, KPI cards, and consumer health monitoring
8GB+ RAM recommended (Kafka + ZooKeeper are memory-hungry)
Run Everything
# Clone the repo
git clone https://github.com/RohanMukka/StreamSense.git
cd StreamSense
# Start all services
docker compose up --build
# The following services will be available:# Dashboard: http://localhost:3000# API: http://localhost:8000# API Docs: http://localhost:8000/docs# Kafka: localhost:9092# Schema Registry: http://localhost:8081# Redis: localhost:6379# PostgreSQL: localhost:5432
GET /api/metrics/timeseries?window=1m&metric=event_type&periods=30
Time-series for charts
GET /api/consumers
Consumer group health and heartbeats
GET /api/kafka/stats
Kafka topic and partition info
GET /api/dlq?limit=50
Dead-letter queue events
GET /api/metrics/historical?window=1m&metric_name=event_type
Historical aggregations from PostgreSQL
Testing Fault Tolerance
# Kill one consumer — watch the other pick up its partitions
docker stop ss-consumer-replica
# Check consumer health endpoint
curl http://localhost:8000/api/consumers
# Restart the consumer
docker start ss-consumer-replica
Design Decisions & Trade-offs
Decision
Rationale
At-least-once delivery
Simpler than exactly-once; idempotent aggregation (counters) handles duplicates gracefully. For financial systems, exactly-once via transactions would be required.
6 Kafka partitions
Balances parallelism with resource constraints. In production, partition count = max consumer parallelism. Would scale to 12-24 for 50k+ events/sec.
Horizontal consumer scaling: Add more consumer instances to the same group — Kafka rebalances partitions automatically
Producer throughput: Current ~5k events/sec is CPU-bound on synthetic generation. Real producers with pre-built payloads can push 50k+/sec per instance
Dashboard scaling: Next.js is stateless — deploy behind a load balancer with any number of replicas
Redis → Redis Cluster: For >100k counters, switch to Redis Cluster with hash-slot-based sharding
PostgreSQL → TimescaleDB: For time-series queries at scale, hypertables with automated partitioning