Giter VIP home page Giter VIP logo

macro-calculator's Introduction

Macro Calculator

Macro Calculator mockup image

Macro Calulator is designed to help the users discover how much of each macronutrient they should eat every day to reach the desire goal.

There are three principal classes of macronutrients: carbohydrate, protein, and fat. Balancing these nutrients is a crucial element of success to any workout goal, whether looking to build muscle, lose fat, or improve athletic performance.

Visit the deployed application here.

Table of Contents

  1. User Experience (UX)
    1. Project Goals
    2. User Stories
    3. Color Scheme
    4. Data Model
    5. Flowchart
  2. Features
    1. User Information Input
    2. System of Measurement Selection
    3. Activity Level Selection
    4. Goal Selection
    5. Diet Selection
    6. Review Data
    7. BMR Calculator
    8. TDEE Calculator
    9. Calories Goal Calculator
    10. Macronutrients Calculator
    11. Restart Program
  3. Technologies Used
    1. Language Used
    2. Frameworks, Libraries and Programs Used
  4. Testing
    1. Testing User Stories
    2. Code Validation
    3. Manual Testing
  5. Deployment
  6. Credits
  7. Acknowledgements

User Experience (UX)

Project Goals

  • Display enough information about the calculator in order to make it easy to understand even for first time users.

  • Each step provides the necessary information to make the program clear and intuitive.

  • Provides input validation to help the user input the correct data.

  • The program should keep running until the user decides otherwise.

User Stories

  • As a user, I want to receive information about the main objective of the program.

  • As a user, I want to easily understand what input is needed on each step.

  • As a user, I want to receive clear feedback in case I provide the wrong input.

  • As a user, I want to be able to review the data I provided and correct it if needed.

  • As a user, I want the calculations to be displayed in a clear way and to be easy to understand.

Color Scheme

Colorama has been used to apply color to the terminal text. This in order to make the program more intuitive and easier to read.

Here are the colors being used:

  • Inputs are displayed in light green.

  • Data and the main logo is displayed in light yellow.

  • Errors are displayed with a red background.

  • Some extra information has been displayed in dim text.

  • Messages are displayed in the default terminal color.

Data Model

Simple data as the name, age, weight and height are being returned and stored as variables in order to access them in the future to display the data back to the user or to make calculations.

The unit selector returns 1 or 2 to be able to use them in if statements to choose different paths in the logic.

More complex data as the gender, activity level, user's goal and diet is being stored as dictionaries as they contain a description of the selection to display back to the user, but also contain values to use in the different calculations.

Calculations are stored as variables to be able to format them and display them back to the user.

Flowchart

The following flowchart was designed using Miro in order to plan the logic to be implemented in the program.

Macro Calculator Flowchart

As shown in the flowchart, the original order of some functions has been changed during the development process in to follow a more intuitive logic and sequence of events but the main idea behind the process is still the same.

Back to top ⇧

Features

User Information Input

Collect the users information in order to use it in the program.

User Information Input

Due to the biological characteristics needed for the BMR calculation, sex has been used over gender.

System of Measurement Selection

Allow the users to select the System of Measurement they are more confortable with.

System of Measurement Selection

Activity Level Selection

Allow the users to select their activity level in order to calculate the total daily energy expenditure (TDEE) based on this activity level.

Activity Level Selection

Goal Selection

Allow the users to select their desired goal . The program will then use this goal to calculate the total daily calories and the macronutrients split based on this goal.

Goal Selection

Diet Selection

Allow the users to select thier prefered diet. This diet will dictate the split of the macronutrients.

Diet Selection

Review Data

Allow the users to review the data input and give them the possibility to enter the data again if a mistake has been made.

Review Data Review Data Question

BMR Calculator

The program use the Mifflin-St Jeor formula to calculate the user's basal metabolic rate (BMR) using the input provided.

BMR

Mifflin-St Jeor Formula

Male BMR = [9.99 x weight (kg)] + [6.25 x height (cm)] – [4.92 x age (years)] + 5

Female BMR = [9.99 x weight (kg)] + [6.25 x height (cm)] – [4.92 x age (years)] – 161

TDEE Calculator

The program use the the value of the selected activity level multiplied by the BMR to calculate the user's total daily energy expenditure (TDEE)..

TDEE

Activity Level Value
No activity: 1.2
A little activity: 1.375
Some activity: 1.55
A lot of activity: 1.725
A TON of activity: 1.9

Calories Goal Calculator

Calculate the total daily calories to be consumed by using the value of the selected goal multiplied by the TDEE.

Calories Goal

Lose Weight

Rate Value
Slow 0.91
Moderate 0.82
Fast 0.65

Maintain Weight

Keeps the same TDEE value.

Gain Weight

Rate Value
Slow 1.08
Moderate 1.17
Fast 1.34

Macronutrients Calculator

Use the macronutrient split returned when the diet is selected in order to calculate the macronutrients in grams to be consumed every day.

Macronutrients

Macronutrients Split Percentage

Diet Protein Carbs Fat
Balanced 40% 30% 30%
Low-carb 40% 20% 40%
High-carb 30% 50% 20%
High-protein 40% 20% 40%
Ketogenic 40% 10% 50%

Restart Program

Allow the user to keep running or exit the program.

Program Loop Question

Future Features

Custom Macronutrients Split

The developer is planning to implement the possibility to input custom macronutrients split when selecting the diet. This will be done by selecting a custom diet and then entering a percentage for each macronutrient (protein, carbs and fat).

