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_id | unsigned integer | foreign key referencing `sessions.id` | | user_id | unsigned integer | foreign key referencing `users.id` | | sleep_duration | unsigned integer | | | average_mood | float | | ## API Endpoints - `POST /api/auth/register` - add a new user - `POST /api/auth/login` - login with user/password - `GET /api/users/:id` - fetch a user - `PUT /api/users/:id` - update a user - `DELETE /api/users/:id` - delete a user - `GET /api/users/:id/sessions` - fetch list of all sessions by user id - `POST /api/users/sessions` - add a session - `PUT /api/users/sessions/:id` - update a session by id - `DELETE /api/users/sessions/:id` - delete a session by id - `GET /api/users/:id/dailyaverages` - fetch a list of last 30 daily averages by user id