Design a fitness tracking app
MetaSoftware Engineer · Online AssessmentLast updated
This problem tests your ability to design a scalable backend for a fitness tracking application, focusing on high-frequency sensor data ingestion, geospatial route storage, and efficient retrieval of historical user activities.
Design a Fitness Tracking App
Design a backend system for a mobile fitness app that allows users to record workouts (e.g., running, cycling). The system should support tracking live GPS coordinates, calculating workout metrics (duration, distance, pace), and retrieving historical workout summaries.
Functional Requirements
- Users can start, pause, and stop a workout.
- The system records GPS coordinates (latitude, longitude, timestamp) at a high frequency (e.g., every 1–2 seconds).
- Users can view a list of their past workouts with summary statistics.
- Users can view a detailed map of their route for a specific completed workout.
Non-Functional Requirements
- Handle 1 million concurrent active workouts.
- Low latency for live workout updates.
- High availability and eventual consistency for historical data.
- Secure user data access and privacy controls.
Expected Output
- API Design: Define the primary endpoints for starting, updating, and finishing workouts, and fetching history.
- Data Model: Propose a schema for users, workouts, and the stream of geospatial coordinate points.
- Storage Strategy: Explain the choice of databases (e.g., NoSQL vs. RDBMS, time-series, or geospatial-specific indexes).
- Architecture: Describe the ingestion pipeline, caching layers, and how you would handle massive write throughput during active workout sessions.
Hints
Hint 1
Consider the difference in storage needs between summary metadata (e.g., total duration) and raw coordinate streams.
Hint 2
Think about how you would partition data to support millions of concurrent users writing updates simultaneously.
Hint 3
Evaluate if a single database technology can handle both the high-velocity write requirements of GPS points and the complex query requirements of user history.
Follow-up questions
- How would you optimize the storage of coordinate points to reduce costs without significantly losing accuracy for route visualization?
- If we wanted to implement a 'live leaderboards' feature for running challenges, how would you change your architecture to support real-time aggregation?
- How would you ensure that a user's location data is kept private and only accessible by authorized users or services?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.