Design click analytics for a URL shortener: record each redirect with timestamp, referrer, user agent, and coarse geo. Support real-time counters and breakdowns by day, country, and referrer for link owners.
Functional requirements
- Record click event on each redirect (async to critical path)
- Dashboard API for totals and time series per short code
- Filter by date range and dimension
- Export aggregated reports (CSV) optional
Non-functional requirements
- Redirect path stays low latency; analytics off critical path
- Privacy: aggregate geo; avoid storing raw IP longer than needed
- High write volume with buffering