KatInterview

Design an Activity Recording and Social Feed Service

System DesignModel answer
MediumModel answerSystem Designmobile-firstoffline-syncsocial-feed

Last updated

Build a mobile service that captures GPS workouts offline, uploads them reliably, and powers a social feed of followers' activities.

You're designing a mobile application for endurance athletes. The app records workouts—running, cycling, and similar activities—using the device's GPS sensor. During a workout, the athlete sees real-time metrics: elapsed time, distance covered, and current pace. When they finish, they save the workout with a name and activity type, and it becomes part of their profile, complete with a map trace and summary stats.

Athletes can follow each other. Each athlete has a personal feed showing recent workouts from the people they follow, where they can react with kudos or post comments.

Your task is to design the end-to-end system: how GPS data flows from the phone to permanent storage, how workouts are stored and displayed, and how the social feed is built and served.

What's In Scope

  • Recording workflow: start, pause, resume, stop
  • Live statistics displayed on the device during the workout
  • Saving and uploading a completed workout
  • An activity detail page showing the route map and summary metrics
  • A profile page listing an athlete's workout history
  • Following other athletes
  • A home feed displaying recent workouts from followed athletes
  • Kudos (reactions) and comments on workouts

What's Out of Scope

  • Performance leaderboards for route segments
  • Route planning or navigation
  • Group features like clubs
  • Direct messaging between athletes
  • Integration with wearable devices
  • Premium subscriptions

Key Constraints

  1. Offline-first recording: Network connectivity during a workout is unpredictable. The recording must work entirely offline, and the app must reliably upload completed workouts even if it crashes, is closed, or the device restarts.

  2. Idempotent uploads: Uploads may be retried multiple times due to network failures. The system must guarantee that retries never create duplicate workouts.

  3. Privacy enforcement: Each workout has a visibility setting (e.g., public, followers-only, private). No read operation may expose a workout to someone the setting excludes.

  4. Scale assumptions: Before diving into implementation, establish targets for daily active users, workouts recorded per day, and feed requests per second. Consider that usage is bursty—weekend mornings see peak activity.

Questions to Clarify

  • What scale should the design target? How many daily active athletes, workouts uploaded per day, and feed page loads?
  • Is there a live-tracking feature where followers see an athlete's position during the workout, or is sharing only after the workout is saved?
  • What visibility options exist? Should the system hide the start/end of routes near an athlete's home address?
  • How long should raw GPS traces be retained, and at what resolution (one point per second, per meter, etc.)?
  • Should the feed be strictly chronological, or can it use ranking signals?

Hints

Hint 1

The recording layer lives entirely on the device. Design a local storage strategy that survives app termination and ensures exactly-once upload semantics.

Hint 2

GPS traces can be huge—thousands of points per workout. Separate raw location data from the derived summary statistics that most views actually need.

Hint 3

For the social feed, choose between fan-out-on-write and fan-out-on-read. Consider what happens when an athlete has hundreds of thousands of followers.