E-Commerce

A fashion e-commerce site with 800K monthly active users wants to show 'Customers also viewed' recommendations that update with every click — not stale suggestions from last night's batch job. During flash sales, browsing patterns shift within minutes.

The nightly collaborative filtering job means recommendations during a 2PM flash sale still reflect yesterday's browsing patterns. Conversion rate drops 23% compared to normal hours.
LIVEclickstream
event_idsession_iduser_idproduct_idproduct_namecategoryactionts
evt_8a3f21sess_a8f2kusr_29481SKU-LB-1093Oversized Linen Blazerouterwearview2024-03-15T14:01:12.000Z
evt_8a3f22sess_a8f2kusr_29481SKU-WL-2847Wide-Leg Linen Trousersbottomsview2024-03-15T14:01:48.000Z
evt_8a3f23sess_a8f2kusr_29481SKU-CT-0412Canvas Mini Totebagsadd_to_cart2024-03-15T14:02:05.000Z
evt_7b2e10sess_p3n7xusr_10332SKU-WL-2847Wide-Leg Linen Trousersbottomsview2024-03-15T14:02:22.000Z
evt_7b2e11sess_p3n7xusr_10332SKU-LB-1093Oversized Linen Blazerouterwearview2024-03-15T14:02:54.000Z
evt_7b2e12sess_p3n7xusr_10332SKU-RT-5531Ribbed Tank Toptopspurchase2024-03-15T14:03:17.000Z
Streaming SQLRunning
Build real-time co-view graph
CREATE MATERIALIZED VIEW co_view_pairs AS
WITH session_views AS (
  SELECT
    session_id,
    product_id,
    product_name
  FROM clickstream
  WHERE action = 'view'
    AND ts > NOW() - INTERVAL '30 MINUTES'
)
SELECT
  a.product_id AS product_a,
  a.product_name AS product_a_name,
  b.product_id AS product_b,
  b.product_name AS product_b_name,
  COUNT(DISTINCT a.session_id) AS co_view_count
FROM session_views a
JOIN session_views b
  ON a.session_id = b.session_id
  AND a.product_id < b.product_id
GROUP BY a.product_id, a.product_name, b.product_id, b.product_name
HAVING COUNT(DISTINCT a.session_id) >= 3;
Compute trending recommendations per category
trending_by_categoryauto-updating
categoryrankproduct_nameengagement_scoreview_countcart_addswindow_start
bottoms1Wide-Leg Linen Trousers11212024-03-15T14:00:00.000Z
outerwear1Oversized Linen Blazer2202024-03-15T14:00:00.000Z
bags1Canvas Mini Tote3012024-03-15T14:00:00.000Z
tops1Ribbed Tank Top5002024-03-15T14:00:00.000Z
denim1High-Rise Straight Jeans2002024-03-15T14:00:00.000Z
User session sess_a8f2k browses a linen blazer and immediately sees 'Trending now: wide-leg trousers, canvas tote' — items that started trending 4 minutes ago when the flash sale went live.
Best-in-Class Event Streaming
for Agents, Apps, and Analytics
GitHubXLinkedInSlackYouTube
Sign up for our to stay updated.