Skip to content

huantran123/Atelier-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Atelier Ratings & Reviews | Back-end services for Atelier E-commerce app

Our 3 software engineers rebuilt back-end API service for a monolithic to service-oriented micorservices to support our existing e-commerce site in this project. The service I built was scaled to meet the demands of production traffic with 6000RPS with < 40ms response time with 0% error rate.

Techonologies Used

Backend Development: Node.js | Express | Postgres | NGINX
Deployement: Docker | AWS EC2
Testing: Jest | SuperTest | K6 | Loader.io


Table of Contents


System Design

Database Design

reviews_schema_design

Architecture

Architecture

Stress Test Results via Loader.io

1000 RPS 3000 RPS 6000 RPS


Usage

Review List

Returns a list of reviews for a particular product. This list does not include any reported reviews.

GET /reviews/

Query 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

Review list query

Review Metadata

Returns review metadata for a given product.

GET /reviews/meta

Query Parameters

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

Response: Status: 200 OK

image

Add a Review

Adds a review for the given product.

POST /reviews

Query Parameters

Parameter Type Description
product_id integer Required ID of the product to post the review for
rating int Integer (1-5) indicating the review rating
summary text Summary text of the review
body text Continued or full text of the review
recommend bool Value indicating if the reviewer recommends the product
name text Username of reviewer
email text Email address of reviewer
photos [text] Array of text urls that link to images to be shown
characteristics object Object of keys representing characteristic_id and values representing the review value for that characteristic. { "14": 5, "15": 5 //...}

Response: Status: 201 Created

Mark Review as Helpful

Updates a review to show it was found helpful.

PUT /reviews/:review_id/helpful

Query Parameters

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

Response: Status: 204 NO CONTENT

Report Review

Updates a review to show it was reported. Note, this action does not delete the review, but the review will not be returned in the above GET request.

PUT /reviews/:review_id/report

Query Parameters

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

Response: Status: 204 NO CONTENT


DB Initialization and ETL Quaries in Postgres

Local

  1. Run node db/schema.js to create tables
  2. Run node db/loadingData.js to import data from csv files (if deployed to cloud, run copyData-AWS-EC2.sql instead). Make sure to replace the file paths with your paths

Deploy to cloud

  1. Create database
  2. Create file named schema.sql and copy commands from db/schema.sql
  3. Create file name loadingData.sql and copy commands from db/loadingData.sql
  4. Run psql -h localhost -U your-user-name -d your-cloud-database-name -f \schema.sql
  5. Transfer the CSV files from local to cloud server
  6. Run psql -h localhost -U your-user-name -d your-cloud-database-name -f \importData.sql`

Installation

  1. In the terminal inside, run npm run server/index.js to start server
  2. Test by typing http://localhost:8000/reviews?product_id=1 in the Postman to see the response.

Other Services

Please reference other API Services that make up the other part of the e-commerce app API:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors