Question
Design a notification batching / digest system that prevents notification spam. Users generate events that notify others (comment, mention, like, assignment); a popular thread can produce hundreds of events for one user in minutes. Instead of 200 separate pushes/emails, the system should intelligently batch ('12 new comments on your post', 'Alice and 5 others mentioned you') with per-user, per-channel preferences (instant vs hourly vs daily) and respect quiet hours and timezones. How do you aggregate, batch, and deliver notifications without spamming users or dropping anything important?
Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.