List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Define what APIs are expected from the system...
startActivity(activityType ActivityType) -> activitySessionId
Records starting of an activity. ActivityType should be an enum indicating the actual activity (e.g. running, jogging, swimming).
API returns a activitySessionId to record the activity.
endActivity(activitySessionId)
Records ending of the activity corresponding to the session id.
setGoal(targetDuration Duration)
Set the daily goal for activity duration.
syncProgress(currentDuration Duration)
Sync the current progress of the user.
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...
The service itself should not be complicated and requires the normal components - client, server and database.
For analytics purposes, there are two additional components. A cron job (or jobs) reading from the database periodically and write to a seperate analytics datastorage.
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...
Client: The client contains not only the UI but also a portion of user data, specifically, the user progress data. To prevent lost of data, the client should sync with server in the following situation: 1. every hour at a certain offset. 2. when user completes an activity, it should call endActivity as well as syncProgress. 3. when a user close the app.
Analytics datastore: The app itself seldom needs to access historical data, therefore, in order to keep database efficient, it should only contains latest 1 year of data. The historical data, however, could be valuable for analytics purposes, therefore, a cron job should fetch them periodically and store all data in this analytics datastore and store them in format that would be more efficient and convenient for analytics purposes.
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
User
id - auto increment, PK
first_name - varchar
last_name - varchar
current_target_id - FK
current_daily_progress - FK
user_daily_target
id - auto increment, PK
user_id - User table FK
daily_target_in_minutes - integer
start_date - date
end_date - date
user_daily_progress
id - auto increment, PK
daily target id - FK
progress_date - date
current_progress_in_minutes - integer
user_activity
id - auto increment, Pk
user_id - FK
started_at - dateTime
last_recorded_at - dateTime
activity_type - enum