A web application providing customized recipes created by the YumBot
Read more about this project here
First, get a Spoonacular API key by visiting this site. Select the basic plan. Then, in the Rapid API dashboard, click "Add New App" on the left navigation bar. Name the application "YumBot". YumBot should not show up in your "My Apps" section on the left navigation bar. Then, select YumBot and in the dropdown menu, click on "Security". You should be able to see your API key. Copy this key and set it as an environment variable on your machine by typing this command in a terminal window
export SPOONACULAR_API_KEY=<your-key>
Then, ensure that you have Python version 2.6+ installed on your machine. To confirm, open a terminal and run the following command to ensure that python is installed and it is the correct version.
python --version
Then,
git clone https://github.com/SrutiG/YumBot.git
cd YumBot
pip install --user -r requirements.txt
chmod +x run.py
./run.py
A page should appear saying Hello World.
This application currently uses a SQLite database generated in the app folder. In order to create the database, run the following commands.
chmod +x db_create.py && chmod +x db_migrate.py
./db_create.py
./db_migrate.py
The file modify_db.py can be used to add/remove recipes from the database and run algorithms. Make sure it has executable permissions by running the following command
chmod +x modify_db.py
Then, run it with your chosen arguments.
./modify_db.py [args]
These are the available arguments
argument name | type | default value | possible values | description |
---|---|---|---|---|
action | string | add | add, remove, matrix, pca, kmeans, add_calc, remove_calc | add: add recipes to the database. Use numrecipes arg to set number of recipes to add. Default is 10 remove: remove recipes from the database. Use numrecipes flag to set number of recipes to remove. matrix: recreate the co-occurrence matrix based on current recipes in the database. This is done automatically after adding recipes. pca: calculate pca coordinates based on current co-occurrence matrix. kmeans: calculate kmeans clusters based on pca coordinates. add_calc: add recipes to database, calculate pca coordinates and kmeans coordinates. Use numrecipes to set number of recipes to add. remove_calc: remove recipes from database. calculate pca coordinates and kmeans coordinates. Use numrecipes to set number of recipes to remove. |
numrecipes | int | 10 | any integer >= 0 | number of recipes to add or remove from the database |
components | int | 24 | any integer between 0 and 24 | number of PCA components |
clusters | int | 35 | any positive integer | number of k-means clusters |
Create new endpoints for the application in the file app/views.py
Currently there is a layout.html file in app/templates which contains the topbar, headers, and links to the css and js files in app/static/css/index.css and app/static/js/index.js. Create new templates which extend layout.html.
Co-occurrence matrix: app/cooccur.py K-Means: app/kmeans.py PCA: app/pca.py
The YumBot class is located in app/yumbot.py. It is used to check if ingredients are compatible and create new recipes.
The database schema is located in app/models.py. After making changes to this schema, make sure you create new migrations by running the command
./db_migrate.py
By default, this application runs on 127.0.0.1:8095. Change the default host and port in run.py or run it on a different host and port using the --host and --port flags. For example,
./run.py --host <your-host> --port <your-port>