Tải bản đầy đủ (.pdf) (77 trang)

BUILDING A FITNESS PERSONAL TRAINER APPLICATION

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (2.76 MB, 77 trang )

2019
Ngo Minh Cuong

PROJECT’S NAME: BUILDING A FITNESS PERSONAL TRAINER APPLICATION

THE UNIVERSITY OF DANANG
DANANG UNIVERSITY OF SCIENCE AND TECHNOLOGY
FACULTY OF INFORMATION TECHNOLOGY

GRADUATION PROJECT THESIS
MAJOR: INFORMATION TECHNOLOGY
SPECIALTY: INFORMATION SECURITY

PROJECT TITLE:

BUILDING A FITNESS PERSONAL TRAINER
APPLICATION

Instructor: M.S. PHAN THANH TAO
Student: NGO MINH CUONG
Student ID: 102150087
Class: 15T2

Da Nang, 12/2019


THE UNIVERSITY OF DANANG
DANANG UNIVERSITY OF SCIENCE AND TECHNOLOGY
FACULTY OF INFORMATION TECHNOLOGY

GRADUATION PROJECT THESIS


MAJOR: INFORMATION TECHNOLOGY
SPECIALTY: INFORMATION SECURITY

PROJECT TITLE:

BUILDING A FITNESS PERSONAL TRAINER
APPLICATION

Instructor: M.S. PHAN THANH TAO
Student: NGO MINH CUONG
Student ID: 102150087
Class: 15T2

Da Nang, 12/2019


INSTRUCTOR’S COMMENTS

..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................

..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................


REVIEWER’S COMMENTS

..................................................................................................................................
..................................................................................................................................

..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................

..................................................................................................................................
..................................................................................................................................
..................................................................................................................................
..................................................................................................................................


SUMMARY
Project’s name: Building a fitness personal trainer application
Student name: Ngo Minh Cuong
Student ID: 102150087
Class: 15T2
This project aims to create a mobile application helping users to create
workout plan and nutrition plan based on their goal. Initially, users need to
determine their specific fitness goal such as weight loss, muscle gain and some
requirement criterion like time for workout every week and every day, time to
achieve the goal, daily activity level … The system acquires those information to
generate an appropriate workout schedule with a collection of exercises to practice
every day, every week during the time of plan. Besides that, users also have a daily
nutrition plan specify amount of calories/protein/carbs/fat need to gain. Users just
practice and eat following the plan. Periodically, they input their current masses
such as weight, forearms circumference and the system generate statistic of how
well they improve.
In this project, I’ve already had the application with necessary features to
help users create and follow fitness plan. I’ve also done on generalizing essential
knowledge of fitness term to make an effective generating algorithm. The
application for users was created with React Native and the API was created by
using Django framework based on Python programming language. Besides that, I
used PostgreSQL to store all the data and deploy the system to Heroku.



DA NANG UNIVERSITY

THE SOCIALIST REPUBLIC OF VIETNAM

UNIVERSITY OF SICIENCE AND
TECHNOLOGY
FALCUTY OF INFORMATION
TECHNOLOGY

Independence - Freedom - Happiness

GRADUATION PROJECT REQUIREMENTS
Student Name: Ngo Minh Cuong
Class: 15T2

Student ID: 102150087

Faculty: Information Technology

Major: Information Technology
1. Topic title: Building a fitness personal trainer application
2. Project topic: ☐has signed intellectual property agreement for final result
3. Initial figure and data:
All the figure and data were gathered on the internet from trusted resources
Content of the explanations and calculations:
- Conceptions of fitness term
- Workout schedule and nutrition plan for users
4. Drawings, charts (specify the types and sizes of drawings):
-


User case diagram
Class diagram

-

Sequence diagram
Activity diagram
Package diagram

5. Name of instructor:

Content parts:

M.S. Phan Thanh Tao

6. Date of assignment : 07/09/2019
7. Date of completion : 20/12/2019
Da Nang, date
Head of Division………………….

month
Instructor

year 2019


ACKNOWLEDGMENTS

First of all, I would like to spend my honest appreciation to my instructor,
M.S. Phan Thanh Tao for his continuous support, supervision and guidance

