System Overview
Android Application Design
The Android application contained five activities and one Sense Manager Service. The five activities included Register Activity, Profile Activity, Exercise Select Activity, Device Picker Activity and Do Exercise Activity. The sense manager service managed one WICED Sense at one time. In the Android application, AsyncTask was used to handle HTTP connection to the AWS EC2 server.
When a user launched the Android application, Register Activity would be created. In this activity, user could register a new account or log in his/her own account. If the user logged in the account, his/her email and password would be stored in Shared Preference for HTTP connection verification. After logging in, Profile Activity would be created. This activity included four fragments, separately showing the user’s exercise history, the times and weights of his/her ten most recent exercises, similar user suggestions, and exercise recommendations based on his/her exercise history. If user wanted to start exercising, he/she could click on the floating button or the recommendation exercise fragment to start Exercise Selected Activity. This is a ListActivity and the user could choose the exercise he/she wanted to do in this activity, and then Do Exercise Activity would be created.
When a user launched the Android application, Register Activity would be created. In this activity, user could register a new account or log in his/her own account. If the user logged in the account, his/her email and password would be stored in Shared Preference for HTTP connection verification. After logging in, Profile Activity would be created. This activity included four fragments, separately showing the user’s exercise history, the times and weights of his/her ten most recent exercises, similar user suggestions, and exercise recommendations based on his/her exercise history. If user wanted to start exercising, he/she could click on the floating button or the recommendation exercise fragment to start Exercise Selected Activity. This is a ListActivity and the user could choose the exercise he/she wanted to do in this activity, and then Do Exercise Activity would be created.
The Android application collected data from WICED Sense through Bluetooth connection. Before doing exercise, the user should choose WICED Sense kit and attached the device on corresponding exercise machine. If the user was prepared to do exercise, he/she could click on the start button to start Sense Manager Service. The service could enable Bluetooth connection with WICED Sense, and get raw data per 100 milliseconds. Sensor Data Parser class provided function to read acceleration and gyroscope data from raw data. Moreover, DSP methods was used to preprocess this real-time data and count times during every exercise as discussed in Detailed Description. The App view was updated when each count was detected and processed. After finish exercising, the exercise data would be posted to the AWS EC2 server.
Web Server Design
Database Design
User data were stored in 5 tables: User, Post, Role, Comment and Follow. As shown in the figure on the left, User table contained the personal information of each user, included email, username, password hash, etc. The summary and recommendation fields were generated by machine learning algorithm. The followed-follower relationship is a many-to-many self-referential relationship that can be decomposed into two one-to-many relationships from each of the original User table to the association table, namely, the Follow table. The Role table manages the permissions of different sorts of user. Each role had a one-to-many relationship with the id field in user table. The post and comment table contained the one-to-many relationship from the user table.
|
API versioning
Login functionality for normal web application (web browser) implemented with the help of Flask-Login stores data in the user session, which Flask stores by default in a client-side cookie. For the non-browser client (Android), HTTP authentication is used to send credentials. With HTTP authentication, user credentials are included in an Authorization header with all requests. The Flask-HTTPAuth extension provides a convenient wrapper that hides the protocol details in a decorator. The authentication callback saves the authenticated user in Flask’s g global object so that the view function can access it later. Furthermore, to avoid having to constantly transfer sensitive information, a token-based authentication solution had been offered. Instead of rendering HTML template, JSON formatted data had been applied in the HTTP response for a better performance of Android App.
Frontend Templates |
All templates inherited bootstrap/base.html from Flask-Bootstrap, which provides a skeleton web page that includes all the Bootstrap CSS and JavaScript files. User weekly activity summary displayed by using the Google pie chart.