Design of Yelp

Learn to fulfill the design requirements of the Yelp system.

We identified the requirements and calculated the estimations for our Yelp system in the previous lesson. In this lesson, we discuss the API design, go through the storage schema, and then dive into the details of the system’s building blocks and additional components.

API design

Let’s discuss the API design for Yelp.

Search

We need to implement the search function. The API call for searching based on categories like “cafes” will be:

search(category, user_location, radius)

Parameter

Description

category

This is the type of search the user makes—for example, a search for restaurants, cinemas, cafes, and so on.

user_location

This contains the location of the user who’s searching with Yelp.

radius

This is the specified radius where the user is trying to find the required category.

This process returns a JSON object that contains a list of all the possible items in the specified category that also fall within the specified radius. Each entry has a place name, address, category, rating, and thumbnail.

The API call for searching based on the name of a place like “Burger Hut” will be:

search(name_of_place, user_location, radius)

Parameter

Description

name_of_place

This contains the name of the place that the user wants to search for.

This process returns a JSON object that contains information of the specified place.

Add a place

The API call for adding a place is below:

add_place(name_of_place, description_of_place, category, latitude, longitude, photo}

Parameter

Description

name_of_place

This contains the name of the place, for example, "Burger Hut".

description_of_place

This contains a description of the place. For example, "Burger Hut sells the yummiest burgers".

category

This specifies the category of the place—for example, "cafe".

latitude

This tells us the latitude of the place.

longitude

This tells us the longitude of the place.

photo

This contains photos of the place. There can be a single or multiple photos.

This process returns a response saying that a place has been added, or an appropriate error if it fails to add a place.

Add a review

The API call for adding a place is below:

add_review(place_ID, user_ID, review_description, rating)

Parameter

Description

place_ID

This contains the ID of the place whose review is added.

user_ID

This contains the ID of the user who adds the review.

review_description

This contains the review of the place—for example, "the food and ambiance were superb".

rating

This contains the rating of the place—for example, 4 out of 5.

This process returns a response that a review has been added, or an appropriate error if it fails to add a review.

Storage schema

Let’s define the storage schema for our system. A few of the tables we might need are “Place,” “Photos,” “Reviews,” and “Users.”

Let’s define the columns of the “Place” table:

  • Place_ID: We use the sequencer to generate an 8 Bytes (64 ...

Access this course and 1400+ top-rated courses and projects.