Skip to content

Rebuilt back-end API service from a monolithic to service-oriented microservices scaled to handle heavy loads

Notifications You must be signed in to change notification settings

xinxin510/product-api-microservice

 
 

Repository files navigation

Products API services

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 2000rps 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 tests1

load 3

loader 2

Usage

List all products

Returns a list of all products of the retail website.

GET /products/

Response: Status: 200 OK

[
{
      "id": 1,
      "name": "Camo Onesie",
      "slogan": "Blend in to your crowd",
      "description": "The So Fatigues will wake you up and fit you in. This high energy camo will have you blending in to even the wildest surroundings.",
      "category": "Jackets",
      "default_price": "140"
  },
{
      "id": 2,
      "name": "Bright Future Sunglasses",
      "slogan": "You've got to wear shades",
      "description": "Where you're going you might not need roads, but you definitely need some shades. Give those baby blues a rest and let the future shine bright on these timeless lenses.",
      "category": "Accessories",
      "default_price": "69"
  },
  ...
]

Get a product's details

Return details of a single product

GET /products/:product_id

Query Parameters

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

Response: Status: 200 OK

{
  "id": 11,
  "name": "Air Minis 250",
  "slogan": "Full court support",
  "description": "This optimized air cushion pocket reduces impact but keeps a perfect balance underfoot.",
  "category": "Basketball Shoes",
  "default_price": "0",
  "features": [
	{
          "feature": "Sole",
          "value": "Rubber"
      },
	{
          "feature": "Material",
          "value": "FullControlSkin"
      },
	// ...
  ],
}

Get a single product's styles

Return all styles of single product

GET /products/:product_id/styles

Query Parameters

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

Response: Status: 200 OK

{
  "product_id": "1",
  "results": [
	{
    "style_id": 1,
    "name": "Forest Green & Black",
    "original_price": "140",
    "sale_price": "0",
    "default?": true,
    "photos": [
          {
            "thumbnail_url": "urlplaceholder/style_1_photo_number_thumbnail.jpg",
            "url": "urlplaceholder/style_1_photo_number.jpg"
          },
          {
            "thumbnail_url": "urlplaceholder/style_1_photo_number_thumbnail.jpg",
            "url": "urlplaceholder/style_1_photo_number.jpg"
         }
			  // ...
      ],
    "skus": {
              "37": {
                    "quantity": 8,
                    "size": "XS"
              },
              "38": {
                    "quantity": 16,
                    "size": "S"
              },
              "39": {
                    "quantity": 17,
                    "size": "M"
              },
              //...
          }
     },
    // ...
}

Get related products of a single product

Return all related products' id of single product

GET /products/:product_id/related

Query Parameters

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

Response: Status: 200 OK

[2,3,5,6]

Installation

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

Other Services

Please reference Questions & Answers API Services that make up the Project Atelier API:

About

Rebuilt back-end API service from a monolithic to service-oriented microservices scaled to handle heavy loads

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.5%
  • Dockerfile 0.5%