# Analytics

The analytics pipeline aggregates video statistics into daily and weekly increments, and exposes them through the dashboard API. All raw stats land in video_statistics; materialized views compute the aggregated data used for charts and tables.


# Key Concepts

  • Raw stats: Every stats fetch inserts a row into video_statistics (views, likes, comments, reposts at that point in time)
  • Increments: Materialized views compute the difference between consecutive stats snapshots to show daily/weekly growth
  • Totals vs increments: The dashboard can show both absolute totals and per-period increments

# Data Flow Summary

RapidAPI fetch (queue-processor)
  ↓
video_statistics (INSERT)
  ↓
mv_video_daily_increments (MV refresh)
  ↓
mv_video_weekly_increments (MV refresh)
  ↓
Dashboard API reads aggregated data

# Related Sections

  • Architecture — Materialized views, refresh schedule
  • Workers — Workers involved in analytics
  • Queues — Queue flows for stats
  • API — Analytics API endpoints