Skip to content

gayatri-01/ScalableServicesAssignment_OrderService

Repository files navigation

OrderService

This microservice is built as part of Scalable-Services-Assignment. It is built using Java Spring Boot & MongoDB.

Steps to run locally

  • Download & Install Java by following steps here

  • Download & Install MongoDB by following steps here

  • Clone this project

  • Run .\gradlew build (only for 1st time)

  • Run .\gradlew bootRun to run the application

  • Application will now be running on http://localhost:8082

  • You can interact with the available endpoints either using Postman or by visiting Swagger - http://localhost:8082/swagger-ui/index.html

API Documentation

  • Get All Orders

    • URL: /orders
    • Method: GET
    • Description: Retrieve a list of all orders.
    • Responses:
      • 200 OK: Successfully retrieved list of orders.
      • 500 Internal Server Error: Error occurred while processing the request.
  • Place an Order

    • URL: /orders
    • Method: POST
    • Description: Place a new order.
    • Request Body:
      {
        "userId": "1",
        "price": 100,
        "orderItems": [
          {
            "orderItemId": 1,
            "quantity": 4,
            "price": 25
          }
        ],
        "paymentDetail": {
          "cardNumber": "123456789",
          "cardExpiry": "2024-10-12",
          "cvv": 123
        }
      }
      {
        "userId": "1",
        "price": 100,
        "orderItems": [
          {
            "orderItemId": 1,
            "quantity": 4,
            "price": 25
          }
        ],
        "paymentDetail": {
          "upiNumber": "123456789"
        }
      }
    • Responses:
      • 201 Created: Order successfully placed.
      • 500 Internal Server Error: Error occurred while processing the request.

Flow of the Service

  • Get All Orders

    • User requests to get all orders.
    • All orders are fetched from the database and returned to the user.
    • If there is any error, an error message is returned.
  • Place an Order

    • User places an order by providing the required details.
    • Order Id is Generated
    • Payment is processed by calling the PaymentService, which is another microservice.
    • If no exceptions, order status is updated to 'PLACED' and success message is returned.
    • if payment fails or there is any other failure, order status is updated to 'FAILED_TO_PROCESS' and failure message is returned.
    • Order is saved in - ( Database Orders / Collection order_details )
    • Inventory is updated by sending the order information onto InventoryService's Kafka Topic inventory-input-topic.
    • Notification about either Order Success or Order Failure is sent to user, by calling NotificationService, which is another microservice.

Success

API Request/Response

When Payment is successful using card:

  • img_7.png
  • img_3.png

When Payment is successful using UPI:

  • img_6.png
  • img_4.png

MongoCollection

  • img_5.png

Failure

API Request/Response

When Payment Service is down:

  • img_8.png
  • img.png

When Payment fails due to insufficient parameters:

  • img_9.png
  • img_1.png

MongoCollection

  • img_2.png

About

ScalableServicesAssignment_OrderService

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages