Daily iOS
iOS system design

Comment feed page

Design the comment feed page for a community app. Constraints: comments are shown flat (no tree), globally sorted by an interaction weight (likes, reply count), and the first screen loads automatically. Given that the sort criterion keeps changing, how would you design the server data structure and the pagination?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

The server stores a computed score per comment and provides keyset cursor pagination over a (score DESC, id DESC) composite index. On the client, a CommentStore merges pages by id, the first screen loads automatically in a task, and the UI uses a compositional layout plus diffable source to update only changed items.

Share a question