Real-Time Retail Analytics Platform
Streaming 1M+ store and e-commerce events an hour into BigQuery with sub-minute freshness.
- Multi-brand retail group (NDA)
- Client
- Data Engineer — pipeline design and build
- My role
- 2025 · 7 months
- Timeline
- 4 engineers, 1 analyst
- Team
- Event-to-dashboard latency
- <60s
- Events per hour at peak
- 1.2M
- Lower BigQuery cost
- 38%
- Pipeline uptime
- 99.9%
Architecture
How the system fits together
- 1
Sources
- POS terminals
- E-commerce webhooks
- Inventory CDC
- 2
Ingest
- Pub/Sub topics
- Schema validation on Cloud Run
- 3
Process
- Dataflow (Apache Beam)
- Windowed aggregations
- Dead-letter queue
- 4
Store
- BigQuery — partitioned & clustered
- Cloud Storage archive
- 5
Serve
- Looker Studio
- Next.js ops console
- Freshness alerts
Context
The situation
The client runs more than 300 stores and a busy online shop. Sales and stock reports came from nightly batch jobs, so regional managers made pricing and replenishment decisions on yesterday's numbers.
Challenge
What made it hard
- Daily batch reports meant stock-outs were spotted a full day late.
- Traffic spiked 8× during sale events and the existing jobs could not keep up.
- Offline POS terminals sent duplicate and late events that skewed totals.
- Analysts ran expensive full-table scans on one huge, unpartitioned table.
Approach
Key decisions and trade-offs
- 01
Event contracts first
Defined versioned schemas for every event type and validated them at the edge. Bad records go to a dead-letter topic for replay instead of being silently dropped.
- 02
Correct totals, even when data is late
Used Beam's event-time windows with allowed lateness and de-duplicated on a deterministic event ID, so terminals that reconnect hours later still land in the right window.
- 03
Model for the query, not the source
Partitioned fact tables by event date and clustered them by store and product. Materialized views pre-compute the five most-used dashboard queries.
- 04
Run it like a product
Added freshness and volume SLOs in Cloud Monitoring with on-call alerts, plus a one-command replay from the Cloud Storage archive.
Results
The impact
- Dashboards refresh in under a minute instead of the next morning.
- Absorbed an 8× sale-day traffic spike through autoscaling with no data loss.
- Cut query costs by about 38% with partitioning, clustering and materialized views.
- Regional teams now act on low-stock alerts the same day.