/products-and-orders-serverless

AWS Serverless Application for a Products and Orders management system

Primary LanguageTypeScript

Serverless Backend for Products and Orders

This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders.

  • getOrder, getOrders, getProduct, getProducts, createOrder, createProduct, deleteOrder, deleteProduct, editOrder, edit Product - Code for the application's Lambda function written in TypeScript.
  • layers - Code for common utility functions share between all lambda functions
  • events - Invocation events that you can use to invoke the function. (currently empty)
  • template.yaml - A template that defines the application's AWS resources.
  • MakeFile - Contains commands to build and deploy changes to the applications

The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the template.yaml file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code.


Deploy the application

To deploy any changes to the application, run the following commands

make build
make deploy

Run the application locally

The SAM CLI can also emulate your application's API. Use the sam local start-api to run the API locally on port 3000.

sam local start-api

Functionality

  • Endpoints created:
  1. GET /products Gets a list of all existing products
  2. GET /product/{id} Get a specific product given its ID
  3. POST /product Creates a new product
  4. PATCH /product/{id} Update a specific product given its ID
  5. Delete /product/{id} Delete a specific product given its ID
  6. GET /orders Gets a list of all existing orders
  7. GET /order/{id} Get a specific order given its ID
  8. POST /order Creates a new order
  9. PATCH /order/{id} Update a specific order given its ID
  • Assumptions:
  1. Product model consists of product name, quantity in stock, and unit price
  2. Order model consists of a list of products, shipping address, order status and shipping details (tracking number and tracking company)
  3. All properties of a product can be updated
  4. only order status and shipping details can be updated for an order

Limitations

  • Application doesn't have any authentication or authorization layer. Same user can successfully invoke all api endpoints
  • Because the application has a small amount of data, we're getting all orders and all products on the home page.
  1. No funcationality has been introduced to search for a product by name, get products by a certain supplier, filter by price, etc
  2. As the applicatioin grows, the database needs to be indexed based on what queries are going to be required.
  • No caching is implemented at this stage