Application Logic


Although we have a general idea of how Chicken Tinder would work and look, it is difficult to imagine how data work underneath the hood. Therefore, we created the logical flowchart above and layout how the data flow between the host (client), other users(client), backend server, and database.

Creating a flock

When the host decided to create a flock for the group, the application will ask for a nickname, a group name, and the target location, and send a POST request to the server. Then the server will generate a group id as well as store the data in a NoSQL database. The server will also respond to the POST request with all the information sent by the host well as a unique flock id. Now a flock has successfully been created.

Joining a flock

After the flock id has been created, the front end of Chicken Tinder will generate a URL for sharing with the flock id as the query parameter. Then the host can share the URL via any platform with other users. Other users can join the flock by clicking on the link and automatically launching the page for joining the flock with the group name as well as the host’s name. Each user will enter their nickname and the application will send a PUT request with the flock id and username to the server. Then the server will add the username under the flock id and redirect the user to a tutorial page. Now individual users has successfully joined the flock.

Before voting

On the quick tutorial page, the front end of the application will get a list of nearby restaurants from the server in the background, which was redirected from Yelp Fusion. However, the server would also create a list of restaurant ids under the created flock id. Now each individual user will be received an identical array of restaurant data, including restaurant name, address, rating, review counts, and so much more.

Voting

After each user received an array of restaurant data, each restaurant will be displayed on the screen one by one and be voted by the users. Each swipe will increment the votes of the restaurant (2 votes for up swipe, 1 vote for right swipe, and 0 for left swipe). Each vote will send a put request with the restaurant id, flock id, and user id to the server, which will be stored in the database. Now each user can vote for each restaurant available until all restaurants are voted on.

Displaying result

After each user has voted on all the restaurants, the user will be redirected to a waiting page. The periodic GET request will be made to the server for the current most voted restaurant. After all the users finished voting, the response to the GET request will include a flag indicating that all users have voted. Once that flag is received, the most-voted restaurant will be displayed with additional information including external links (if available) to the delivery app, navigation, phone, and Yelp page.

The following is how data are stored in the NoSQL database:

{
  "flockId": "12345",
  "flockName": "Group Lunch",
  "host": "charlie666",
  "location": {
    "longitude": 123.45,
    "latitude": -678.90
  },
  "users": [
    {
      "id": "charlie666",
      "name": "Charlie",
      "vote": 17
    },
    {
      "id": "Sravya777",
      "name": "Sravya",
      "vote": 18
    },
    {
      "id": "steven888",
      "name": "Steven",
      "vote": 19
    }
  ],
  "votes": {
    "u4sTiCzVeIHZY8OlaL346Q": 0,
    "woXlprCuowrLJswWere3TQ": 1,
    "JLbgvGM4FXh9zNP4O5ZWjQ": 2
  },
  "restaurant": {
    "u4sTiCzVeIHZY8OlaL346Q": {
      "id": "u4sTiCzVeIHZY8OlaL346Q",
      "alias": "gaucho-parrilla-argentina-pittsburgh",
      "name": "Gaucho Parrilla Argentina",
      "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/qTosLFGIaRfWWolSSWXfgA/o.jpg",
      "is_closed": false,
      "url": "https://www.yelp.com/biz/gaucho-parrilla-argentina-pittsburgh?adjust_creative=4NyEZ_ADjDEi-lQ7QpfThw&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4NyEZ_ADjDEi-lQ7QpfThw",
      "review_count": 2191,
      "categories": [
          {
              "alias": "argentine",
              "title": "Argentine"
          }
      ],
      "rating": 4.5,
      "coordinates": {
          "latitude": 40.442788,
          "longitude": -80.002485
      },
      "transactions": [
          "delivery"
      ],
      "price": "$$",
      "location": {
          "address1": "146 Sixth St",
          "address2": "",
          "address3": "",
          "city": "Pittsburgh",
          "zip_code": "15222",
          "country": "US",
          "state": "PA",
          "display_address": [
              "146 Sixth St",
              "Pittsburgh, PA 15222"
          ]
      },
      "phone": "+14127096622",
      "display_phone": "(412) 709-6622",
      "distance": 608.0607898262963
    }
  }
}

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *