We are here to help you make that dreaded decision: Where are we eating? Provide your zip code and we will show you a list of open restaurants. Pick your top 3 and share them with your friends or family to get their 1st, 2nd, and 3rd choice. We will tally the rankings and show you all the winning restaurant. Let's go eat!
This repo houses What We Eatin'? Back-End. It has a combination of ReST API and GraphQL API, both built with Ruby on Rails and PostgreSQL. It provides data from Yelp API and logic to a React Front-End.
- Getting Started
- Front-End Repo
- Running the tests
- Architecture
- DB Schema
- Endpoints
- Built With
- Versioning
- Credits
To get your local/development environment running, please fork and clone down the repo:
$ git clone git@github.com:WhatWeEating/back-end-wwe.git
- You can find more information about the application at GitHub Repo
- Visit the deployed application on Heroku
To run this application you will need Ruby 2.5.3 and Rails 5.2.6
Once you have forked and cloned the repo:
-
Install the gem packages using Bundler
$ cd back-end-wwe $ bundle install
-
Start with a clean database
$ rails db:{drop,create,migrate,seed}
RSpec testing suite is utilized for testing this application.
- Run the test suite and access test coverage files
$ bundle exec rspec $ open coverage/index.html
The following is a depiction of the overall architecture for this application which includes a JavaScript Front-End application and a Rails Engine on the Back-End that calls out to Yelp's API.
The following is a depiction of our Database Schema
GET https://back-end-wwe.herokuapp.com/restaurants?zip=<5-digit-code>
- Required params: valid 5-digit zip code
- Required headers: unique event ID
- Limited results: 15 restaurants
Example response (expand)
{
"data": [
{
"id": "AKqb9TR9QdzJ1qdu8tkTzA",
"type": "restaurant",
"attributes": {
"name": "Hair of the Dog Eatery",
"image": "https://s3-media3.fl.yelpcdn.com/bphoto/gwaFPzFHysAIJ6e5YC2exQ/o.jpg",
"rating": 4.0,
"price": "$$",
"address": "4000 Virginia Beach Blvd, Ste 210, Virginia Beach, VA 23452",
"phone": "(757) 321-2200"
}
},
{
"id": "BfRDJuCXGJTYspHHgEN4zg",
"type": "restaurant",
"attributes": {
"name": "Mazari Kebab and More",
"image": "https://s3-media2.fl.yelpcdn.com/bphoto/O8HcqBaWHv_oHQ5U5wk6IA/o.jpg",
"rating": 4.5,
"price": "$$",
"address": "676 N Witchduck Rd, Virginia Beach, VA 23462",
"phone": "(757) 961-5968"
}
},
{
"id": "HH0O-DJNF34-SMmhKkK-AA",
"type": "restaurant",
"attributes": {
"name": "The Route 58 Delicatessen",
"image": "https://s3-media4.fl.yelpcdn.com/bphoto/SWhB05QOOBLuhk5Sw9uylw/o.jpg",
"rating": 4.5,
"price": "$$",
"address": "4000 Virginia Beach Blvd, Ste 156, Virginia Beach, VA 23462",
"phone": "(757) 227-5868"
}
}
]
}
POST https://back-end-wwe.herokuapp.com/graphql
Example query (expand)
mutation {
createRestaurants(input: {
params: {
first: {
eventId: "1234500",
yelpId: "f00d1sLyf311",
image: "website",
address: "578 st",
phone: "125405648",
name: "Cuisine All"
},
second: {
eventId: "1234500",
yelpId: "Gr2bs00menOMNoms",
image: "webpage",
address: "3 ave",
phone: "458405648",
name: "All the Yums"
},
third:{
eventId: "1234500",
yelpId: "suPP0fd2D2y",
image: "imageaddress",
address: "5 st",
phone: "966405648",
name: "Nom Noms for Dayz"
}
}}) {
restaurant {
name
phone
address
votes
}
}
}
Example response (expand)
{
"data": {
"createRestaurants": {
"restaurant": [
{
"name": "Cuisine All",
"phone": "125405648",
"address": "578 st",
"votes": 0
},
{
"name": "All the Yums",
"phone": "458405648",
"address": "3 ave",
"votes": 0
},
{
"name": "Nom Noms for Dayz",
"phone": "966405648",
"address": "5 st",
"votes": 0
}
]
}
}
}
POST https://back-end-wwe.herokuapp.com/graphql
Example query (expand)
mutation {
updateRestaurants(input: {
params: {
first: {
eventId: "1234500", yelpId: "f00d1sLyf311"
},
second: {
eventId: "1234500", yelpId: "Gr2bs00menOMNoms"
},
third: {
eventId: "1234500", yelpId: "suPP0fd2D2y"
}
}
}) {
restaurant {
yelpId
votes
name
}
}
}
Example response (expand)
{
"data": {
"updateRestaurants": {
"restaurant": [
{
"yelpId": "f00d1sLyf311",
"votes": 3,
"name": "Cuisine All"
},
{
"yelpId": "Gr2bs00menOMNoms",
"votes": 2,
"name": "All the Yums"
},
{
"yelpId": "suPP0fd2D2y",
"votes": 1,
"name": "Nom Noms for Dayz"
}
]
}
}
}
POST https://back-end-wwe.herokuapp.com/graphql
Example query (expand)
{
fetchEvent(uid: "1234500") {
uid
restaurants {
name
yelpId
votes
}
}
}
Example response (expand)
{
"data": {
"fetchEvent": {
"uid": "1234500",
"restaurants": [
{
"name": "Cuisine All",
"yelpId": "f00d1sLyf311",
"votes": 3
},
{
"name": "All the Yums",
"yelpId": "Gr2bs00menOMNoms",
"votes": 2
},
{
"name": "Nom Noms for Dayz",
"yelpId": "suPP0fd2D2y",
"votes": 1
}
]
}
}
}
- Ruby
- Rails
- GraphQL/GraphiQL
- Fast JSON API
| RSpec | Faker | VCR/Webmock | Shoulda Matchers | SimpleCov | Orderly |
- Ruby 2.5.3
- Rails 5.2.6
Ashish Malla GH | Patrick Findley GH | Matt Craig GH |
|
|
|
Diana Buffone GH | Logan Anderson GH |
|
|
Leta Keane GH | Robert Gu GH |
|
|
This project was created for Turing School of Software and Design