An open-sourced backend for the Eatery application, available on Android and iOS.
Technologies involved include:
- Flask
- GraphQL
Virtualenv setup!
virtualenv -p python3.7 venv
source venv/bin/activate
pip install -r requirements.txt
It's recommended to use direnv
.
The required environment variables for this API are the following:
To use direnv
with this repository, run the following and set the variables appropriately.
cp envrc.template .envrc
Flake 8: Install flake8
Black: Either use command line tool or use editor extension.
If using VS Code, install the 'Python' extension and include following snippet inside settings.json
:
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "black"
sh start_server.sh
The flask app runs on your 'localhost' via port 5000.
*NOTE: App may take up some time before starting because it needs to fetch and parse data at start up.
src.database
: models for dbsrc.eatery_db
: parse raw data and store into dbsrc.gql_parser
: fetch data from db and put into graphQL typessrc.gql_types
: graphQL types
Campus eateries are updated at app start-up and at regularly scheduled hours.
Regular updates are scheduled as cron job in update_db.txt
. Note that cron uses UTC timezone so 0 9,15,21 * * *
refers to daily updates at 5AM, 11AM, 5PM EST. The updates are scheduled at hours within close range of dining hall opening hours because dining hall menus are updated by Cornell at random times.
Collegetown updates are run only at app start-up since data on Yelp doesn't change frequently. To run manual updates, execute python update_ctown.py
in docker container.
Also refer to #193 to see why ctown update isn't scheduled as cron job.
Hello, World!
This endpoint gives graphQL interface, GraphiQL, where you can construct queries and request data. Refer to the documentation in GraphiQL to view the nested data structure of query.
This should show names of all campus eateries in database.
{
campusEateries {
name
}
}
This should be an extensive query that contains (almost) all the nested fields for eateries.
{
campusEateries {
coordinates {
latitude
longitude
}
eateryType
id
imageUrl
name
paymentMethods {
brbs
cash
cornellCard
credit
mobile
swipes
}
paymentMethodsEnums
phone
about
campusArea {
descriptionShort
}
expandedMenu {
category
stations {
category
items {
item
healthy
choices {
label
options
}
price
}
}
}
location
nameShort
operatingHours {
date
events {
calSummary
description
endTime
menu {
category
items {
item
healthy
}
}
startTime
}
}
slug
swipeData {
endTime
sessionType
startTime
swipeDensity
waitTimeHigh
waitTimeLow
}
}
collegetownEateries{
coordinates{
latitude
longitude
}
eateryType
id
imageUrl
name
paymentMethods {
brbs
cash
cornellCard
credit
mobile
swipes
}
paymentMethodsEnums
phone
address
categories
operatingHours{
date
events {
description
endTime
startTime
}
}
price
rating
ratingEnum
url
}
}