(Developer: Roman Rakic)
THE COACH >>> Live live website
The Coach is a command-line small Python program that can be considered a type of simulation or game. Project will put user in a position of a Coach for a team of 5 Basketball players that will be created based on user input. Input has to be inside Realistic parameters determined by the developer.Program will output the percentage of possible team performance so that user will have a Idea of how good final result Is.Program was developed as a 3rd portfolio project in acquiring the "Diploma In Software Development" with Code institute. The requirements of this project were use of Python programming language and it's libraries to develop a program in a mock terminal in the browser.
- Project Goals
- User Experience
- User Stories
- Technical Design
- Technologies Used
- Features
- Future-features
- Validation
- Testing
- Bugs
- Deployment
- Credits
- Acknowledgements
- The Coach program is intended to be the beginning of possible real-world application used in sports by coaches, mentors, and even athletes themself. With certain upgrades and some more real-world-based calculations in regard of caloric values and influences of certain training routines on athletes' bodies, this program could provide value and assist in optimizing the team and individual performance of an athlete.
- Interact with the program that is fun and easy to understand
- Use a program that has real-life potential
- Be able to Log in and come back to the existing account
- Create something fun and unique
- See the result of input choices
- Create a program that is Easy to use
- Create a program with possible real-world usage
- Create a program that provides feedback to a user
- Create a program that can be further developed in multiple directions
- Sports enthusiasts
- Coaching enthusiasts
- Strategic thinkers
- Simple easy to use and understand the program
- Intuitive navigation
- Engaging content
- Possibility of creativity inside certain parameters
- Personalization (usernames and player names)
- Feedback to a user in different stages of program
- Final result
Click here to view instructions
- Using this program user will create 5 players inside given parameters that allow certain creativity. In the next stage, user will choose 3 different types of training, each training option holds a value (that is not presented to the user, but the user is warned that the higher the number of training the value is higher) that will Carry half of the player's overall value. next stage calls user to pick 3 food options for each player. also each option has a caloric value (not presented to a user ). so user has to use common sense for food options,cause the caloric value of the food will be compared to a user active metabolic rate that is calculated after input values for each player. Food options will carry another half of player value. Final stage of the program presenting the user with the final result.Final percentage is calculated by calculating both halves of player value and then getting an overall value of the team in percentage
- The main menu is presented to the user with ASCII art of the program title and a short description of program instructions. at the bottom of the menu user is presented with 2 options option to proceed and the option to exit the program input validation is implemented throughout program so if invalid or outside parameters input is given user will be prompted to repeat the input
- program is terminated
- this option will present user with another 2 options
- new user
- existing user
- user is asked to create username and to put the email.
- user email is validated with python (email_validator) library
- after both inputs are validated user credentials are stored in the database(google spreadsheet)
- this option will returnig user to input email adress. if email is found in the database program will retrieve users username and greet user with username and percentage(score) user had on his last use of the program
- user will create 5 players and each player will consist of name,age,height and weight. all inputs will go trough validation process
Operation: Input numbers and characters then press enter key.
- after creating a team user is presented with the table consisting of his inputs for each player and active metabolic rate value calculated based on inputs.
- user will have to assign 3 training options to each player and each option has a certain value validation of inputs is implemented also.
Operation: Input a numeric value and press enter key.
- user will assign 3 food options for each player, and also each option carries certain calorie value input validation implemented.
Operation: Input a numeric value and press enter key.
- after choosing training and meals for all players program will perform calculation and present to user table of values thad lead to final result.
- final calculation is done and it's presented to user with thank you message
- after final result user will be presented with 2 options menu
- go again
- exit
Operation: Input a numeric value and press enter key.
- user is returned back to create a team and his previous result is cleared from the database
- I want to have an idea of what the program is about
- I want to be able to have clear and simple navigation
- I want to be able to log in and return to a program later
- I want to be able to get feedback in different stages of program
- I want to be informed why my input is not valid
- I want input parameters to be displayed clearly
- I want to see what choices I made
- I want to be able to play multiple times without logging in again
- I want to use the program with real-world data
- I want to use a program that allows certain creativity inside parameters
- I want to know the final result of using the program
- I want user to easily and intuitively navigate troughout program
- I want user to be guided and informed how to make valid inputs
- I want user to be able to personalize his experience and inputs
- I want user to have clear feedback from inputs
- I want user details to be stored and retrieved on demand into the database
- I want user to have the option to exit the program
- I want user to know the final result
- This Flowchart summarises the structure and logic of the application.
- OOP(object oriented programming) was implemented in certain parts of this program
- Classes -- One class was used to create all players with certain attributes(name,age,weight,height), and method that calculates the active metabolic rate of each player.
- Lists -- usage of lists in program is quite often because most of operations and calculations required repetition and iteration multiple times.
- Google sheets API - used to manipulate data(CRUD- create ,read update and delete)
- Calorie ninjas API - used to retrieve caloric value from users input
- Python programming language for the logic of the program
-
Lucidchart was used to draw a program flowchart
-
Git was used for version control within VSCode to push the code to GitHub
-
GitHub was used as a remote repository to store project code
-
Google Cloud Platform was used to manage access and permissions to the Google Services such as Google auth, sheets etc.
-
Google Sheets were used to store player's details
-
Heroku Platform was used to deploy the project into live environment
-
Font Awesome - icons from Font Awesome were used in the footer below the program terminal
-
Visual Studio Code (VSCode) VSCode was used to write the project code using Code Institute template
- click - used to clear the terminal
- random - used to generate random player values inside given parameters
- typing -used for type hints and return data types in python code
- sys & sleep - used to create a typing effect throughout the project
- time - used to displayed delayed messages in the terminal
- unittest - is used to do automated testing(part of the program)
- requests -JUSTIFICATION: used this library to call CalorieNinjas API and get caloric values of assigned meals
- colorama -JUSTIFICATION: used this library to add color to the terminal and enhance user experience. warning information is marked red while details that user can focus on with green color.Program title was colored blue
- email_validator - JUSTIFICATION: used this library to validate if user email input is in correct form
- gspread - JUSTIFICATION: used gspread for data manipulation inside Google spreadsheet and interaction with Google APIs
- google.oauth2.service_account -JUSTIFICATION: I used this module to set up the authentification needed to access the Google API and connect my Service Account with the Credentials function. A creds.json file is created with all details the API needs to access the google account. In deployment to heroku this information is stored in the config var section along with another custom config var provided by code institute.
- Introduce user with a program and give a hint what is it about
- user story covered: 1
- Displaying instructions on how to use program and what to expect
- user story covered: 1
- Provide 2 options for a user to proceed or exit a program
- user story covered: 17,16,12,2
- User is presented with option to to (sign-up) as a new user or to (log-in) as an existing user
- user story covered: 3,16,12,2
- User is prompted to make a username
- Validating username input
- User asked to provide a valid email address
- Informs user is email in valid format
- Saving credentials into the Google Spreadsheet
- User story covered: 3,16,5,14
- User is prompted to enter the valid email that is stored in a database
- validating email
- if email is not in the database user is taken a step back to choose between new user or existing user
- if email is in the database user is greeted with the username and with the last result achieved while using the program
- user story covered: 15,3,16
- user can start creating players inside given parameters
- if the input is not inside the parameters user is asked to repeat the input along with a message that gives instructions on valid inputs
- user story covered: 6,9,13,14,10
- table with user input values for each created player
- user story covered: 4,15,7
- User can choose from range of training options and pick 3 for each player input validation implemented
- user story covered: 9,7,2
- trainings for a player is displayed after choosing 3 options
- user story covered: 7,15
- User i presented with meal options for each player and have to assign 3 options for each player
- user story covered: 9,6,10,7
- meals for each player is displayed after every 3 meals choosen
- user story covered: 7,15
- Calculated value for each player ,values will be used to determine final result
- user story covered: 15,4,7
- user is presented with a final result of the program team performance percentage based on inputs given and the user is greeted with a thank you message
- user story covered: 11,18
- user has 2 options to choose to go again or to exit the program
- if go again is chosen user final result achieved is deleted from the database and it will be updated with a new result at the end
- is exit option is chosen program is terminated
- user story covered: 8,2,12
- Displays an error message if user input is not in a form that was expected or inside given parameters
- Asks for new input and provides guidance to user on how to make valid input
- User stories covered: 5,6,13,15
Validation of in-program inputs Screenshot
- Future development of this program would very likely include
- Training options for longer periods of time(week)
- Diet schedule period of (week or more)
- Rest schedule period of(week or more)
- Implementing calculation of training impact to the individual athlete and adding that calculation to the final percentage
- Since PEP8 Validation Service site is down and can't be used PEP8 validator "pycodestyle" was installed directly to Gitpod Workspace and I'm uploading images of all python files in my project. All files are cleared of errors and are up to PEP8 standards (if there were any errors there would be a red line inside my source code)
The testing approach is as follows:
- Manual testing of user stories
- Automated unit testing using the Python unittest library
User stories testing
- I want to have an idea what the program is about
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Intro screen | User is presented with an intro text | Intro screen presented | Works as expected |
Program instructions | User is presented with Program instructions screen | instructions screen presented | Works as expected |
- I want to be able to have clear and simple navigation
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Options menu 1 | Select between 2 options | user is taken to options menu 2 (where new or existing user option is presented ) or user is exiting the program | Works as expected |
Options menu 2 | Select between 2 options | use can create a new user or log in as an existing one | Works as expected |
End or play again menu | Select between 2 options | user can go agin and go through program or exit the program | Works as expected |
- I want to be able log in and return to a program later
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Create user(Sign-up) | User is choosing new user option | User is prompted to put a username and valid email address | Works as expected |
Validate existing user(Log-in) | User is choosing existing user option | User is prompted valid email address if email is in database user is greeted with username and can proceed to using program | Works as expected |
- I want to be able to get feedback in different stages of program
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Created players table | expected from user to put in valid inputs | Table with input values is presented | Works as expected |
Calculated values table | user inputs expected to be valid | Table with Calculated values is presented | Works as expected |
- I want to be informed why my input is not valid
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
user input validations | user input is outside parameters or invalid | Red text displayed informing user on invalid input | Works as expected |
- I want input parameters to be displayed clearly
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Creating players | parameters for input displayed | user inputs valid input | Works as expected |
Meals Menu | parameters for input displayed | user inputs valid input | Works as expected |
- I want to see what choices i made
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Created players table | user inputs are valid | table is presented to user | Works as expected |
Trainings-choosed | user inputs are valid | training choices are displayed | Works as expected |
Meals-choosed | user inputs are valid | meal choices are displayed | Works as expected |
- I want to be able to play multiple times without loging in again
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
End or play again menu | All input values are valid | End game menu presented | Works as expected |
- I want to use the program with real-world data
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Creating players | user credentials are validated | real-world parameters presented to user | Works as expected |
Trainings menu | user successfully created players | real-world parameters presented to user | Works as expected |
Meals Menu | user assigned trainings to players | real-world parameters presented to user | Works as expected |
- I want to use the program that allows certain creativity inside parameters
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Creating players | user credentials are validated | various inputs inside parameters give creativity to user | Works as expected |
- I want to know the final result of using the program
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Final value and thank you note | all previous inputs were valid | user presented with final team performance value | Works as expected |
- I want user to easily and intuitevly navigates troughout program
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Options menu 2 | user can choose between 2 options | user taken to the desired direction depending on input | Works as expected |
End or play again menu | user can choose between 2 options | user taken to the desired direction depending on input | Works as expected |
- I want user to be guided and informed how to make valid inputs
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
User Input Validation | user input is outside parameters or invalid | Red text displayed informing user on invalid input | Works as expected |
- I want user to be able to personalize his experience and inputs
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Creating players | user input can be anything inside given parameters | personalized valid input and experience | Works as expected |
Create user(Sign-up) | user input can be anything inside given parameters | personalized valid input and experience | Works as expected |
- I want user to have clear feedback of inputs
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Training choosed | valid training inputs | trainings choosed presented to user | Works as expected |
Meals choosed | valid meal inputs | meals choosed presented to user | Works as expected |
Created players table | valid inputs when creating players | table with player values presented | Works as expected |
- I want user details to be stored and retrieved on demand into the database
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Create a user(Sign-up) | input valid credentials for user | user credentials stored in database | Works as expected |
Validate existing user(Log-in) | input valid email | email is retrieved from database and user is greeted | Works as expected |
- I want user to have option to exit the program
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Options menu 1 | user can choose an option to exit program | program is terminated | Works as expected |
End or play again menu | user can choose an option to exit program | program is terminated | Works as expected |
- I want user to know the final result
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Final value and thank you note | after all inputs are valid and inside given parameters | final result presented | Works as expected |
unit testing
- Tests are run using Python unittest library
- Since i was introduced to "unit testing " when most of the source code for the program was almost finished only a small part of the project was tested.
- User score function was tested for various inputs.
- when tested with empty string input typeError should be raised (since function is appending score value that should be int. or float value) so I had to write some more validation for this function
- After adding code so that typeError is raised on invalid input unit test passed
- Testing display menu function in (validate.py) file since this function is more complex and the function that is called from that function is based on user input after doing research and getting a question answered on stackoverflow,only behaviour of the function is tested. and after both tests passed function is calling the right function based on user input
Bug | Fix |
---|---|
In validating user inputs when creating player pycodestyle was warning about "too broad exception" in the while loop. | add "ValueError" when catching the exception with a suitable error message |
When breaking a too-long line of code forgot to put "backslash(\ )" to move on next line and didn't match the previous indentation |
putting "backslash(\ )" when moving on next line and press (tab) |
to match previous line indentation | |
when using Colorama and the keyword "Fore" to color the choices that require user input ,user input was in the last color of choice(red) | I colored the blank space white before closing the colored choices line so any input after that would be in white color |
When creating subclass palyer in a for loop and keyword range i set the wrong range cause last number in range is not included | change last number in range to one greater |
The Application has been deployed from GitHub to Heroku by following the steps:
-
Create or log in to your account at heroku.com
-
Create a new app, add a unique app name ( for example PP3_The_Coach) and then choose your region
-
Click on create app
-
Go to "Settings"
-
Under Config Vars store any sensitive data you saved in .json file. Name 'Key' field, copy the .json file and paste it to 'Value' field. Also add a key 'PORT' and value '8000'.
-
Add required buildpacks (further dependencies). For this project, set it up so Python will be on top and Node.js on bottom
-
Go to "Deploy" and select "GitHub" in "Deployment method"
-
To connect Heroku app to your Github repository code enter your repository name, click 'Search' and then 'Connect' when it shows below
-
Choose the branch you want to buid your app from
-
If prefered, click on "Enable Automatic Deploys", which keeps the app up to date with your GitHub repository
-
Wait for the app to build. Once ready you will see the “App was successfully deployed” message and a 'View' button to take you to your deployed link.
- Go to the GitHub repository
- Click on the Fork button in the top right corner
- Copy of the repository will be in your own GitHub account.
- Go to the GitHub repository
- Locate the Code button above the list of files (next to 'Add file') and click it
- Highlight the "HTTPS" button to clone with HTTPS and copy the link
- Open Git Bash
- Change the current working directory to the one where you want the cloned directory
- Type git clone and paste the URL from the clipboard ($ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY)
- Press Enter to create your local clone
-
gspread documentation explained how to create read update and delete values in the google spreadsheet
-
CalorieNinjas-API-Documentation - helped me in making a function that calculates the caloric value of user choices for each player.
-
ASCII Art Generator was used to create program title
-
Code Institute - "Love Sandwiches - Essentials Project" walkthrough helped me to connect Google Spreadsheet to my project.
-
How to install a Python module, eg. email validation
-
How to add colored text to Python terminal colorama(0.4.5)
-
code used to clear the terminal console
-
you tube channel-code and help in better understanding unit test
-
stackoverflow-user- for clearing up how to write unit test for more complex function and using mock in unit test
-
stackoverflow-added functionality that user cannot type into the terminal unless program is asking for an input
I would like to take a few moments to say Thank you to the following people:
-
First, I would like to thank my wife Una, and my daughter Tara for their continuous support and understanding while working on the development of this project.
-
I would like to thank my Mentor Mo.Shami for his support, insight expertise, and guidance.
-
Warwick Hart for some great ideas and feedback when reviewing the project.
-
Awesome Code Institute Slack community for being there