Table of Contents
This project is built to help users track their daily consumed food calories;which can be very helpful for diabetic and people who follow diatery.This web Application is built to help them store their daily foods and automatically calculate and summaries their calories intake.
What can this web app do:
- Let users enter their food types and the nutrient amount of protein,fat and carbohyderates contained in it , then it calculate the calories by applying the following formula : Calories=(Protein+Carb) x 4 + Fat x 9
- User can also update the previously entered food.
- User then can enter the date to track the consumed food , and add foods to this date.
- User then can see all the saved days , and he can delete it .
Here you are screenshots of the application depcting the web app functionality.
To design this simple MVP , I have designed the database to store user's data in 3 relations as show in the following picture.
As shown in the design of the database the primary key is ID , which is autogenerated number, for relations log_date and food.The food date relation which store the the food aten in a day , have a composite primary key (log_date_id,food_id), which reference log_date.id and food.id respectively.
This project built using the following technologies .
This section gives instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
This is an example of how to list things you need to use the software and how to install them.
Note: These steps is relevant to linux environments
- Clone the repo
git clone https://github.com/mhallaq/flask-calories-tracker.git
- Install Python virtual environment
sudo apt install python3-venv
- Create virtual environment
env_namepython3 -m venv env_name
- Activate virtual environment
. ./projectenv/bin/activate - Install required python packages
pip3 install -r requirements.txt
To get the test running , you need to create a test db in mysql with the same schema as in the production environment.Then update the SQL_URI in the test script.
pytest --cov=app
or
pytest --cov=app --cov-report html
You need WISGI server such as Gunicorn. If it's not installed run
sudo apt-get install gunicorn
To start the server run
gunicorn --workers=2 --bind=0.0.0.0:5000 app:app
you can change the worker parameters and the port above as per your need.
Here is a a sample of the test coverage result html report, generated by the Pytest-cov .
Use this application to track your daily food calories .Please see appliction screenshots below.
A list of commonly used resources that I find helpful are listed in the acknowledgements.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Mohammed Alhallaq
Project Link: https://github.com/mhallaq/flask-calories-tracker




