Write path: Logging workouts
/log API takes a workout description and persists it to the database - returns workout ID
/history shows workouts for a user, optional time frame parameters, workout type parameters
/stats shows statistics for workouts (how frequently you've worked out in the last 30 days, average workout duration, etc)
API Gateway for userauthentication, in front of k8s microservices
Workout service - this service ingests workout descriptions from authenticated users and persists them to a SQL database.
Stats service - background chron processor which periodically computes statistics for workouts
History service - hosts API for history API showing a users historical workouts over the last 30days
Workout Type ( name -> PK)
Workouts ( id -> PK , user -> FK, workout_type-> FK, duration INTERVAL, distance int, time timestamp)
Stats(id->PK, user->FK, stats jsonb, time timestamp, type varchar)
Workout service -> synchronous API which ingests details about a workout for an authenticated user. Workout type (run/swim/jumprope/walk etc) , distance, and duration etc .
Generates a UUID, for workout ID , persists to database as a synchrnous HTTP API
Stats service -> Periodically generates summary statistics for a user. On some period like 24 hours, check if a user does not have statistics generated in the last 24 hours, and generate new statistics looking back 24, 7, and 30 days which are persisted to the database.