through the tenure of my project. His wisdom and experience gave me the
understanding on determining the idea, designing the system and handling
researching.
In addition, I would like to thank mentors from Enclave company for their
valuable guidance. During the progress, they always gave helpful advice and
resource to make my project better and better. I also thank to my colleagues at
Enclave company for their supportive advice. Specially, thanks to my family and
my friends for always be with me and give enthusiasm and motivation to keep my
on my way.
I also would like to thank all teachers at Da Nang University of Science and
Technology for their continuous contribution for education. During four years at
university, I was taught a lot, they imparted us knowledge, taught us to do the right
thing.
Without the generous help from all of them, my senior project wouldn’t have
been successful.
Sincerely,

Ngo Minh Cuong


GUARANTEE

I guarantee:
1. The whole project was made on my own following the instruction of M.S Phan
Thanh Tao.
2. Every information was from trusted resource and was verify about the
reliability.
3. I take full responsibility for my project.
Student Performed,


Ngo Minh Cuong

i


CONTENT

SUMMARY ..................................................................................................................... 5
ACKNOWLEDGMENTS .............................................................................................. 7
GUARANTEE .................................................................................................................. i
CONTENT ....................................................................................................................... ii
LIST OF TABLES ......................................................................................................... iv
LIST OF FIGURES ....................................................................................................... vi
LIST OF ABBREVIATIONS ..................................................................................... viii
INTRODUCTION .......................................................................................................... 1
1.

Project overview ................................................................................................... 1
1.1.

Context........................................................................................................... 1

1.2.

Purpose .......................................................................................................... 1

2.

Theories................................................................................................................. 2
2.1.


Technologies .................................................................................................. 2

2.2.

Tools and environment development .......................................................... 2

3.

Thesis structure .................................................................................................... 2

Chapter 1 : THEORIES AND TECHNOLOGIES ...................................................... 3
1.1.

REST API ......................................................................................................... 3

1.1.1.

Definition ................................................................................................... 3

1.1.2.

The six principles of REST ...................................................................... 3

1.2.

Django and Django REST framework ........................................................... 4

1.2.1.


Django ........................................................................................................ 4

1.2.2.

Django REST framework ........................................................................ 5

1.3.

React Native & Redux ..................................................................................... 6

1.3.1.

React Native............................................................................................... 6

1.3.2.

Redux ......................................................................................................... 7

1.4.

PostgreSQL ....................................................................................................... 8

1.5.

Fitness Theories .............................................................................................. 10

1.6.

Conclusion ....................................................................................................... 11


ii


Chapter 2 : ANALYSIS AND DESIGN ...................................................................... 12
2.1. Requirement analysis ........................................................................................ 12
2.1.1. General requirements ................................................................................. 12
2.1.2. Main features............................................................................................... 13
2.2. System analysis ................................................................................................... 14
2.2.1. System architecture .................................................................................... 14
2.2.2. Use case diagram ......................................................................................... 15
2.2.3. Description for the main use-case.............................................................. 16
2.2.4. Activity diagram ......................................................................................... 32
2.3. System design ..................................................................................................... 40
2.3.1. Class diagram .............................................................................................. 40
2.3.2. Sequence diagram ....................................................................................... 41
2.3.3. Package diagram ......................................................................................... 44
2.3.4. Database design ........................................................................................... 45
2.4. Conclusion .......................................................................................................... 50
Chapter 3 : IMPLEMENTATION AND RESULT EVALUATION ....................... 52
3.1.

Development environment............................................................................. 52

3.2.

Demo system’s main features ........................................................................ 54

3.3.

Result evaluation ............................................................................................ 59


3.3.1.

Advantages .............................................................................................. 59

3.3.2.

Disadvantages .......................................................................................... 60

CONCLUSION ............................................................................................................. 61
1.

Achievements ...................................................................................................... 61

2.

Future works ...................................................................................................... 61

REFERENCE ................................................................................................................ 62

iii


LIST OF TABLES

Table 2.1: User case description – Administrator – Login .................................. 16
Table 2.2: User case description – Administrator – Manage sample data ........... 16
Table 2.3: User case description – Administrator – Create sample data ............. 17
Table 2.4: User case description – Administrator – Update sample data ............ 18
Table 2.5: User case description – Administrator – Delete sample data ............. 18

