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 Ngo Minh Cuong PROJECT’S NAME: BUILDING A FITNESS PERSONAL TRAINER APPLICATION 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 IN STRUCTOR’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 I n 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 UNIVERSITY OF SICIENCE AND TECHNOLOGY FALCUTY OF INFORMATION TECHNOLOGY THE SOCIALIST REPUBLIC OF VIETNAM Independence - Freedom - Happiness GRADUATION PROJECT REQUIREMENTS Student Name: Ngo Minh Cuong Student ID: 102150087 Class: 15T2 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 month year 201 9 Head of Division ………………… Instructor 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 i 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 ii 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 Th e 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 iii 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 iv 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 v Table 2 34: Description of table – Food 49 vi 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 vii 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 viii LIST OF ABBREVIATIONS No Items Description 1 API Application Programming Interface 2 HTML Hypertext Markup Language 3 HTTP H ypertext Transfer Protocol 4 REST Representational State Transfer 5 UX/UI User Experience/User Interface Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 1 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 T here 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 Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 2 Meanwhile, I built this sys tem 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 Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 3 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 applic ations 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 Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 4 Caching The client, server, and any intermediate components can cache all resources to improve performance The information can be classified as cacheable or non- cacheable 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 an d 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 fra mework 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 Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 5 putting a password in cookies, the hashed password is stored in it so that it can’t be fetched easily by hackers - Scalability Dj ango 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 ext ended toolkit of Django for building Web APIs These are s ome strong point of Django REST framework: - The Web browsable API is a huge usability - Authentication policies including packages for OAuth1a and OAuth2 Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 6 - Serialization that supports both ORM and non-ORM data sources - Customizable all the way down - just use regular function-based views - Extensive documentation , and great community support - Used and truste d by internationally recognised companies including Mozilla , RedHat , Heroku , and Eventbrite Figure 1 2: Example of using Django Rest framework with React overview 1 3 React Native & Redux 1 3 1 React Native React Native [4] is a framework developed by Facebook for creating native- style apps for both iOS & Android platform under one common language, JavaScript The working principles of React Native [5] are virtually identical to React except that React Native does not manipulate the DOM via the Virtual DOM It runs in a background process (which interprets the JavaScript written by the developers) directly on the end-device and communicates with the native platform via a serialization, asynchronous and batched Bridge React components wrap existing native code and interact with native APIs via React’s declarative UI paradigm an d JavaScript This enables native app development for whole new teams of developers, and can let existing native teams work much faster Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 7 React Native does not use HTML Instead, messages from the JavaScript thread are used to manipulate native views Figure 1 3: React Native architecture overview 1 3 2 Redux Redux is an open-source JavaScript library for managing application state It is most commonly used with libraries such as React or Angular for building user interfaces Figure 1 4: Redux architecture Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 8 1 4 PostgreSQL PostgreSQL, [6] also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and technical standards compliance It is designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users It is the default database for macOS Server, and is also available for Linux, FreeBSD, OpenBSD, and Windows PostgreSQL [6] features transactions with Atomicity, Consistency, Isolation, Durability (ACID) properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures PostgreSQL is developed by the PostgreSQL Global Development Group, a diverse group of many companies and individual contributors Below is an inexhaustive list of various features in PostgreSQL: - Data Types Primitives: Integer, Numeric, String, Boolean Structured: Date/Time, Array, Range, UUID Document: JSON/JSONB, XML, Key-value (Hstore) Geometry: Point, Line, Circle, Polygon Customizations: Composite, Custom Types - Data Integrity UNIQUE, NOT NULL Primary Keys Foreign Keys Exclusion Constraints Explicit Locks, Advisory Locks - Concurrency, Performance Indexing: B-tree, Multicolumn, Expressions, Partial Advanced Indexing: GiST, SP-Gist, KNN Gist, GIN, BRIN, Covering indexes, Bloom filters Sophisticated query planner / optimizer, index-only scans, multicolumn statistics Transactions, Nested Transactions (via savepoints) Multi-Version concurrency Control (MVCC) Parallelization of read queries and building B-tree indexes Table partitioning Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 9 All transaction isolation levels defined in the SQL standard, including Serializable Just-in-time (JIT) compilation of expressions - Reliability, Disaster Recovery Write-ahead Logging (WAL) Replication: Asynchronous, Synchronous, Logical Point-in-time-recovery (PITR), active standbys Tablespaces - Security Authentication: GSSAPI, SSPI, LDAP, SCRAM-SHA-256, Certificate, and more Robust access-control system Column and row-level security Multi-factor authentication with certificates and an additional method - Extensibility Stored functions and procedures Procedural Languages: PL/PGSQL, Perl, Python (and many more) SQL/JSON path expressions Foreign data wrappers: connect to other databases or streams with a standard SQL interface Customizable storage interface for tables Many extensions that provide additional functionality, including PostGIS - Internationalization, Text Search Support for international character sets, e g through ICU collations Case-insensitive and accent-insensitive collations Full-text search Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 10 Figure 1 5: Basic PostgreSQL architecture 1 5 Fitness Theories This system has a feature to generate a personal plan for users by using an algorithm I used theories of fitness term to create a collection of criteria that are used to create a proper plan The first theory is the calories needed amount for a person There is a factor called BMR (Basal Metabolic Rate), which shows you the minimum amount of calories you need to maintain all essential activities such as breath, sit This factor can be calculated by the Harris-Benedict equation [7]: Men: BMR = 66 5 + (13 75 x weight) + (5 003 x height) – (6 755 x age) Women: BMR = 655 1 + (9 563 x weight) + (1 85 x height) – (4 676 x age) BMR is an amount calorie for essential activity To know the proper amount number, you need TDEE (Total Daily Energy Expenditure), which shows you an average amount of calories you need in your daily life based on your activity level TDEE is determined by multiplying BMR by a factor called PAL (Physical Activity Level): PAL = 1 53 if you are an o ffice worker getting little or no exercise PAL = 1 76 if you are a c onstruction worker or person running one hour daily PAL = 2 25 if you are an a gricultural worker (non - mechani zed) or person swimming two hours daily Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 11 To generate a workout plan, firstly, I used the recommended number of repetitions for each muscle group [8]: 60-120 reps/week with large size muscle group 30-50 reps/week with small size muscle group After that, based on a favorite muscle group list users chose and the day per week for the workout they input, the algorithm can generate what kind of exercise each day by combining two kinds of exercise, cardio and weightlifting [9] From the information of exercise type each day, time for a workout each day, and the recommend repetition for each muscle group, the algorithm would generate a list of exercises from the exercise library 1 6 Conclusion By learning the technologies and theories above, I successfully applied them to my system However, those are all new for me, so the system still contains many flaws, but basically, I’ve known to use them for building a specific project Some of the technologies I used are so new but have used by many developers recently Moreover, there are also a lot of big communities about those technologies This means those technologies are the trend and will be common in the future Learning and understanding about them early would be an advantage Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 12 Chapter 2 : ANALYSIS AND DESIGN This chapter will go into detail the requirements, describing nonfunctional requirements, design constraints, and other factors necessary to provide a complete and comprehensive description of the requirements for the application This consists of a package containing Requirements Specification, Use-Cases of the use-case model, Use Case Specifications, and Activity Diagram Shows an overview of what functions the system can satisfy Also, it defines the architecture, modules, and data for a system to satisfy specified requirements System design is intended to be the link between the system architecture and the implementation of technological system elements that compose the physical architecture model of the system It could be seen as the application of systems theory to product development The System Design process is to provide sufficiently detailed data and information about the system, and it is a system element to enable the implementation consistent with architectural entities as defined in models and views of the system architecture It shows the components of the web application, the structure of data tables, the relationship the elements that make up the system 2 1 Requirement analysis 2 1 1 General requirements - To use this system effectively, users are required to determine initially: The specific fitness goal: Gain weight, lose weight The desired number of the week to achieve the goal How often per week for the workout (fourth times, fifth times) How long per workout day to practice (twenty minutes, thirty minutes) Some main body mass: weight, height, age, gender Daily activity level: less activity, moderate activity - To extend the system as well as make the data more various, the admin needs to add more sample exercises and sample food recipes Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 13 2 1 2 Main features This system has two actors: - Administrator: The administrator has two main missions: Manage user accounts: deactivate or delete if necessary Create sample data for the system, including exercises, sample workout plans, sample ingredients, sample food recipes - Users: These are some main features that users can experience with the system: Consult the sample workout data: The system includes two main types of sample workout data: Exercises are all the single exercises of the system Each exercise has some necessary information for users to understand to perform it correctly Besides that, those exercises are used as a material to create both sample plans and user’s plans Workout plans are sample plans for various goals such as a plan for building upper muscles, plan for building leg muscles, plan for increasing endurance Those plans are the same as the user’s plan but it isn’t customized for anyone I t’s just the s ample data Users can practice following those sample plans if they see it suitable for them Follow the recommended workout plan: This feature is only available in case users provided initial information Recommend a workout plan is generated based on the user’s criteria , so the effectiveness of following the plan would be the best Tracking practice progress: Every time practicing with the app, the system would calculate the number of calories burned during the progress and create a statistic from those Looking at the statistic, users can know how much calories did they burned and how well they performed it Tracking daily diet: This feature requires users to eat clean It means they have to know how much they ate, then input the number of foods to the app From that information, the system can create a statistic of how much calories, protein, fat, carbs that users gained and evaluate the quality of the user’s current diet state Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 14 This feature also shows the recommended amount of nutrition for daily diet as well as how many calories to eat each meal 2 2 System analysis 2 2 1 System architecture Figure 2 1: System architecture This system includes: - API service was built by using Django REST framework to handle all the requests between client and server, query data from the database then return to the client - PostgreSQL database to store all the data - Administrator web page provided by Django framework to manage the whole system - The mobile client built in React Native platform is an application for users Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 15 2 2 2 Use case diagram - Use case diagram for Administrator: Figure 2 2: Use case diagram for Administrator - Use case diagram for Users: Figure 2 3: User case diagram for Users Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 16 2 2 3 Description for the main use-case Description for administrator web page - Login Table 2 1: User case description – Administrator – Login Use case ID UC-01 Actor Administrator Brief description This use case for administrator to log in Pre-conditions Administrator who has account to access administrator web page Post-conditions Administrator logged in successfully Flow of events Actor Input System Response 1 Open the administrator web page 2 Show login form 3 Fill the email and password Click “Login” button 4 System validates account that administrator filled and submit Show home screen if given account is correct - Manage sample data Table 2 2: User case description – Administrator – Manage sample data Use case ID UC-02 Actor Administrator Brief description This use case for view sample data including all the data created by administrator Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 17 Pre - conditions Administrator who has already logged in the system Post - conditions Administrator access sample data successfully Flow of events Actor Input System Response 1 Choose sample data 2 Show detail of data - Create sample data Table 2 3: User case description – Administrator – Create sample data Use case ID UC-03 Actor Administrator Brief description This use case for create sample data Pre-conditions Administrator who has already logged in the system Post-conditions Administrator create sample data successfully Flow of events Actor Input System Response 1 Choose table of data to create 2 Show the list of all exist data 3 Click “+Add” button 4 Show the form to input new data 5 Input data then click “Save” 6 Show the list contain added data Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 18 - Update sample data Table 2 4: User case description – Administrator – Update sample data Use case ID UC-04 Actor Administrator Brief description This use case for update sample data Pre-conditions Administrator who has already logged in the system Post-conditions Administrator update sample data successfully Flow of events Actor Input System Response 1 Choose table of data to modify 2 Show list of data 3 Choose a data to modify 4 Show the detail of data 5 Edit data then click button “Save” 6 Show the list of data contains updated data - Delete sample data: Table 2 5: User case description – Administrator – Delete sample data Use case ID UC-05 Actor Administrator Brief description This use case for delete sample data Pre-conditions Administrator who has already logged in the system Post-conditions Administrator delete sample data successfully Flow of events Actor Input System Response Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 19 1 Choose table of data to delete 2 Show list of data 3 Choose a data to delete 4 Show the detail of data 5 Click button “Delete” 6 Show the fo rm to confirm deleting 7 Click button “Yes” to delete 8 Show the list of data doesn’t contains deleted data - Create user’s account Table 2 6: User case description – Administrator – Create user account Use case ID UC-06 Actor Administrator Brief description This use case for creating user’s account Pre-conditions Administrator who has already logged in the system Post-conditions Administrator create user’s account successfully Flow of events Actor Input System Response 1 Choose table of user 2 Show list of all user 3 Click button “Add” 4 Show the form to create user’s account Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 20 5 Input account information then click button “Add” 6 Show the form to confirm creating 7 Click button “Yes” to create 8 Show the list of user’s accounts contains new user’s account - Delete user’s account Table 2 7: User case description – Administrator – Delete user account Use case ID UC-07 Actor Administrator Brief description This use case for deleting user’s account Pre-conditions Administrator who has already logged in the system Post-conditions Administrator delete user’s account successfully Flow of events Actor Input System Response 1 Choose table of user 2 Show list of all user 3 Choose user to delete 4 Show the detail of user’s account 5 Click button “Delete” 6 Show the form to confirm deleting 7 Click button “Yes” to delete Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 21 8 Show the list of user’s accounts doesn’t contains deleted user’s account Description for user mobile application - Register account Table 2 8: User case description – User – Register account Use case ID UC-08 Actor User Brief description This use case for user to register account Pre-conditions User has already had the application Post-conditions User register account successfully Flow of events Actor Input System Response 1 Open the application 2 Show login form 3 Click button “Register” 4 Show the form to create new account 5 Input account information then click button “ Create ” 6 Show successful alert if account information is valid then return to login form Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 22 - Login Table 2 9: User case description – User – Login Use case ID UC-09 Actor User Brief description This use case for user to log in Pre-conditions User who has already had account Post-conditions User logged in successfully Flow of events Actor Input System Response 1 Open the application 2 Show login form 3 Input the email and password then click “Login” button 4 System validates account that user submitted Show home screen if given account is correct - Input initial information Table 2 10: User case description – User – Input initial information Use case ID UC-10 Actor User Brief description This use case for user input initial required information Pre-conditions User has already logged in for the first time Post-conditions User allowed to use the application Flow of events Actor Input System Response Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 23 1 Open the application and login 2 Show form to input initial information 3 Input the required information 4 System validates all info rmation user submit ted Show home screen if given information is correct - Consult recommend workout plan Table 2 11: User case description – User – Consult recommend workout plan Use case ID UC-11 Actor User Brief description This use case for user to access and practice with recommend workout plan Pre-conditions User has already logged in and input initial information Post-conditions User can access recommend workout plan Flow of events Actor Input System Response 1 Click on recommend plan in the beginning part 2 Show schedule of plan 3 Click one day to show the detail plan 4 Show list of exercises to practice of that day 5 Click button “Start” to practice Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 24 6 Show practice screen - Consult sample workout plan Table 2 12: User case description – User – Consult sample workout plan Use case ID UC-12 Actor User Brief description This use case for user to access and practice with sample workout plan Pre-conditions User has already logged in and input initial information Post-conditions User can access sample workout plan Flow of events Actor Input System Response 1 Click one plan in the “Plan” tab 2 Show schedule of plan 3 Click one day to show the detail plan 4 Show list of exercises to practice of that day 5 Click button “Start” to practice 6 Show practice screen - Consult sample exercises Table 2 13: User case description – User – Consult sample execises Use case ID UC-13 Actor User Brief description This use case for user to access and practice with sample exercises Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 25 Pre - conditions User has already logged in and input initial information Post - conditions User can access sample exercises Flow of events Actor Input System Response 1 Click on “Exercise” tab 2 Show a list of all exercises 3 Choose one exercises to show 4 Show detail information of exercise 5 Click button “Start” to pra c tice 6 Sh ow practice screen - Examine statistic Table 2 14: User case description – User – Examine statistic Use case ID UC-14 Actor User Brief description This use case for user to access the statistic Pre-conditions User has already logged in and input initial information Post-conditions User can access statistic feature Flow of events Actor Input System Response 1 Click on “Profile” tab 2 Show profile tab 3 Click on “Statistic” 4 Show statistic screen Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 26 - Create personal food Table 2 15: User case description – User – Create food Use case ID UC-15 Actor User Brief description This use case for user to create their own food/meal Pre-conditions User has already logged in and input initial information Post-conditions User create food/meal successfully Flow of events Actor Input System Response 1 Click on “ Diary ” tab 2 Show “Diary” tab 3 Click on float button “+” then click “Create food” or “Cre ate meal” 4 Show screen to input detail information of food/meal 5 Click button “ Create ” to submit 6 The system check given information of food/meal Go back to previous screen if given information is valid - Modify personal food Table 2 16: User case description – User – Modify food Use case ID UC-16 Actor User Brief description This use case for user to update their own food/meal Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 27 Pre - conditions User has already logged in and input initial information Post - conditions User up d ate food/meal successfully Flow of events Actor Input System Response 1 Click on “Diary” tab 2 Show “Diary” tab 3 Click on float button “+” then click “ All f ood s ” 4 Show “All foods” screen 5 Click on “Your food” or “Your meal” tab 6 Show all user’s foods/meals 7 Choose one item to update 8 Show detail of food/meal 9 Click “Edit” Button 10 Show form to update 11 Update information then click button “Update” 12 The system checks new given information Go back Diary tab if it is valid - Delete personal food Table 2 17: User case description – User – Delete food Use case ID UC-17 Actor User Brief description This use case for user to delete their own food/meal Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 28 Pre - conditions User has already logged in and input initial information Post - conditions User delete food/meal successfully Flow of events Actor Input System Response 1 Click on “Diary” tab 2 Show “Diary” tab 3 Click on float button “+” then click “ All f ood s ” 4 Show “All foods” screen 5 Click on “Your food” or “Your meal” tab 6 Show all user’s foods/meals 7 Choose one item to delete 8 Show detail of food/meal 9 Click “Delete” Button 10 Show the confirm form 11 Click “Yes” button to delete 12 The system delete chosen item - Add daily diet record Table 2 18: User case description – User – Add daily diet record Use case ID UC-18 Actor User Brief description This use case for user to add eaten food to their daily diet record Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 29 Pre - conditions User has already logged in and input initial information Post - conditions User add food successfully Flow of events Actor Input System Response 1 Click on “Diary” tab 2 Show “Diary” tab 3 Click on float button “+ Add ” on Breakfast/Lunch/Dinner part to add food 4 Show “All foods” screen 5 Choose one food to add 6 Show detail information of food to input the quantity 7 Input quantity of fo od then click button “Add” 8 Food is added to the meal - Update daily diet record Table 2 19: User case description – User – Update daily diet record Use case ID UC-19 Actor User Brief description This use case for user to update eaten food on their daily diet record Pre-conditions User has already logged in, input initial information and input food the record Post-conditions User update record successfully Flow of events Actor Input System Response Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 30 1 Click on “Diary” tab 2 Show “Diary” tab 3 Choose the date to update 4 Show calendar screen 5 Pick a date 6 Show the record of that date 7 Choose a food to update the quantity 8 Show detail information of food 9 Change t he quantity then click button “Update” 10 The food is updated - Remove daily diet record Table 2 20: User case description – User – Remove food from daily diet record Use case ID UC-20 Actor User Brief description This use case for user to remove eaten food on their daily diet record Pre-conditions User has already logged in, input initial information and input food the record Post-conditions User remove record successfully Flow of events Actor Input System Response 1 Click on “Diary” tab 2 Show “Diary” tab Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 31 3 Choose the date to update 4 Show calendar screen 5 Pick a date Show the record of that date 6 Click button “Delete” beside a food to remove 7 Show confirm alert 8 Click “Yes” button to remove 9 The food is removed - Clear daily diet record Table 2 21: User case description – User – Clear daily diet record Use case ID UC-21 Actor User Brief description This use case for user to clear all the information of their daily diet record Pre-conditions User has already logged in, input initial information and input food the record Post-conditions User remove record successfully Flow of events Actor Input System Response 1 Click on “Diary” tab 2 Show “Diary” tab 3 Click float button “+” then click “Clear chart” 4 Show confirm alert Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 32 5 Click “Yes” button to clear 6 Daily record is cleared 2 2 4 Activity diagram Activity diagram is basically a flowchart to represent the flow from one activity to another activity The activity can be described as an operation of the system Activity diagram is used as a flowchart that consists of activities performed by the system I must clearly understand about the elements used in activity diagram The main of an activity diagram is the activity itself After identifying the activities, I need to understand how they associated with constraints and conditions Administrator - Login Figure 2 4: Activity diagram – Administrator – Login Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 33 - Manage sample data Figure 2 5: Activity diagram – Administrator – Manage sample data - Create sample data Figure 2 6: Activity diagram – Administrator – Create sample data - Update sample data Figure 2 7: Activity diagram – Administrator – Update sample data Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 34 - Delete sample data Figure 2 8: Activity diagram – Administrator – Delete sample data - Create account Figure 2 9: Activity diagram – Administrator – Create account Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 35 - Delete account Figure 2 10: Activity diagram – Administrator – Delete account Users - Register account Figure 2 11: Activity diagram – Users – Register account Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 36 - Login Figure 2 12: Activity diagram – Users – Login - Input initial information Figure 2 13: Activity diagram – User – Input initial information Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 37 - Consult workout data including recommend workout plan, sample workout plan, exercises Figure 2 14: Activity diagram – Users – Consult workout data - Examine statistic Figure 2 15: Activity diagram – Users – Statistic - Create food Figure 2 16: Activity diagram – Users – Create personal food Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 38 - Modify food Figure 2 17: Activity diagram – Users – Modify personal food - Delete food Figure 2 18: Activity diagram – Users – Delete personal food - Add food to daily diet record Figure 2 19: Activity diagram – Users – Add food to daily diet record Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 39 - Update food of daily diet record Figure 2 20: Activity diagram – Users – Update food of daily diet record - Remove food from daily diet record Figure 2 21: Activity diagram – Users – Remove food from daily diet record - Clear daily diet record Figure 2 22: Activity diagram – Users – Clear daily diet record Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 40 2 3 System design 2 3 1 Class diagram Figure 2 23: Class diagram The class diagram describes the responsibilities of a system, basis for components and deployment diagrams, analysis and design of the static view of an application Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 41 It describes the relationship among all entities of this system, the attributes and methods are clearly identified 2 3 2 Sequence diagram - Login Figure 2 24: Sequence diagram – Login Administrator - Create sample data Figure 2 25: Sequence diagram – Administrator – Create sample data Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 42 User - Register account Figure 2 26: Sequence diagram – Users – Register account - Input initial information and get recommend fitness plan Figure 2 27: Sequence diagram – Users – Input initial information Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 43 - Practice exercises Figure 2 28: Sequence diagram – Users – Practice exercises - Add food to daily diet record Figure 2 29: Sequence diagram – Users – Add food to daily diet record Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 44 2 3 3 Package diagram Figure 2 30: Package Diagram This package diagram describes my system architecture My system uses API service to execute the actions of users, including generating recommend plan for user, export statistic of calories burned and eaten nutrition, return workout data for user to practice then calculate calories burned, tracking daily diet by adding eaten foods All the data were stored in PostgreSQL to assist API return data to client Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 45 2 3 4 Database design Description of tables Table 2 22: Description of table – User No Name Type Length Allow Null Key 1 username Varchar 10 FALSE PK 2 email Varchar 10 FALSE 3 password Text 50 FALS E 4 is_active Boolean FALSE 5 is_admin Boolean FALSE 6 password Varchar 60 FALSE 7 first_name Varchar 45 FALSE 8 last_name Varchar 45 FALSE 9 phone Varchar 15 TRUE 10 ava_url Text 200 FALSE 11 crea ted_at timestamp FALSE Table 2 23: Description of table – FitnessMass No Name Type Length Allow Null Key 1 id Integer 10 FALSE PK 2 user_id Varchar 10 FALSE FK 3 weight Integer 3 FALSE 4 height Integer 3 FALSE 5 age Integer 2 FALSE 6 gender Boolean FALSE Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 46 7 weight_goal Integer 3 TRUE 8 workout_time Integer 3 FALSE 9 workout_day Integer 1 FALSE 10 activity_level Varchar 10 FALSE FK 11 fitness_level Varchar 10 FALSE FK 12 fitness_goal Varchar 10 FALSE FK 13 calories_goal Integer 4 FALSE 14 protein_goal Integer 3 FALSE 15 carbs_goal Integer 3 FALSE 16 fat_goal Integer 3 FALSE Table 2 24: Description of table – Activity level No Name Type Length Allow Null Key 1 level Varchar 10 FALSE PK 2 description Text 50 FALSE Table 2 25: Description of table – FitnessLevel No Name Type Length Allow Null Key 1 level Varchar 10 FALSE PK 2 description Text 50 FALSE Table 2 26: Description of table – FitnessGoal No Name Type Length Allow Null Key 1 goal Varchar 10 FALSE PK Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 47 2 description Text 50 FALSE Table 2 27: Description of table – Plan No Name Type Length Allow Null Key 1 id Integer 10 FALSE PK 2 user_id Varchar 10 TRUE FK 3 name Varchar 10 FALSE 4 difficulty_level Varchar 10 FALSE 5 image Text FALSE 6 plan_type V archar 10 FALSE 7 day_number Integer 2 FALSE 8 instruction Text 200 TRUE Table 2 28: Description of table – DaySequence No Name Type Length Allow Null Key 1 id Integer 3 FALSE PK 2 week Varchar 10 FALSE 3 day Varchar 10 FALSE 4 order Integer 3 FALSE 5 exercise_number Integer 2 FALSE 6 set _ number Integer 1 FALSE 7 progress Integer 2 FALSE 8 plan_id Integer 10 FALSE FK Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 48 Table 2 29: Description of table – ExerciseSequence No Name Type Length Allow Null Key 1 id Integer 3 FALSE PK 2 day_sequence_id Integer 3 FALSE FK 3 order Integer 3 FALSE 5 duration Varchar 5 FALSE 6 exercise_id Varchar 10 FALSE FK 7 is_done Boolean FALSE Table 2 30: Description of table – Exercise No Name Type Length Allow Null Key 1 name Varchar 10 FALSE PK 2 image Text FALSE 3 description Text 50 FALSE 5 exercise_group Varchar 10 FALSE 6 level Varchar 10 FALSE Table 2 31: Description of table – DateRecord No Name Type Length Allow Null Key 1 date Date FALSE PK 2 user_id Varchar 10 FALSE FK 3 calories_intake Integer 4 FALSE 5 protein_intake Integer 3 FALSE Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 49 6 carbs_intake Integer 3 FALSE 7 fat_intake Integer 3 FALSE Table 2 32: Description of table – Meal No Name Type Length Allow Null Key 1 id Integer 10 FALSE PK 2 date_id Date FALSE FK 3 calories_intake Integer 4 FALSE 5 protein_intake Integer 3 FALSE 6 carbs_intake Integer 3 FALSE 7 fat_intake Integer 3 FALSE 8 meal_type Varchar 10 FALSE Table 2 33: Description of table – Meal Record No Name Type Length Allow Null Key 1 id Integer 10 FALSE PK 2 meal _id Integer 10 FALSE FK 3 food _ id Varchar 10 FALSE FK 5 serving Integer 3 FALSE Table 2 34: Description of table – Food No Name Type Length Allow Null Key Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 50 1 name Varchar 10 FALSE PK 2 user_id Varchar 10 TRUE FK 3 calories Integer 4 FALSE 5 protein Integer 3 FALSE 6 carbs Integer 3 FALSE 7 fat Integer 3 FALSE 8 category Varchar 10 FALSE Relationship between tables Figure 2 31: Relationship between tables 2 4 Conclusion This chapter presented the requirements specification that the system could meet the user’s demands Follow the requirements, the use case diagrams are used to gather the requirements of a system including internal and external influences Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 51 These requirements are mostly design requirements The activity diagrams, draw the activity flow of a system, show the steps and action sequences as well as the interactions between user and user, user and system Thereby, the overview and the activity streams of the system are fully presented Besides, this chapter also describes the system structure, as well as the action sequences for each function By that, it facilitates the testing phase, the tester can go back the sequence diagrams to follow the action sequences and create the function tests and the input data as well Furthermore, it shows the database to help the reader have clearer views of the system By that, I can consider and evaluate the complexity of this system Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 52 Chapter 3 : IMPLEMENTATION AND RESULT EVALUATION This chapter presents result of the project and go into each outcome After tenure of project, the outcome will be shown in two parts, development environment and demonstration of the system Development environment will go through all the technologies and development tools were used and finally show the experiment result 3 1 Development environment Web service I built the web service in Django framework version 3 0 and applied Django REST framework version 3 10 3 by using RESTful API method By using it, all the date is converted into JSON format to correspond to any platform Within the scope of this project, I applied four main API methods: GET: retrieve resource representation/inf ormation only Example: To retrieve all exercises of my system, send request to https://herokufitnessapp herokuapp com/Fitness/single_exercises Then Web service return a JSON response: Figure 3 1: Response from API – GET method POST: create new subordinate resources Example: To create personal food in my system, send request to https://herokufitnessapp herokuapp com/Fitness/food//food s/ with the JSON data in request body: Building a Fitness Personal Trainer Application Ngo Minh Cuong – 15T2 53 Figure 3 2: Response from API – P
Project overview
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”.
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
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.
Theories
Technologies
- Django and Django REST framework
Tools and environment development
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
Building a Fitness Personal Trainer Application
THEORIES AND TECHNOLOGIES
REST API
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
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 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
Building a Fitness Personal Trainer Application
The client, server, and any intermediate components can cache all resources to improve performance The information can be classified as cacheable or non- cacheable
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
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
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.
Django and Django REST framework
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 :
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
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
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
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
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
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
Building a Fitness Personal Trainer Application
- Serialization that supports both ORM and non-ORM data sources
- Customizable all the way down - just use regular function-based views
- Extensive documentation, and great community support
- Used and trusted by internationally recognised companies including
Mozilla, RedHat, Heroku, and Eventbrite
Figure 1.2: Example of using Django Rest framework with React overview
React Native & Redux
React Native [4] is a framework developed by Facebook for creating native- style apps for both iOS & Android platform under one common language, JavaScript
The working principles of React Native [5] are virtually identical to React except that React Native does not manipulate the DOM via the Virtual DOM It runs in a background process (which interprets the JavaScript written by the developers) directly on the end-device and communicates with the native platform via a serialization, asynchronous and batched Bridge
React components wrap existing native code and interact with native APIs via React’s declarative UI paradigm and JavaScript This enables native app development for whole new teams of developers, and can let existing native teams work much faster
Building a Fitness Personal Trainer Application
React Native does not use HTML Instead, messages from the JavaScript thread are used to manipulate native views
Figure 1.3: React Native architecture overview
Redux is an open-source JavaScript library for managing application state It is most commonly used with libraries such as React or Angular for building user interfaces
Building a Fitness Personal Trainer Application
PostgreSQL
PostgreSQL, [6] also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and technical standards compliance It is designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users It is the default database for macOS Server, and is also available for Linux, FreeBSD, OpenBSD, and Windows
PostgreSQL [6] features transactions with Atomicity, Consistency, Isolation, Durability (ACID) properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures PostgreSQL is developed by the PostgreSQL Global Development Group, a diverse group of many companies and individual contributors
Below is an inexhaustive list of various features in PostgreSQL:
Primitives: Integer, Numeric, String, Boolean
Structured: Date/Time, Array, Range, UUID
Document: JSON/JSONB, XML, Key-value (Hstore)
Geometry: Point, Line, Circle, Polygon
Indexing: B-tree, Multicolumn, Expressions, Partial
Advanced Indexing: GiST, SP-Gist, KNN Gist, GIN, BRIN, Covering indexes, Bloom filters
Sophisticated query planner / optimizer, index-only scans, multicolumn statistics
Transactions, Nested Transactions (via savepoints)
Multi-Version concurrency Control (MVCC)
Parallelization of read queries and building B-tree indexes
Building a Fitness Personal Trainer Application
All transaction isolation levels defined in the SQL standard, including Serializable
Just-in-time (JIT) compilation of expressions
Point-in-time-recovery (PITR), active standbys
Authentication: GSSAPI, SSPI, LDAP, SCRAM-SHA-256, Certificate, and more
Column and row-level security
Multi-factor authentication with certificates and an additional method
Procedural Languages: PL/PGSQL, Perl, Python (and many more)
Foreign data wrappers: connect to other databases or streams with a standard SQL interface
Customizable storage interface for tables
Many extensions that provide additional functionality, including PostGIS
Support for international character sets, e.g through ICU collations
Case-insensitive and accent-insensitive collations
Building a Fitness Personal Trainer Application
Fitness Theories
This system has a feature to generate a personal plan for users by using an algorithm I used theories of fitness term to create a collection of criteria that are used to create a proper plan
The first theory is the calories needed amount for a person There is a factor called BMR (Basal Metabolic Rate), which shows you the minimum amount of calories you need to maintain all essential activities such as breath, sit This factor can be calculated by the Harris-Benedict equation [7]:
Men: BMR = 66.5 + (13.75 x weight) + (5.003 x height) – (6.755 x age)
Women: BMR = 655.1 + (9.563 x weight) + (1.85 x height) – (4.676 x age)
BMR is an amount calorie for essential activity To know the proper amount number, you need TDEE (Total Daily Energy Expenditure), which shows you an average amount of calories you need in your daily life based on your activity level TDEE is determined by multiplying BMR by a factor called PAL (Physical Activity Level):
PAL = 1.53 if you are an office worker getting little or no exercise
PAL = 1.76 if you are a construction worker or person running one hour daily
PAL = 2.25 if you are an agricultural worker (non-mechanized) or person swimming two hours daily
Building a Fitness Personal Trainer Application
To generate a workout plan, firstly, I used the recommended number of repetitions for each muscle group [8]:
60-120 reps/week with large size muscle group
30-50 reps/week with small size muscle group
After that, based on a favorite muscle group list users chose and the day per week for the workout they input, the algorithm can generate what kind of exercise each day by combining two kinds of exercise, cardio and weightlifting [9]
From the information of exercise type each day, time for a workout each day, and the recommend repetition for each muscle group, the algorithm would generate a list of exercises from the exercise library.
Conclusion
By learning the technologies and theories above, I successfully applied them to my system However, those are all new for me, so the system still contains many flaws, but basically, I’ve known to use them for building a specific project
Some of the technologies I used are so new but have used by many developers recently Moreover, there are also a lot of big communities about those technologies This means those technologies are the trend and will be common in the future Learning and understanding about them early would be an advantage
Building a Fitness Personal Trainer Application
ANALYSIS AND DESIGN
Requirement analysis
- To use this system effectively, users are required to determine initially:
The specific fitness goal: Gain weight, lose weight
The desired number of the week to achieve the goal
How often per week for the workout (fourth times, fifth times)
How long per workout day to practice (twenty minutes, thirty minutes)
Some main body mass: weight, height, age, gender
Daily activity level: less activity, moderate activity
- To extend the system as well as make the data more various, the admin needs to add more sample exercises and sample food recipes
Building a Fitness Personal Trainer Application
This system has two actors:
The administrator has two main missions:
Manage user accounts: deactivate or delete if necessary
Create sample data for the system, including exercises, sample workout plans, sample ingredients, sample food recipes
These are some main features that users can experience with the system:
Consult the sample workout data:
The system includes two main types of sample workout data:
Exercises are all the single exercises of the system Each exercise has some necessary information for users to understand to perform it correctly Besides that, those exercises are used as a material to create both sample plans and user’s plans
Workout plans are sample plans for various goals such as a plan for building upper muscles, plan for building leg muscles, plan for increasing endurance Those plans are the same as the user’s plan but it isn’t customized for anyone It’s just the sample data Users can practice following those sample plans if they see it suitable for them
Follow the recommended workout plan:
This feature is only available in case users provided initial information Recommend a workout plan is generated based on the user’s criteria, so the effectiveness of following the plan would be the best
Every time practicing with the app, the system would calculate the number of calories burned during the progress and create a statistic from those Looking at the statistic, users can know how much calories did they burned and how well they performed it
This feature requires users to eat clean It means they have to know how much they ate, then input the number of foods to the app From that information, the system can create a statistic of how much calories, protein, fat, carbs that users gained and evaluate the quality of the user’s current diet state
Building a Fitness Personal Trainer Application
This feature also shows the recommended amount of nutrition for daily diet as well as how many calories to eat each meal.
System analysis
- API service was built by using Django REST framework to handle all the requests between client and server, query data from the database then return to the client
- PostgreSQL database to store all the data
- Administrator web page provided by Django framework to manage the whole system
- The mobile client built in React Native platform is an application for users
Building a Fitness Personal Trainer Application
- Use case diagram for Administrator:
Figure 2.2: Use case diagram for Administrator
- Use case diagram for Users:
Figure 2.3: User case diagram for Users
Building a Fitness Personal Trainer Application
2.2.3 Description for the main use-case
Description for administrator web page
Table 2.1: User case description – Administrator – Login
Brief description This use case for administrator to log in
Pre-conditions Administrator who has account to access administrator web page Post-conditions Administrator logged in successfully
Flow of events Actor Input System Response
1 Open the administrator web page
3 Fill the email and password Click “Login” button
System validates account that administrator filled and submit
Show home screen if given account is correct
Table 2.2: User case description – Administrator – Manage sample data
Brief description This use case for view sample data including all the data created by administrator
Building a Fitness Personal Trainer Application Pre-conditions Administrator who has already logged in the system
Post-conditions Administrator access sample data successfully
Flow of events Actor Input System Response
Table 2.3: User case description – Administrator – Create sample data
Brief description This use case for create sample data
Pre-conditions Administrator who has already logged in the system
Post-conditions Administrator create sample data successfully
Flow of events Actor Input System Response
1 Choose table of data to create
2 Show the list of all exist data
4 Show the form to input new data
6 Show the list contain added data
Building a Fitness Personal Trainer Application
Table 2.4: User case description – Administrator – Update sample data Use case ID UC-04
Brief description This use case for update sample data
Pre-conditions Administrator who has already logged in the system
Post-conditions Administrator update sample data successfully
Flow of events Actor Input System Response
1 Choose table of data to modify
4 Show the detail of data
5 Edit data then click button “Save”
6 Show the list of data contains updated data
Table 2.5: User case description – Administrator – Delete sample data Use case ID UC-05
Brief description This use case for delete sample data
Pre-conditions Administrator who has already logged in the system
Post-conditions Administrator delete sample data successfully
Flow of events Actor Input System Response
Building a Fitness Personal Trainer Application
1 Choose table of data to delete
4 Show the detail of data
6 Show the form to confirm deleting
7 Click button “Yes” to delete
8 Show the list of data doesn’t contains deleted data
Table 2.6: User case description – Administrator – Create user account Use case ID UC-06
Brief description This use case for creating user’s account
Pre-conditions Administrator who has already logged in the system
Post-conditions Administrator create user’s account successfully
Flow of events Actor Input System Response
2 Show list of all user
4 Show the form to create user’s account
Building a Fitness Personal Trainer Application
5 Input account information then click button “Add”
6 Show the form to confirm creating
7 Click button “Yes” to create
8 Show the list of user’s accounts contains new user’s account
Table 2.7: User case description – Administrator – Delete user account Use case ID UC-07
Brief description This use case for deleting user’s account
Pre-conditions Administrator who has already logged in the system
Post-conditions Administrator delete user’s account successfully
Flow of events Actor Input System Response
2 Show list of all user
4 Show the detail of user’s account
6 Show the form to confirm deleting
7 Click button “Yes” to delete
Building a Fitness Personal Trainer Application
8 Show the list of user’s accounts doesn’t contains deleted user’s account
Description for user mobile application
Table 2.8: User case description – User – Register account
Brief description This use case for user to register account
Pre-conditions User has already had the application
Post-conditions User register account successfully
Flow of events Actor Input System Response
4 Show the form to create new account
5 Input account information then click button “Create”
6 Show successful alert if account information is valid then return to login form
Building a Fitness Personal Trainer Application
Table 2.9: User case description – User – Login Use case ID UC-09
Brief description This use case for user to log in
Pre-conditions User who has already had account
Post-conditions User logged in successfully
Flow of events Actor Input System Response
3 Input the email and password then click
System validates account that user submitted
Show home screen if given account is correct
Table 2.10: User case description – User – Input initial information
Brief description This use case for user input initial required information Pre-conditions User has already logged in for the first time
Post-conditions User allowed to use the application
Flow of events Actor Input System Response
Building a Fitness Personal Trainer Application
1 Open the application and login
2 Show form to input initial information
System validates all information user submitted Show home screen if given information is correct
Table 2.11: User case description – User – Consult recommend workout plan Use case ID UC-11
Brief description This use case for user to access and practice with recommend workout plan Pre-conditions User has already logged in and input initial information
Post-conditions User can access recommend workout plan
Flow of events Actor Input System Response
1 Click on recommend plan in the beginning part
3 Click one day to show the detail plan
Show list of exercises to practice of that day
5 Click button “Start” to practice
Building a Fitness Personal Trainer Application
Table 2.12: User case description – User – Consult sample workout plan Use case ID UC-12
Brief description This use case for user to access and practice with sample workout plan Pre-conditions User has already logged in and input initial information Post-conditions User can access sample workout plan
Flow of events Actor Input System Response
1 Click one plan in the
3 Click one day to show the detail plan
Show list of exercises to practice of that day
5 Click button “Start” to practice
Table 2.13: User case description – User – Consult sample execises
Brief description This use case for user to access and practice with sample exercises
Building a Fitness Personal Trainer Application Pre-conditions User has already logged in and input initial information Post-conditions User can access sample exercises
Flow of events Actor Input System Response
2 Show a list of all exercises
3 Choose one exercises to show
Show detail information of exercise
5 Click button “Start” to practice
Table 2.14: User case description – User – Examine statistic
Brief description This use case for user to access the statistic
Pre-conditions User has already logged in and input initial information Post-conditions User can access statistic feature
Flow of events Actor Input System Response
Building a Fitness Personal Trainer Application
Table 2.15: User case description – User – Create food Use case ID UC-15
Brief description This use case for user to create their own food/meal
Pre-conditions User has already logged in and input initial information
Post-conditions User create food/meal successfully
Flow of events Actor Input System Response
3 Click on float button “+” then click “Create food” or “Create meal”
Show screen to input detail information of food/meal
5 Click button “Create” to submit
6 The system check given information of food/meal
Go back to previous screen if given information is valid
Table 2.16: User case description – User – Modify food Use case ID UC-16
Brief description This use case for user to update their own food/meal
Building a Fitness Personal Trainer Application Pre-conditions User has already logged in and input initial information
Post-conditions User update food/meal successfully
Flow of events Actor Input System Response
3 Click on float button “+” then click “All foods”
5 Click on “Your food” or
6 Show all user’s foods/meals
7 Choose one item to update
8 Show detail of food/meal
11 Update information then click button “Update”
12 The system checks new given information Go back Diary tab if it is valid
Table 2.17: User case description – User – Delete food Use case ID UC-17
Brief description This use case for user to delete their own food/meal
Building a Fitness Personal Trainer Application Pre-conditions User has already logged in and input initial information
Post-conditions User delete food/meal successfully
Flow of events Actor Input System Response
3 Click on float button “+” then click “All foods”
5 Click on “Your food” or
6 Show all user’s foods/meals
7 Choose one item to delete
8 Show detail of food/meal
11 Click “Yes” button to delete
12 The system delete chosen item
Table 2.18: User case description – User – Add daily diet record
Brief description This use case for user to add eaten food to their daily diet record
Building a Fitness Personal Trainer Application Pre-conditions User has already logged in and input initial information Post-conditions User add food successfully
Flow of events Actor Input System Response
“+Add” on Breakfast/Lunch/Dinner part to add food
5 Choose one food to add
6 Show detail information of food to input the quantity
7 Input quantity of food then click button “Add”
8 Food is added to the meal
Table 2.19: User case description – User – Update daily diet record
Brief description This use case for user to update eaten food on their daily diet record Pre-conditions User has already logged in, input initial information and input food the record Post-conditions User update record successfully
Flow of events Actor Input System Response
Building a Fitness Personal Trainer Application
3 Choose the date to update
6 Show the record of that date
7 Choose a food to update the quantity
8 Show detail information of food
9 Change the quantity then click button “Update”
Table 2.20: User case description – User – Remove food from daily diet record Use case ID UC-20
Brief description This use case for user to remove eaten food on their daily diet record Pre-conditions User has already logged in, input initial information and input food the record Post-conditions User remove record successfully
Flow of events Actor Input System Response
Building a Fitness Personal Trainer Application
3 Choose the date to update
Show the record of that date
6 Click button “Delete” beside a food to remove
8 Click “Yes” button to remove
Table 2.21: User case description – User – Clear daily diet record
Brief description This use case for user to clear all the information of their daily diet record Pre-conditions User has already logged in, input initial information and input food the record Post-conditions User remove record successfully
Flow of events Actor Input System Response
3 Click float button “+” then click “Clear chart”
Building a Fitness Personal Trainer Application
5 Click “Yes” button to clear
Activity diagram is basically a flowchart to represent the flow from one activity to another activity The activity can be described as an operation of the system Activity diagram is used as a flowchart that consists of activities performed by the system I must clearly understand about the elements used in activity diagram The main of an activity diagram is the activity itself After identifying the activities, I need to understand how they associated with constraints and conditions
Figure 2.4: Activity diagram – Administrator – Login
Building a Fitness Personal Trainer Application
Figure 2.5: Activity diagram – Administrator – Manage sample data
Figure 2.6: Activity diagram – Administrator – Create sample data
Figure 2.7: Activity diagram – Administrator – Update sample data
Building a Fitness Personal Trainer Application
Figure 2.8: Activity diagram – Administrator – Delete sample data
Figure 2.9: Activity diagram – Administrator – Create account
Building a Fitness Personal Trainer Application
Figure 2.10: Activity diagram – Administrator – Delete account
Figure 2.11: Activity diagram – Users – Register account
Building a Fitness Personal Trainer Application
Figure 2.12: Activity diagram – Users – Login
Figure 2.13: Activity diagram – User – Input initial information
Building a Fitness Personal Trainer Application
- Consult workout data including recommend workout plan, sample workout plan, exercises
Figure 2.14: Activity diagram – Users – Consult workout data
Figure 2.15: Activity diagram – Users – Statistic
Figure 2.16: Activity diagram – Users – Create personal food
Building a Fitness Personal Trainer Application
Figure 2.17: Activity diagram – Users – Modify personal food
Figure 2.18: Activity diagram – Users – Delete personal food
- Add food to daily diet record
Building a Fitness Personal Trainer Application
- Update food of daily diet record
Figure 2.20: Activity diagram – Users – Update food of daily diet record
- Remove food from daily diet record
Figure 2.21: Activity diagram – Users – Remove food from daily diet record
Figure 2.22: Activity diagram – Users – Clear daily diet record
Building a Fitness Personal Trainer Application
System design
The class diagram describes the responsibilities of a system, basis for components and deployment diagrams, analysis and design of the static view of an application
Building a Fitness Personal Trainer Application
It describes the relationship among all entities of this system, the attributes and methods are clearly identified
Figure 2.25: Sequence diagram – Administrator – Create sample data
Building a Fitness Personal Trainer Application
Figure 2.26: Sequence diagram – Users – Register account
- Input initial information and get recommend fitness plan
Figure 2.27: Sequence diagram – Users – Input initial information
Building a Fitness Personal Trainer Application
Figure 2.28: Sequence diagram – Users – Practice exercises
- Add food to daily diet record
Figure 2.29: Sequence diagram – Users – Add food to daily diet record
Building a Fitness Personal Trainer Application
This package diagram describes my system architecture My system uses API service to execute the actions of users, including generating recommend plan for user, export statistic of calories burned and eaten nutrition, return workout data for user to practice then calculate calories burned, tracking daily diet by adding eaten foods All the data were stored in PostgreSQL to assist API return data to client
Building a Fitness Personal Trainer Application
Table 2.22: Description of table – User
No Name Type Length Allow Null Key
Table 2.23: Description of table – FitnessMass
No Name Type Length Allow Null Key
2 user_id Varchar 10 FALSE FK
Building a Fitness Personal Trainer Application
10 activity_level Varchar 10 FALSE FK
11 fitness_level Varchar 10 FALSE FK
12 fitness_goal Varchar 10 FALSE FK
Table 2.24: Description of table – Activity level
No Name Type Length Allow Null Key
Table 2.25: Description of table – FitnessLevel
No Name Type Length Allow Null Key
Table 2.26: Description of table – FitnessGoal
No Name Type Length Allow Null Key
Building a Fitness Personal Trainer Application
Table 2.27: Description of table – Plan
No Name Type Length Allow Null Key
2 user_id Varchar 10 TRUE FK
Table 2.28: Description of table – DaySequence
No Name Type Length Allow Null Key
8 plan_id Integer 10 FALSE FK
Building a Fitness Personal Trainer Application
Table 2.29: Description of table – ExerciseSequence
No Name Type Length Allow Null Key
2 day_sequence_id Integer 3 FALSE FK
6 exercise_id Varchar 10 FALSE FK
Table 2.30: Description of table – Exercise
No Name Type Length Allow Null Key
Table 2.31: Description of table – DateRecord
No Name Type Length Allow Null Key
2 user_id Varchar 10 FALSE FK
Building a Fitness Personal Trainer Application
Table 2.32: Description of table – Meal
No Name Type Length Allow Null Key
2 date_id Date FALSE FK
Table 2.33: Description of table – Meal Record
No Name Type Length Allow Null Key
2 meal_id Integer 10 FALSE FK
3 food_id Varchar 10 FALSE FK
Table 2.34: Description of table – Food
No Name Type Length Allow Null Key
Building a Fitness Personal Trainer Application
2 user_id Varchar 10 TRUE FK
Conclusion
This chapter presented the requirements specification that the system could meet the user’s demands Follow the requirements, the use case diagrams are used
Building a Fitness Personal Trainer Application
These requirements are mostly design requirements The activity diagrams, draw the activity flow of a system, show the steps and action sequences as well as the interactions between user and user, user and system Thereby, the overview and the activity streams of the system are fully presented
Besides, this chapter also describes the system structure, as well as the action sequences for each function By that, it facilitates the testing phase, the tester can go back the sequence diagrams to follow the action sequences and create the function tests and the input data as well Furthermore, it shows the database to help the reader have clearer views of the system By that, I can consider and evaluate the complexity of this system
Building a Fitness Personal Trainer Application
IMPLEMENTATION AND RESULT EVALUATION
Development environment
I built the web service in Django framework version 3.0 and applied Django REST framework version 3.10.3 by using RESTful API method By using it, all the date is converted into JSON format to correspond to any platform Within the scope of this project, I applied four main API methods:
GET: retrieve resource representation/information only
Example: To retrieve all exercises of my system, send request to https://herokufitnessapp.herokuapp.com/Fitness/single_exercises
Then Web service return a JSON response:
Figure 3.1: Response from API – GET method
POST: create new subordinate resources
Example: To create personal food in my system, send request to https://herokufitnessapp.herokuapp.com/Fitness/food//food s/ with the JSON data in request body:
Building a Fitness Personal Trainer Application
Figure 3.2: Response from API – POST method
Example: To update information of a food in my system, send request to https://herokufitnessapp.herokuapp.com/Fitness/food//food s/ with the JSON data in request body:
Figure 3.3: Response from API – PUT method
Example: To delete a food in my system, send request to https://herokufitnessapp.herokuapp.com/Fitness/food//food s/ with the JSON data in request body:
Building a Fitness Personal Trainer Application
Figure 3.4: Response from API – DELETE method
I also applied in my algorithm to generate fitness plan for users All data of the system were stored in PostgreSQL database
In client-side, I create an android mobile app by using React Native platform version 0.58 Additional, I also applied Redux library to improve the app performance
To complete this project, these are some tools I used: Visual Studio Code, Android Studio and Postman.
Demo system’s main features
This part contains the demonstration of what my system has already had which show the application for users
Figure 3.5: Result – Input initial information
Building a Fitness Personal Trainer Application
In this screen, users input required information needed for generating their personal training plan then submit to system The API service validates the data then return error if the data valid or navigate to main screen other vice versa
This screen shows all the sample workout plans of the system and the recommend plan for user
Figure 3.7: Result – Days sequence of each plan
Building a Fitness Personal Trainer Application
Figure 3.8: Result – Detail information of each plan day
The first screen show a sequence day of plan, the detail of each day is shown in the second screen including general information, a sequence of exercises to practice
This feature helps users to practice following exercises
Building a Fitness Personal Trainer Application
The feature plays a role of a library of exercises, users examine these exercises to understand how to practice correctly
Figure 3.10: Result – Library of exercises
Figure 3.11: Result – Detail of each exercise
Building a Fitness Personal Trainer Application
This feature shows the daily diet record of users including nutrition information and eaten foods
Figure 3.12: Result – Daily nutrition information
Figure 3.13: Result – Daily eaten food record
Building a Fitness Personal Trainer Application
This feature show a list of records from the beginning day to current day Users can see how much calories they burned and intake each day
Result evaluation
Before this project I had had experience and knowledge in fitness term so all the fitness principles in this project is absolutely right Furthermore, the demand of being fitness is more and more popular thus I make this application would help users a lot on their daily life
Moreover, I’ve also had experience with Django framework That helps me a lot on building web service in a short time but still keep the efficiency In the other hand, Django is a high-level Python web framework that enables rapid development of making websites
Especially, my system is very effective in supporting users to create their own fitness plan It gathers user’s provided information, combines with algorithm to generate the most appropriate plan The algorithm was created by applying many fitness principles which were used by many fitness trainer, athlete In addition, the system also has various fitness plans based on multiple goals This gives users more
Building a Fitness Personal Trainer Application choice in case they tend to practice more Practicing is also easy with practice features; users open and practice following it
Beside advantages I mentioned, there are still some disadvantages I had:
- My system doesn’t have some necessary feature:
- The performance of the application isn’t too high
Building a Fitness Personal Trainer Application
Achievements
During the tenure of senior project, I’ve gained experience and knowledge on new technologies, especially React Native platform This technology was all new to me but after completing this project, I’ve known not only using React Native but also combining it with Redux library to improve the application performance Besides that, applying Django framework to web service also helped me to widen the knowledge and experience that I had had before
Beside achievements on technology, working on this project by myself also gave a chance to improve my self-learning and self-management skill Because there was no one control and track my progress so I had to arrange my tasks in the right way Moreover, I had to research by myself to use a lot of new technologies needed for the system Especially, my English skills were improved a lot by researching English resources and communicating with my colleagues
Building a system about fitness also gave me the necessary knowledge that I can apply to my daily life Especially, I’ve known principles of fitness term to create and improve my generating algorithm Based on all the achievements above, I’m totally confident to develop this project in the future and making it more completed.
Future works
Basically, this system has the main necessary features of a fitness personal application but there are some features needed to add in for a better experience These are some works I plan to add in the future:
- Build administrator web page to helps administrator manage the system easily
- Create authentication function for users to help them control their own profile information such as plan progress, personal information
- Create customize plan feature for users With this feature, experience users can create their personal workout plans
- Add recipe feature, this one would recommend users what dishes they should it on their daily meal based on the goals and information they provided
- Improve statistic feature to help user manage their progress more effective.