shmuelko / chargeF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chargeflow Assignment

We would like you to design a classic e-commerce store using micro-services and a event-driven approach (ideally using AWS’ primitives) that meets the requirements below.

  • The customer makes a request with the contents of a shopping cart (We would like to see a full REST design including request, response, endpoint etc.)
  • The backend calculates the total amount that needs to be charged
  • The backend issues an invoice
  • The backend bills the customer using pre-approved 3rd party billing partner (e.g. stripe / PayPal / etc.)
  • The backend ships the goods to the customer using a shipment service that provides a tracking number (e.g. FedEx/DHL)
  • The backend sends email updates to the customer for each stage of the order
  • Consider error flows and non-functional requirements as you see fit

Deliverables:

  • Please draw the system diagram using an online tool like eraser.io / draw.io / excalidraw.com followed by a few paragraphs / recorded video going over the design.
  • A REST design for the new endpoint(s)
  • Please write the main handler for the order creation flow in node.js. While we don’t expect the code to “work”, it should look like “runnable” code and demonstrate a best practice as you see fit.

Diagram View:

system diagram

Install and run

REST API:

paths:
  /api/v0/orders:
    get:
      summary: Returns all Orders.
      parameters:
        - in: path
          name: id
          required: true
          type: string
          minimum: 1
          description: The ID of the order to return.
      responses:
        200:
          description: A list of Orders object.
          schema:
            type: list[Orders]
        default:
          description: Unexpected error
    patch:
      summary: Returns all Orders.
      parameters:
        - in: path
          name: id
          required: true
          type: string
          minimum: 1
          description: The ID of the order to return.
        - in: body
          type: object
          description: Create new Order.
      responses:
        200:
          description: The updated object.
          schema:
            type: Order
        default:
          description: Unexpected error
    put:
      summary: Create new Order.
      parameters:
        - in: body
          type: object
          description: Create new Order.
      responses:
        200:
          description: The new Order object.
          schema:
            type: object
            properties:
              userId:
                type: Number
                example: 4
              items:
                type: [Object]
        default:
          description: Unexpected error

  /api/v0/orders/{id}:
    get:
      summary: Returns a order by ID.
      parameters:
        - in: path
          name: id
          required: true
          type: integer
          minimum: 1
          description: The ID of the order to return.
      responses:
        200:
          description: A Order object.
          schema:
            type: object
            properties:
              userId:
                type: Number
                example: 65a3beb7736d8d52d86cb351
              items:
                type: string
                example: [{ productId: Number, quantity: Number, price: Number, subtotal: Number }]    
            status:
              type: string
              example: 'pending'
        400:
          description: The specified user ID is invalid (e.g. not a number).
        404:
          description: A user with the specified ID was not found.
        default:
          description: Unexpected error
  delete:
    summary: Delete this order.
    parameters:
      - in: path
        name: id
        required: true
        type: integer
        minimum: 1
        description: The ID of the order to remove.
    responses:
      200:
        description: Confirmation that the Order was removed.
        schema:
          type: string
      404:
        description: A user with the specified ID was not found.
      default:
        description: Unexpected error

About


Languages

Language:JavaScript 100.0%