Although a full-fetched Fitness Tracking application would be able to do lots of different things, we'll concentrate on it's core functionality:
We'll need a storage for users, users' goals and users' workouts.
Assuming, 10k DAU at the start and up to 50k DAU in a year we can roughly estimate our storage requirements:
In total we'll need very modest 3*10^4 * 6*10^4 B = ~2 * GB of storage for the first year.
We'll need the following API in the system:
POST v1/goals/new - returns a status code and some metadata (id,
{
id: string,
user: string,
type: string,
created_at: timestamp
}
GET v1/goals/user/{user_id} - returns paginated set of a user's workouts
{}
POST v1/workouts/start - return a workout id
{
user: string,
started_at: timestamp
type: string
}
POST v1/workouts/{id}/readings - returns a status code
{
heart_rate: int,
coordinates:
...
}
POST v1/workouts/{id}/finish - returns a status code and some metadata
{
finished_at: timestamp
}
POST v1/workouts/new - returns a status code and some metadata
{
user: string,
type: string,
indicators: [ind1, ind2, ... ]
started_at:
}
GET v1/workouts/user/{id} - returns a paginated set of a user's workouts
We'll have a NoSql storage for all our entities, since we don't need strict consistency guarantees or relational queries. And also we can anticipate changes in the schemas, since we're in the early stages of development of our app.
We'll store the following entities:
Goal - supports only goals for a desired number of workouts per week
{
id: string,
user: string,
type: string,
target_value: int
}
Workout
{
id: string,
user: string,
duration: int,
indicators: [ind1, ...]
start: timestamp,
end: timestamp
}
We'll need the following indices:
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?