Sleep Tracker helps Users track their sleep and mood every day. It gives Users a better idea of their sleep pattern and improve their health. After one month, Sleep Tracker will give recommendation of optimal sleep duration. ## Target Audience Sleep Tracker is intended for anyone interested in improving their sleep and health. ## Features - Homepage view shows a graph of your nightly hours of sleep over time . - Ability to create a night’s sleep entry. For each date set (1/1/19-1/2/19), user can scroll through a digital clock image (like when you set your alarm on your phone, or just type in) to enter what time they got in bed and what time they woke up. From this data, app will calculate their total time in bed. - Ability to edit or delete a sleep entry. - Ability to click one of four emoji buttons to rate how they felt right when they woke up, how they felt during the day, and how tired they felt when they went to bed. Behind the scenes, a score 1-4 is given for each emoji. - The app will calculate an average mood score for 1/2/19, and compare it to the time spent in bed. The app will then recommend after using for >1 month how much sleep you need. “Your mood score tends to be highest when you sleep 7.5 hours” ## Possible further features - Make recommendations not only based on sleep time, but also on bed time (some reasearch will need to be done in that area) - Connect to third party sleep tracking services ## Database Schemas ### Users Schema `users` | field | data type | metadata | | :--------| :--------------- | :-------------------------------------------------- | | id | unsigned integer | primary key, auto-increments, generated by database | | email | string | required | | username | string | required | | password | string | required | ### Sleep Sessions Schema `sessions` | field | data type | metadata | | :------------ | :--------------- | :-------------------------------------------------- | | id | unsigned integer | primary key, auto-increments, generated by database | | user_id | unsigned integer | foreign key referencing `users.id`, required | | bed_time | unsigned integer | timestamp with date, required | | wake_time | unsigned integer | timestamp with date, required | | bed_tiredness | unsigned integer | | | wake_mood | unsigned integer | | | day_mood | unsigned integer | | ### Average Mood per Sleep Session Schema `dailyAverages` | field | data type | metadata | | :------------- | :--------------- | :-------------------------------------------------- | | id | unsigned integer | primary key, auto-increments, generated by database | | session_user | unsigned integer | foreign key referencing `sessions.user_id` | | session_date | unsigned integer | foreign key referencing `sessions.wake_time` | | sleep_duration | unsigned integer | | | average_mood | float | | ## API Endpoints - `POST /api/users` - add a new user - `GET /api/users/:id` - fetch a user - `PUT /api/users/:id` - update a user - `GET /api/users/:id/sessions` - fetch list of all sessions by user id - `POST /api/users/:id/sessions` - add a session y user id - `GET /api/users/:id/sessions/:id` - fetch a single session by id - `PUT /api/users/:id/sessions/:id` - update a session by id - `DELETE /api/users/:id/sessions/:id` - delete a session by id - `GET /api/dailyaverages/:id` - fetch a list of last 30 daily averages by user id