Skip to content

mhallaq/flask-calories-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calories Tracker App

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgements

About The Project

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.


Application design


To design this simple MVP , I have designed the database to store user's data in 3 relations as show in the following picture.

ER diagram


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.


Built With:

This project built using the following technologies .

Getting Started

This section gives instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

Building the application

Note: These steps is relevant to linux environments

  1. Clone the repo
    git clone https://github.com/mhallaq/flask-calories-tracker.git
  2. Install Python virtual environment
    sudo apt install python3-venv
  3. Create virtual environment env_name
    python3 -m  venv env_name
  4. Activate virtual environment
    . ./projectenv/bin/activate
    
  5. Install required python packages
    pip3 install -r requirements.txt
    

Testing the application

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


Deploying the application

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 .

Coverage Test HTML Result

Usage

Use this application to track your daily food calories .Please see appliction screenshots below.


Application Screenshots


Home Page

Home Page

Add Food's nutrients and Calories Page

Add Food

A list of commonly used resources that I find helpful are listed in the acknowledgements.

Adding food intake

Add food intake in a day

Contributing

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Mohammed Alhallaq

Project Link: https://github.com/mhallaq/flask-calories-tracker

Acknowledgements

About

Calories tracking Flask Web App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors