Giter Site home page Giter Site logo

retail-q-a's Introduction

Retail Q&A | Back-end services for e-commerce site

I worked with another software engineer to rebuild back-end API service from a monolithic to service-oriented microservices to support our existing e-commerce application in this project. The service I built was scaled to meet the demands of production traffic which is 1000rps with < 1s response time with 0% error rate.

Technologies used

Backend Development: Node.js, Express, Postgres, NGINX
Deployment: Docker, AWS EC2
Testing: Jest, SuperTest, K6, Loader.io, New Relic


Table of Contents


System Design

Database Design

overview_schema_design

Architecture

Architecture

Stress Test Results via Loader.io

load tests 1

load tests 2

load tests 3


Usage

List questions

Retrieves a list of questions for a particular product. This list does not include any reported questions

GET /qa/questions

Query Parameters

Parameter Type Description
product_id integer Required ID of the question for which data should be returned
page integer Selects the page of results to return. Default 1.
count integer Specifies how many results per page to return. Default 5

Response: Status: 200 OK

GET /qa/questions

Answers List

Returns answers for a given question. This list does not include any reported answers

GET /qa/questions/:question_id/answers

Query Parameters

Parameter Type Description
question_id integer Required ID of the question for which answers are needed

Response: Status: 200 OK

GET /qa/questions/:question_id/answers

Add a Question

Adds a question for the given product

POST /qa/questions

Query Parameters

Parameter Type Description
body text Text of question being asked
name text Username for question asker
email text Email address for question asker
product_id integer Required ID of the Product for which the question is posted

Response: Status: 201 Created

Mark Question as Helpful

Updates a question to show it was found helpful

PUT /qa/questions/:question_id/helpful

Query Parameters

Parameter Type Description
question_id integer Required ID of the question to update

Response: Status: 204 NO CONTENT

Report Question

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

PUT /qa/questions/:question_id/report

Query Parameters

Parameter Type Description
question_id integer Required ID of the question to update

Response: Status: 204 NO CONTENT

Mark Answer as Helpful

Updates an answer to show it was found helpful

PUT /qa/answers/:answer_id/helpful

Query Parameters

Parameter Type Description
answer_id integer Required ID of the answer to update

Response: Status: 204 NO CONTENT

Report Answer

Updates an answer to show it has been reported. Note, this action does not delete the answer, but the answer will not be returned in the above GET request

PUT /qa/answers/:answer_id/helpful

Query Parameters

Parameter Type Description
answer_id integer Required ID of the answer to update

Response: Status: 204 NO CONTENT


DB Initialization and ETL Quaries in Postgres

  1. Run schema.sql
  2. Run copyData.sql (if deployed to cloud, run copyData-AWS-EC2.sql instead)
  3. Run setPrimarykeySequence.sql
  4. Run createIndex.sql
  5. After load testing APIs using K6, run deleteK6TestData.sql to delete load test data.

Installation

  1. In the terminal inside, run npm run start to start server
  2. Test by typing http://localhost:3000/qa/questions in the Postman to see the response.

Other Services

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

retail-q-a's People

Contributors

sunheal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.