Table 2.6: User case description – Administrator – Create user account ............ 19
Table 2.7: User case description – Administrator – Delete user account ............ 20
Table 2.8: User case description – User – Register account ................................ 21
Table 2.9: User case description – User – Login ................................................. 22
Table 2.10: User case description – User – Input initial information .................. 22
Table 2.11: User case description – User – Consult recommend workout plan .. 23
Table 2.12: User case description – User – Consult sample workout plan.......... 24
Table 2.13: User case description – User – Consult sample execises ................. 24
Table 2.14: User case description – User – Examine statistic ............................. 25
Table 2.15: User case description – User – Create food ...................................... 26
Table 2.16: User case description – User – Modify food .................................... 26
Table 2.17: User case description – User – Delete food ...................................... 27
Table 2.18: User case description – User – Add daily diet record ...................... 28
Table 2.19: User case description – User – Update daily diet record .................. 29
Table 2.20: User case description – User – Remove food from daily diet record30
Table 2.21: User case description – User – Clear daily diet record ..................... 31
Table 2.22: Description of table – User ............................................................... 45
Table 2.23: Description of table – FitnessMass ................................................... 45
Table 2.24: Description of table – Activity level ................................................. 46
Table 2.25: Description of table – FitnessLevel .................................................. 46
Table 2.26: Description of table – FitnessGoal.................................................... 46
Table 2.27: Description of table – Plan................................................................ 47
Table 2.28: Description of table – DaySequence ................................................. 47
Table 2.29: Description of table – ExerciseSequence.......................................... 48
Table 2.30: Description of table – Exercise ......................................................... 48
Table 2.31: Description of table – DateRecord.................................................... 48
Table 2.32: Description of table – Meal .............................................................. 49
Table 2.33: Description of table – Meal Record .................................................. 49

iv



Table 2.34: Description of table – Food .............................................................. 49

v


LIST OF FIGURES

Figure 1.1: Django architecture overview ........................................................................ 5
Figure 1.2: Example of using Django Rest framework with React overview .................. 6
Figure 1.3: React Native architecture overview ............................................................... 7
Figure 1.4: Redux architecture.......................................................................................... 7
Figure 1.5: Basic PostgreSQL architecture..................................................................... 10
Figure 2.1: System architecture ...................................................................................... 14
Figure 2.2: Use case diagram for Administrator............................................................. 15
Figure 2.3: User case diagram for Users......................................................................... 15
Figure 2.4: Activity diagram – Administrator – Login ................................................... 32
Figure 2.5: Activity diagram – Administrator – Manage sample data ........................... 33
Figure 2.6: Activity diagram – Administrator – Create sample data .............................. 33
Figure 2.7: Activity diagram – Administrator – Update sample data ............................. 33
Figure 2.8: Activity diagram – Administrator – Delete sample data .............................. 34
Figure 2.9: Activity diagram – Administrator – Create account .................................... 34
Figure 2.10: Activity diagram – Administrator – Delete account .................................. 35
Figure 2.11: Activity diagram – Users – Register account ............................................. 35
Figure 2.12: Activity diagram – Users – Login .............................................................. 36
Figure 2.13: Activity diagram – User – Input initial information .................................. 36
Figure 2.14: Activity diagram – Users – Consult workout data ..................................... 37
Figure 2.15: Activity diagram – Users – Statistic ........................................................... 37
Figure 2.16: Activity diagram – Users – Create personal food ...................................... 37