It was decided not to implement this feature at this point as it became bit confusing for the user. Once this feature is implemented it will need to be very intuitive to use.

Back to top ⇧

Technologies Used

Language Used

Frameworks, Libraries and Programs Used

  • GitPod was used for writing code, committing, and then pushing to GitHub.

  • GitHub was used to store the project after pushing.

  • Heroku was used to deploy the application.

  • PEP8 online check was used to validate the Python code.

  • PrettyTable library was used to present the data in table format.

  • Colorama library was used to apply color to the terminal text.

  • Miro was used to create the program flowchart.

Back to top ⇧

Testing

Testing User Stories

  • As a user, I want to receive information about the main objective of the program.

    • Information about the program is presented in the welcome message explaining the use of the application.

    • Details are provided together with the results to further explain the different terms.

  • As a user, I want to easily understand what input is needed on each step.

    • Input messages are being provided with detailed information on what the input needs to be.

    • Input messages text is colored in light green to make them noticeable.

  • As a user, I want to receive clear feedback in case I provide the wrong input.

    • Error messages are provided explaining what is wrong with the input provided in case the wrong input is entered.

    • Some values as age, weight and height are being limited in order to gather the correct information and avoid mistypes.

    • Error messages have a red background to make them noticeable.

  • As a user, I want to be able to review the data I provided and correct it if needed.

    • Added a feature where the user can easily see the data entered and decide to continue or enter the data again.

    • The data is being presented in table format to make it easier to review.

    • The input data is colored in light yellow to make it as clear as possible.

  • As a user, I want the calculations to be displayed in a clear way and to be easy to understand.

    • Calculations are being formatted and presented at the end of the program with explanation for the different results.

    • The result data is colored in light yellow to make it as clear as possible.

Code Validation

The PEP8 online check was used continuosly during the development proces to validate the Python code for PEP8 requirements. For this reason no before and after snapshots are available.

PEP8 Code Validation

Manual Testing

Feature Outcome Example Pass/Fail
Name Input Validate if value is empty Name value is empty Pass
Age Input Validate if value is empty Age value is empty Pass
Validate if value is too low Age value is too low Pass
Validate if value is too high Age value is too high Pass
Validate if value is not an integer Age value is not an integer Pass
Sex Selection Validate if value is empty Sex value is empty Pass
Validate if invalid value Sex value is invalid Pass
Unit Selection Validate if value is empty Unit value is empty Pass
Validate if invalid value Unit value is invalid Pass
Weight Input Validate if value is empty Weight in kg value is empty Pass
Weight in lb value is empty
Validate if value is too low Weight in kg value is too low Pass
Weight in lb value is too low
Validate if value is too high Weight in kg value is too high Pass
Weight in lb value is too high
Validate if value is not an integer Weight in kg value not an integer Pass
Weight in lb value not an integer
Height Input Validate if value is empty Height in cm value is empty Pass
Height in inch value is empty
Validate if value is too low Height in cm value is too low Pass
Height in inch value is too low
Validate if value is too high Height in cm value is too high Pass
Height in inch value is too high
Validate if value is not an integer Height in cm value not an integer Pass
height in inch value not an integer
Activity Level Selection Validate if value is empty Activity level value is empty Pass
Validate if invalid value Activity level value is invalid Pass
Goal Selection Validate if value is empty Goal value is empty Pass
Validate if invalid value Goal value is invalid Pass
Rate Selection Validate if value is empty Lose weight rate value is empty Pass
Gain weight rate value is empty
Validate if invalid value Lose weight rate value is invalid Pass
Gain weight rate value is invalid
Diet Selection Validate if value is empty Diet value is empty Pass
Validate if invalid value Diet value is invalid Pass
Review Data Allow user to enter the data again Review data question Pass
Restart Program Keep running or exit the program Exit the program Pass
Restart the program

Back to top ⇧

Deployment

The application has been deployed using Heroku by following these steps:

Heroku was used to deploy the application.

  1. Create the requirements.txt file and run: pip3 freeze > requirements.txt in the console.
  2. Commit changes and push them to GitHub.
  3. Go to the Heroku's website.
  4. From the Heroku dashboard, click on "Create new app".
  5. Enter the "App name" and "Choose a region" before clicking on "Create app".
  6. Go to "Config Vars" under the "Settings" tab.
  7. Click on "Reveals Config Vars" and add the KEY: CREDS and the VALUE stored in creds.json file if needed.
  8. Add the Config Var, KEY: PORT and VALUE: 8000.
  9. Go to "Buildpacks" section and click "Add buildpack".
  10. Select "python" and click "Save changes"
  11. Add "nodejs" buildpack as well using the same process.
  12. Go to "Deployment method", under the "Deploy" tab select "GitHub" and click on "Connect to GitHub".
  13. Go to "Connect to GitHub" section and "Search" the repository to be deployed.
  14. Click "Connect" next the repository name.
  15. Choose "Automatic deploys" or "Manual deploys" to deploy your application.

Back to top ⇧

Credits

Content

Media

  • The ASCII art is a modified version of an original art created with ASCII-Generator.

Code

  • Stack Overflow was consulted on a regular basis for inspiration and sometimes to be able to better understand the code being implement.

Back to top ⇧

Acknowledgements

  • My partner, for her unconditional love, help and continued support in all aspects of life to make possible for me to complete this project.

  • My tutor, Marcel, for his invaluable feedback and guidance.

  • Code Institute and its amazing Slack community for their support and providing me with the necessary knowledge to complete this project.

macro-calculator's People

Contributors

josswe26 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.