Skip to content

Latest commit

 

History

History
235 lines (162 loc) · 7.12 KB

README.md

File metadata and controls

235 lines (162 loc) · 7.12 KB

Delphi System Designs

Delphi System Designs is a back-end focused initiative that optimized inherited front end legacy code. The front-end consists of the Ratings and Reviews module of a single page e-commerce web application within a service-oriented / microservices architecture. I was tasked with building out a clean and scalable back-end that could handle high production-level web traffic.

The Ratings and Reviews client rendering my back end

reviews-FE

Objectives for this initiative

Scaling the Database

  • I ultimately chose PostgresQL because of my preference towards object-relational SQL databases and because it is open source.

  • I wrote three data generation scripts in order to generate over a total of 17 million records spread between the three tables I have in my schema.

It took me only 209 seconds to generate the 10M records for my primary table!

data-gen-shot

It took 124.39 seconds to seed my database

seed-shot

DBMS Benchmarking

  • My goal was to optimize the back end in order to verify that the queries used by my API ran under 50ms.

I got them running in under 7ms

query-duration

Measured Performance

Monitored response time / latency, throughput, and error rate using New Relic

new-relic-shot

new-relic-shot1

Stress tested my service

  • Stress tested my service in development using the simulated data I created and realistic requests to the API by scaling the number of request per second (RPS): 1, 10, 100, 1K via Artiller.io

  • Blew passed my goal of reaching 1k RPS with low latency times (2016.52 RPS)

rps-shot

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

NodeJS and Xcode

First, navigate to the preferred local directory.

Next, fork the repo to your Github.

Next, access the demo site by cloning the Github repository:

$ git clone https://github.com/Back-end-to-the-Future/ratings-and-reviews-module.git

Installing

Navigate inside the directory './ratings_and_reviews_module' and run the following commands:

$ npm i

After all dependencies are installed, run the following commands in two seperate terminal windows to start the server and the react development enviornment:

$ npm run start
$ npm run react-dev

In your browser, open up a window or tab to http://localhost:3000/

Technologies Used

Monitored and Stress Tested with

Deployed with

Author

Related Projects

Reviews API

List Reviews

Returns a list of reviews for a particular product. This list does not include any reported reviews. GET /reviews/:product_id/list

Parameters

Parameter Type Description
product_id integer Specifies the product for which to retrieve reviews.
page integer Selects the page of results to return. Default 1.
count integer Specifies how many results per page to return. Default 5.
sort text Changes the sort order of reviews to be based on "newest", "helpful", or "relevant"

Response

Status: 200 OK

{
  "product": "2",
  "page": 0,
  "count": 5,
  "results": [
    {
      "review_id": 5,
      "rating": 3,
      "summary": "I'm enjoying wearing these shades",
      "recommend": 0,
      "response": "",
      "body": "Comfortable and practical.",
      "date": "2019-04-14T00:00:00.000Z",
      "reviewer_name": "shortandsweeet",
      "helpfulness": 5,
      "photos": [{
          "id": 1,
          "url": "urlplaceholder/review_5_photo_number_1.jpg"
        },
        {
          "id": 2,
          "url": "urlplaceholder/review_5_photo_number_2.jpg"
        },
        // ...
      ]
    },
    {
      "review_id": 3,
      "rating": 4,
      "summary": "I am liking these glasses",
      "recommend": 0,
      "response": "Glad you're enjoying the product!",
      "body": "They are very dark. But that's good because I'm in very sunny spots",
      "date": "2019-06-23T00:00:00.000Z",
      "reviewer_name": "bigbrotherbenjamin",
      "helpfulness": 5,
      "photos": [],
    },
    // ...
  ]
}

Get Review Metadata

Returns review metadata for a given product.

GET /reviews/:product_id/meta

Parameters

Parameter Type Description
product_id integer Required ID of the product for which data should be returned

Response

Status: 200 OK

{
  "product_id": "2",
  "ratings": {
    2: 1,
    3: 1,
    4: 2,
    // ...
  },
  "recommended": {
    0: 5
    // ...
  },
  "characteristics": {
    "Size": {
      "id": 14,
      "value": "4.0000"
    },
    "Width": {
      "id": 15,
      "value": "3.5000"
    },
    "Comfort": {
      "id": 16,
      "value": "4.0000"
    },
    // ...
}

Mark Review as Helpful

Updates a review to show it was found helpful.

PUT /reviews/helpful/:review_id

Parameters

Parameter Type Description
reveiw_id integer Required ID of the review to update

Response

Status: 204 NO CONTENT