Designing a social feed

Mobile system design Senior Kotlin 2.0+ API 24+ Reviewed By Best Latest Apps

Pick the fix

Users see duplicate posts while scrolling a busy feed. Pagination uses ?page=3. Fix?

Options
Hint 1 of 1

What happens to page 3 when 5 new posts arrive?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Switch to cursor-based pagination with a 'next' token from the server

Correct. New posts no longer shift items into the next page.

Why not the others?
  • B Remove duplicates by text. Different posts can share text.
  • C Load smaller pages. Still shifts.
  • D Disable pull-to-refresh. Doesn't stop shifting.

30-second answer

Fetch pages with cursor-based pagination through Paging 3 and a RemoteMediator that stores pages in Room, so the feed opens instantly from cache. Render with a LazyColumn using stable keys and content types. Load images with a library that downsamples and caches. Likes update optimistically in the database, then sync; roll back on failure. Pull-to-refresh replaces the first page.

Practise saying it · 45 s. No recording, just a timer

Design a social feed.

Say your answer out loud, then check which of these points you covered:

  • Paging 3 + RemoteMediator + Room
  • Cursor pagination
  • Stable keys
  • Image downsampling
  • Optimistic likes

Deep dive

Cursors avoid duplicates and gaps when new posts arrive; offsets don't.

Prefetch the next page before the user reaches the end.

Keep item models small and immutable so Compose can skip.

Track impressions with visibility, not just composition.

Common mistakes

  • Offset pagination on a live feed.
  • Full-size images in thumbnails.
  • Waiting for the server before showing a like.

Senior take & follow-ups

Cover paging, caching, rendering, images and optimistic actions in that order.

Follow-up questions

Think of your answer first, then open the hint.

  1. Why cursor pagination?

    Show hint

    New posts at the top don't shift page boundaries.

  2. How do you roll back an optimistic like?

    Show hint

    Revert the local row if the request fails and show a message.

Compare on iOS: Designing an infinite-scroll social feed The same design with different list and paging APIs.

Suggest a fix if something here is wrong or out of date.