Back to home
The Project Repository
https://github.com/kc319/TerraDemo
Code and Resources
Unique User Session ID
- Each time a user starts a session by going to the website in their browser, a unique session ID is created and passed within the states of the React DOM
- This ID is created using a sha256 Hash, using the Current time and a random perturbed string as a key, meaning 2 users would have to access the website at the exact same second ( very unlikely ) and be given the exact same random string, to have the same ID. This is quite impossible
- The use of a Hashing ID is to anonymise their userID and the connected wearables on the database, IN CASE of a breach or leak, instead of having a simple 0-x ID created based on the number of registered users, and to provide users with privacy guarantees
User Suggestions
- Our Suggestions engine automatically finds correlations and relations between different data sets from different wearables.
- The available data sets are stores in DashboardMoz class state, and passed to the General Suggestions file
- Here, we use a large match case statement, to output different suggestions based on the type of suggestion we want to provide
- Then based on the available datasets, we can detect average/outlier trends in the user’s health data, based on scientific knowledge of the human body, to generate meaningful suggestions back to the main Dashboard Class, where they are outputted on the page
Change Main Page Graph Time Scales
- By default, all Dashboard Cards display data with a timescale of 30 days
- However, using the 3 dot drop down menu on each dashboard card, we can change the timescale to 1 week, 1 month, or 3 months
- Users can use this to get a better understanding of their recent health data, or a larger scale understanding over a bigger range
Connect wearable accounts to unique user session
- On Guest login, or upon clicking the terra widget icon on the sidebar, users will be taken to a new browser page with the Terra Widget
- Here they can login and connect any of their wearable accounts to their current session
- On successful closing of the window, a delete signal is sent to the backend, to delete the users unique session id
Selective Data Requests Based On Missing Dates
- Since the user could potentially request data from various time periods it would be inefficient to ask Terra for data we already have stored in our database.
- This function finds the dates for which we do not have data and only requests these from Terra.
Using Express’s Router To Divide Code
- Express has an in-built router package that allowed us to reduce the code in the main app.js file and separate it into different files depending on the purpose of each particular route.
- These routes deal with different frontend concerns such as anything to do with the user.
Setting Up MongoDB
- A global mongo object is setup before the server is launched that can be used for any connection to the database.
- It requires a key not provided in the source repository.
Terra Integration
React App (frontend):
Authentication Setup
NodeJS Tutorial
MongoDB
Tailwind Dashboard
Habitdash Dashboard (Competitor)
Leaflet & Poster Design:
Heart Rate Health Analysis:
Nutrition Guidelines:
- [https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/618167/government_dietary_recommendations.pdf] (https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/618167/government_dietary_recommendations.pdf)
React Component LifeCycle:
React Rendering
Learning React Techniques and Rules
React Hooks:
React UseState Hooks:
React Router:
Express: