Skip to content

tspoon1/restock

Repository files navigation

Restock.io

The application that aims to help users stay up to date on the prices/availability of the products they are looking for. Given uncertain times such as now, where COVID-19 has forced the supply of certain key products to change in price or become unavailable, there is a high demand for the updating of key product price and availability data. Our application aims to keep users informed on what is happening with their key products in a friendly and easy manner. Say goodbye to checking Amazon 24/7 for toilet paper :)

Prerequisites:

  • Anaconda 3.7
  • Python 3.7
  • Pip

Required Python Packages & Modules:

  • python-dotenv
  • os
  • datetime
  • sendgrid
  • flask
  • gunicorn
  • gspread
  • oauth2client
  • selenium
  • pytest

Setting up the Environment:

Before installing the requirements to run this, please make a virtual environment for your restock programs to live in by doing the following:

conda create -n restock-env python=3.7 # (first time only) <br />
conda activate restock-env 

Installation:

In order to set this project up, please download this repo and write into the command line:

git clone [email protected]:tspoon1/restock <br />
cd restock/ <br />

Proceed to download the following packages:

pip install -r requirements.txt

Getting a ChromeDriver

In order to get the reliance on selenium up and running that we need, make sure to ensure the chromedriver.exe is appropriate for the machine you are running it on. You can find a link to download these different drivers here:

Also, be sure to update your convironment variable CHROMEDRIVER_PATH that leads to the chrome driver, as this is a temporary fix to get the project running before we have full automatic emails with heroku in which case you won't need it!

Set Up

In addition to what was said above, make sure to configure your env to fit the required variables:

  • A SENDGRID_API_KEY
  • An email address to use for sending and receiving emailed alerts stored in EMAIL

The sendgrid Package

The sendgrid package provides emailing capabilities via the SendGrid Email Delivery Service. 📬 ✉️

Installation if you do not have it already

First, sign up for a free account, then click the link in a confirmation email to verify your account. Then create an API Key with "full access" permissions.

To setup the usage examples below, store the API Key value in an environment variable called SENDGRID_API_KEY. Also set an environment variable called MY_EMAIL_ADDRESS to be the email address you just associated with your SendGrid account (e.g. "[email protected]").

For information on how to obtain a Sendgrid API key and tempate (it's very easy by the way so don't be too concerned), check out these three explanatory links:

Deploying the local Flask version to online server (powered by Heroku)

If you are unfamiliar with or you have never used Heroku before, click the link below for a comprehensive guide (from Professor Rossetti) on Heroku, setting up an account, and getting it all running: https://github.com/prof-rossetti/intro-to-python/blob/master/exercises/web-service/deploying.md

If you haven't yet done so, install the Heroku CLI, and make sure you can login as well as list your applications.

heroku login # just a one-time thing when you use heroku for the first time

heroku apps # at this time, results might be empty-ish

Before you deploy to the server, you need to configure the server's environment: instead of using a ".env" file, we will directly configure the server's environment variables by clicking "Reveal Config Vars" from the "Settings" tab in your application's Heroku dashboard.

Deploying to Server

After creating a heroku app and configuring your env-variables whether through a CLI or the heroku website as outlined above, you'll need to utilize the special file called the "Procfile" in the root directory. This file is key because it essentially coordiantes with the Heroku server on which command to invoke to run the app.

Make a commit to the heroku app and utilize the already existing Procfile to launch the application.

git push heroku master

View the server logs and troubleshoot as necessary until you're able to see the application's home page in the browser.

heroku logs --tail

Google Sheet Setup:

After you can see your version of the Restock.io app running perfectly, you are almost there! Once you have done this, all you have to do is set up your google sheet.

You will need to utilize the gspread, Google Sheets API, in order to get a backend up and running. If you have never done this, below are a few awesome references to get going:

Sheet Basics

Ensure that your client_secret.json is in your root directory, and you have created a sheet that has the following contents in the following cells:

A1 = 'email'
B1 = 'url'

Testing

After doing all of the above, your front end should be able handle form inputs and store them appropriately in the google sheet you have made. If not, this may be a good time to utilize the test suit we have written for each one of our tests. Perform them by typing the following when in the root directory:

pytest

Code Climate Software Check:

To Restock, or not to Restock

Upon completion of everything above, you are good to go! Just make sure to keep an eye out for our v3.0 to release, where the google sheet will be automatically run-through and checked regularly by a herkou scheduled script. But for now, just type the following into your CLI a couple times a day to keep your own Restock users happy!

python app/email_runner.py

Goodluck and thank you for using Restock.io!

The Restock team <3

About

Will help notify people when items restock

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published