GithubHelp home page GithubHelp logo

tejasa97 / meals_suggestor Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 39 KB

Meals Suggestor is an app you can use to plan out your meals for the week to reach your fitness goals

Python 95.49% Dockerfile 2.20% Mako 2.31%
docker redis flask sqlalchemy-orm python

meals_suggestor's Introduction

Meals Suggestor

(As part of L**an challenge)

Meals Suggestor is an app you can use to plan out your meals for the week to reach your fitness goals.

  • Get multiple meal combo suggestions that comply with your planned calorie intake for the day
  • Save your chose meal combo to your weekly planner
  • View your weekly planner

Tech

Meals Suggestor uses a number of open source projects that comprise it's core components

Installation

Meals Suggestor can be built and run locally with docker and docker-compose

  1. Clone this repository
  2. Refer links docker-install and docker-compose-install to install the latest versions of docker and docker-compose (check system compatibility)
  3. (Optional) Sign up for Spoonacular and obtain an API KEY, and replace the existing key in the .env file (a working demo key is already in repository)
  4. Run the deployment with docker-compose
    $ docker-compose up --build
    Note:
    The deployment uses Nginx for reverse proxying the API calls and runs on port 8080, so if you have any webserver already running on port 8080, you will have to stop it.
    $ sudo service stop apache2

Usage

Meals Suggestor provides for 3 APIs, the instructions on using them are indicated below

REST APIs

  1. Get meal suggestions with max total calories for the day provided

    Request:

    $ curl 'http://localhost/api/meals/suggestion?calories=2000&day=Sunday' | json_pp

    Response:

    {
      "total_calories" : 1892,
      "meals" : [
         {
            "name" : "Freaky Hand Sandwiches",
            "calories" : 639,
            "meal_id" : 426892
         },
         {
            "calories" : 603,
            "meal_id" : 372675,
            "name" : "Torta della Nonna (Grandma's Cake)"
         },
         {
            "meal_id" : 9897,
            "calories" : 650,
            "name" : "Crouching Cabbage, Hidden Mushrooms"
         }
      ]
    }

    Every time the above API is called, a new meals combo is provided. The meal_id corresponding to the meal is utilised to confirm a particular meals combo, or individual meals from different combinations.

    The following API indicates how a meal combination (or meals from different combinations) can be confirmed to the day meal planner.

  2. Confirm a meals suggestion (or individual meals) for a day

    Request:

    $ curl --header "Content-Type: application/json" --request POST --data '{"day":"Sunday","calories":2000, "meal_ids":[426892, 372675, 9897]}' http://localhost/api/meals/confirm_suggestion | json_pp    

    Response:

    {
       "total_calories" : 1892,
       "meals" : [
          {
             "calories" : 639,
             "meal_id" : 426892,
             "name" : "Freaky Hand Sandwiches"
          },
          {
             "name" : "Torta della Nonna (Grandma's Cake)",
             "meal_id" : 372675,
             "calories" : 603
          },
          {
             "name" : "Crouching Cabbage, Hidden Mushrooms",
             "meal_id" : 9897,
             "calories" : 650
          }
       ]
    }
    Note:
    1. The daily plans can be added in any order (eg: Friday, Wednesday, Monday, etc)
    2. The plan for a day can be updated by issuing the API for the same day with the new desired meal_ids.

    To view the added meals combination in the weekly meal planner, you can use the following API.

  3. Get current weekly meal planner

    Request:

    $ curl http://localhost/api/meals/weekly_plan | json_pp

    Response:

    {
       "total_calories_week" : 1892,
       "plan" : [
          {
             "day" : "Sunday",
             "day_calories" : 1892,
             "meals" : [
                {
                   "calories" : 639,
                   "meal_id" : 426892,
                   "name" : "Freaky Hand Sandwiches"
                },
                {
                   "meal_id" : 372675,
                   "name" : "Torta della Nonna (Grandma's Cake)",
                   "calories" : 603
                },
                {
                   "calories" : 650,
                   "meal_id" : 9897,
                   "name" : "Crouching Cabbage, Hidden Mushrooms"
                }
             ]
          }
       ]
    }

    Below is an example weekly plan obtained after having confirmed meal suggestions for all days of the week
    Response:

    {
        "plan": [
            {
                "day": "Sunday",
                "meals": [
                    {
                        "meal_id": 508950,
                        "name": "Chocolate Pear Tartlets",
                        "calories": 430
                    },
                    {
                        "meal_id": 887560,
                        "name": "Chocolate Chip Strawberry Shortcakes",
                        "calories": 453
                    },
                    {
                        "meal_id": 526894,
                        "name": "Grilled Lime Chicken Leg Quarters",
                        "calories": 465
                    }
                ],
                "day_calories": 1348
            },
            {
                "day": "Monday",
                "meals": [
                    {
                        "meal_id": 406312,
                        "name": "Cherry Nut Ice Cream",
                        "calories": 613
                    },
                    {
                        "meal_id": 112134,
                        "name": "Baked Cauliflower Cheese Soup",
                        "calories": 622
                    },
                    {
                        "meal_id": 113845,
                        "name": "Autumn Parfait",
                        "calories": 621
                    }
                ],
                "day_calories": 1856
            },
            {
                "day": "Tuesday",
                "meals": [
                    {
                        "meal_id": 426892,
                        "name": "Freaky Hand Sandwiches",
                        "calories": 639
                    },
                    {
                        "meal_id": 372675,
                        "name": "Torta della Nonna (Grandma's Cake)",
                        "calories": 603
                    },
                    {
                        "meal_id": 9897,
                        "name": "Crouching Cabbage, Hidden Mushrooms",
                        "calories": 650
                    }
                ],
                "day_calories": 1892
            },
            {
                "day": "Wednesday",
                "meals": [
                    {
                        "meal_id": 206324,
                        "name": "Nilla Wafer-Banana Cake",
                        "calories": 932
                    },
                    {
                        "meal_id": 1142563,
                        "name": "Chocolate Pudding Pie",
                        "calories": 915
                    },
                    {
                        "meal_id": 590873,
                        "name": "Biscoff Marshmallow Pie",
                        "calories": 913
                    }
                ],
                "day_calories": 2760
            },
            {
                "day": "Thursday",
                "meals": [
                    {
                        "meal_id": 706965,
                        "name": "Chicken and Rice Noodle Stir-Fry with Ginger and Basil",
                        "calories": 338
                    },
                    {
                        "meal_id": 462117,
                        "name": "Asian Roll Lettuce Wrap",
                        "calories": 372
                    },
                    {
                        "meal_id": 160015,
                        "name": "Pan-Seared Halibut with Wine-Braised Leeks",
                        "calories": 346
                    }
                ],
                "day_calories": 1056
            },
            {
                "day": "Friday",
                "meals": [
                    {
                        "meal_id": 593243,
                        "name": "Chicken & Rice with Béchamel",
                        "calories": 933
                    },
                    {
                        "meal_id": 564354,
                        "name": "Apple Walnut Spinach Salad",
                        "calories": 929
                    },
                    {
                        "meal_id": 602612,
                        "name": "Spinach Mushroom and Bacon Cheese Fondue",
                        "calories": 881
                    }
                ],
                "day_calories": 2743
            },
            {
                "day": "Saturday",
                "meals": [
                    {
                        "meal_id": 1041378,
                        "name": "Candy Corn Cupcakes with Real Candy Corn Frosting #HalloweenTreatsWeek",
                        "calories": 544
                    },
                    {
                        "meal_id": 52768,
                        "name": "Double-Crust Cherry Tart",
                        "calories": 572
                    },
                    {
                        "meal_id": 247746,
                        "name": "Bacon Wrapped Stuffed Medjool Dates",
                        "calories": 549
                    }
                ],
                "day_calories": 1665
            }
        ],
        "total_calories_week": 13320
    }    
    Note:

    To add the meal plans afresh or delete all existing data(Postgres/Redis), you will need to stop and kill the running containers and then remove the Postgres and Redis v volumes that were created.

    $ docker rm -f $(docker ps -a -q)
    $ docker volume remove postgres_db redis_dump

meals_suggestor's People

Contributors

tejasa97 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.