Figure 2.17: Activity diagram – Users – Modify personal food ..................................... 38
Figure 2.18: Activity diagram – Users – Delete personal food ...................................... 38
Figure 2.19: Activity diagram – Users – Add food to daily diet record ......................... 38
Figure 2.20: Activity diagram – Users – Update food of daily diet record .................... 39
Figure 2.21: Activity diagram – Users – Remove food from daily diet record .............. 39
Figure 2.22: Activity diagram – Users – Clear daily diet record .................................... 39
Figure 2.23: Class diagram ............................................................................................. 40
Figure 2.24: Sequence diagram – Login ......................................................................... 41
Figure 2.25: Sequence diagram – Administrator – Create sample data.......................... 41
Figure 2.26: Sequence diagram – Users – Register account........................................... 42
Figure 2.27: Sequence diagram – Users – Input initial information ............................... 42
Figure 2.28: Sequence diagram – Users – Practice exercises ......................................... 43
Figure 2.29: Sequence diagram – Users – Add food to daily diet record ....................... 43
Figure 2.30: Package Diagram ........................................................................................ 44
Figure 2.31: Relationship between tables ....................................................................... 50
Figure 3.1: Response from API – GET method.............................................................. 52
Figure 3.2: Response from API – POST method............................................................ 53
Figure 3.3: Response from API – PUT method .............................................................. 53
Figure 3.4: Response from API – DELETE method ...................................................... 54
Figure 3.5: Result – Input initial information ................................................................. 54
Figure 3.6: Result – Workout plan.................................................................................. 55
Figure 3.7: Result – Days sequence of each plan ........................................................... 55
Figure 3.8: Result – Detail information of each plan day ............................................... 56
Figure 3.9: Result – Practice feature ............................................................................... 56
Figure 3.10: Result – Library of exercises ...................................................................... 57

vi


Figure 3.11: Result – Detail of each exercise ................................................................. 57

Figure 3.12: Result – Daily nutrition information .......................................................... 58
Figure 3.13: Result – Daily eaten food record ................................................................ 58
Figure 3.14: Result – Statistic ......................................................................................... 59

vii


LIST OF ABBREVIATIONS

No

Items

Description

1

API

Application Programming Interface

2

HTML

Hypertext Markup Language

3

HTTP


Hypertext Transfer Protocol

4

REST

Representational State Transfer

5

UX/UI

User Experience/User Interface

viii


Building a Fitness Personal Trainer Application

INTRODUCTION

1. Project overview
1.1. Context
Nowadays, the growth and development of the knowledge economy lead to the
transference from manual-working into intellectual-working. That means people
use grey matter to work and have a sedentary lifestyle. People were carried in the
moving of life, they become too busy to care about their fitness.
According to the researching from “Global Emotions Report”, there were third
of people from 143 countries said they experienced “a lot of stress” on their life,

most of them are intellectual worker. This state comes from being unhealthy
because most of them don’t have time to create a fitness plan. There is no time for
them for gym center or self-researching about how to build a suitable fitness plan.
Cause of those problems I decided to come up with the project “Build a fitness
personal trainer application”.
1.2. Purpose
This system aims to help users create a fitness plan which is appropriate for
them. The users just need to input the initial requirement criterion, the system
would generate a plan based on that. The plan contains a workout schedule and
daily nutrition plan, users practice and eat follow it to achieve their goal.
With each plan, users will get a schedule of what exercises they need to practice
and how long/ how often to do it. All the exercises of the system don’t need
equipment thus users can practice at home or at their office. Besides practicing,
users also need to follow the nutrition plan for the best result. Different from usual
diet, nutrition plan for a specific goal is harder, it called clean-eating. It’s totally
follow the science so that users can apply it for their daily meal even they plan is
over.
Users need to determine the specific time to get their goal, how often they can
spend for workout and some more criteria. Then the plan will be customized to suit
them. During the goal time, users just follow the plan, practice following the
schedule and adjust their meal to fit the nutrition plan. They are able to control
their progress by regularly update their current body mass, combine with the
statistic of the system they will see how well they changed.

Ngo Minh Cuong – 15T2

1


Building a Fitness Personal Trainer Application


Meanwhile, I built this system not for everyone. People who don’t care much
about their fitness and don’t afford to follow the heavy fitness plan shouldn’t use
this system.
2. Theories
2.1. Technologies
- Django and Django REST framework
- React Native & Redux
- PostgreSQL
-

REST API

2.2. Tools and environment development
- Microsoft Visual Studio Code
- Android Studio Emulator
-

Postman
Google chrome

3. Thesis structure
INTRODUCION – This chapter gives information about context and purpose
of the project as well as technologies were used in the project.
Chapter 1: THEORIES AND TECHNOLOGIES – This chapter introduces
all technologies and knowledge theories were used in the project.
Chapter 2: ANALYSIS AND DESIGN – This chapter contains the main
features, software requirement specifications and database design of the project.
Chapter 3: IMPLEMENTATION AND RESULT EVALUATION – This
chapter shows the implementation of the project including pictures and explanation

for each main feature.
CONCLUSION - The conclusion chapter of the thesis including what
knowledge was gain, advantages, and disadvantages of making the project, further
plans for the project.
REFERENCE – This section includes all the resources were used to refer
during making this project

Ngo Minh Cuong – 15T2

2


Building a Fitness Personal Trainer Application

Chapter 1 : THEORIES AND TECHNOLOGIES

This system were make from combining current popular technologies and
platform. To learn more about them, I would like to introduce main technologies
used in this project.
1.1.

REST API

1.1.1. Definition
API [1] is the acronym for "Application Programming Interface". It is a
software that allows two applications to communicate with each other over the
internet and through various devices.
The abbreviation REST stands for "Representational State Transfer" and
refers to a software architectural style. It is based on six principles that describe
how networked resources are defined and addressed on the web, for example in a

cloud. REST is not a programming language or basic structure and is not a piece
of software that can be executed.
RESTful APIs use the HTTP request methods GET, POST, PUT and
DELETE. Therefore, no protocol conventions are required for client and server to
communicate with each other via REST-APIs. With GET, resources are queried
from a RESTful API. POST is used to update or change the state of a resource.
With PUT, new resources can be created or the content of existing resources can
be replaced. DELETE is used to delete resources. These four HTTP methods are
usually sufficient to cover most use cases.
1.1.2. The six principles of REST
Client-server architecture [1]
The principle behind the client-server architecture is the separation of
problems. Dividing the user interface from data storage improves the portability
of that interface across multiple platforms. It also has the advantage that different
components can be developed independently from each other.
Statelessness
Statelessness means that the communication between client and server
always contains all the information needed to execute the request. There is no
session state on the server, it is kept entirely on the client. If access to a resource
requires authentication, the client must authenticate itself on each request.

Ngo Minh Cuong – 15T2

3


Building a Fitness Personal Trainer Application

Caching
The client, server, and any intermediate components can cache all resources

to improve performance. The information can be classified as cacheable or noncacheable.
Uniform interface
All components of a RESTful API have to follow the same rules to
communicate with each other. This also makes it easier to understand interactions
between the various components of a system.
Layered system
Individual components cannot see beyond the immediate level they interact
with. This means that a client that connects to an intermediate component such as
a proxy does not know what is behind it. Therefore, components can be easily
exchanged or expanded independently of each other.
Code-on-demand
Additional code can be downloaded to extend client functionality. However,
this is optional because the client may not be able to download or execute this
code.
1.2.

Django and Django REST framework

1.2.1. Django
Django [2] is a high-level Python web framework that enables rapid
development of secure and maintainable websites. It is free and open source, has a
thriving and active community, great documentation, and many options for free and
paid-for support.
These are main features of Django :
-

Versatility
Django can build almost any type of website. It can also work with any
client-side framework and can deliver content in any format such as HTML,
JSON, XML etc. Some sites which can be built using Django are wikis,

social networks, new sites etc.

-

Security
Since Django framework is made for making web development easy, it has
been engineered in such a way that it automatically do the right things to
protect the website. For example, In the Django framework instead of

Ngo Minh Cuong – 15T2

4


Building a Fitness Personal Trainer Application

putting a password in cookies, the hashed password is stored in it so that it
can’t be fetched easily by hackers.
-

Scalability
Django web nodes have no stored state, they scale horizontally – just fire up
more of then in need. Being able to do this is the essence of good scalability.
Instagram and Disqus are two Django based products that have millions of
active users, this is taken as an example of the scalability of Django.

-

Portability
All the codes of the Django framework are written in Python, which runs on

many platforms. Which leads to run Django too in many platforms such as
Linux, Windows and Mac OS.

Figure 1.1: Django architecture overview
1.2.2. Django REST framework
Django REST framework [3] is a powerful and flexible extended toolkit of
Django for building Web APIs.
These are some strong point of Django REST framework:
-

The Web browsable API is a huge usability.
Authentication policies including packages for OAuth1a and OAuth2.

Ngo Minh Cuong – 15T2

5



×