Skip to content

pyc0422/Atelier-backend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retail Q&A | Back-end services for e-commerce web 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 8000RPS 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

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

Local

  1. Run node db/schema.js to create tables
  2. Run node db/importData.js to import data from csv files (if deployed to cloud, run copyData-AWS-EC2.sql instead)
  3. Run node db/addIndex.js to create indexes
  4. After load testing APIs using K6, run node db/deleteTestData.js to delete load test data.

Deploy to cloud

  1. Create database
  2. Create file named schema.sql copy codes from db/awsSchema.sql
  3. Create file name importData.sql copy codes from db/awsImportData.sql
  4. Run psql -h localhost -U your-user-name -d your-cloud-database-name -f \schema.sql
  5. Transfer the CSV files from loacal 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 to start server
  2. Test by typing http://localhost:8000/qa/questions?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

Languages

  • JavaScript 99.4%
  • Other 0.6%