This project implements the infrastructure and code needed to create a middleware hosted on AWS that can process orders on a massive scale. It takes inspiration from Taco Bell's 'This is my architecture' video: https://www.youtube.com/watch?v=sezX7CSbXTg
As a store or restaurant, having a reliable mechanism to receive orders from your customers and manage them according to your capacity is essential. Initially, this might involve simply accepting or rejecting orders based on what you can handle. However, as your establishment gains global popularity and the volume of incoming orders surges to thousands per minute, you need a robust system that can efficiently manage this high order volume without the hassle of constantly scaling the underlying infrastructure.
Moreover, as your business continues to expand, it becomes necessary to integrate your order management process with third-party order aggregators to streamline operations further. To address these challenges, this project introduces a middleware solution designed to receive and process customer orders seamlessly. The system captures new order requests, stores them in a database, and updates the order status—either accepting or rejecting the orders—based on your business logic. Additionally, it ensures that customers are promptly informed of their order status via email, enhancing their overall experience.
In order to deploy the CDK, a few actions need to be performed.
git clone <git url>
The aws-cli must be installed -and- configured with an AWS account on the deployment machine (see https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html for instructions on how to do this on your preferred development platform). This project requires Node.js. To make sure you have it available on your machine, try running the following command.
node -v
Make sure you have the AWS CDK installed. For best experience, install the CDK globally: npm install -g aws-cdk
In the cdk.json, modify the emailAddress
field. This will be the email address that will receive updates about the order. Once the CDK is deployed, you'll receive an email on this email address prompting you to confirm your subscription to receive order updates via email.
AWS infrastructure needs to be deployed and configured for the experience to function. The required code has been written using CDK and included in the repository. To deploy, perform the following steps:
- Perform the required steps dictated in the Prerequisites
- Configure your AWS credentials
aws configure
- CD into the order-middleware directory
- Install the required dependencies
npm install
- CDK bootstrap
cdk bootstrap aws://ACCOUNT-NUMBER/REGION
- Deploy the application
cdk deploy
Deployment can take approximately 10 minutes. Once complete, you will need to note down the output of the CDK deployment. The output will look like this:
CdkStack.HttpApiUrl = https://<API>.<region>.amazonaws.com/
- Navigate to the Cloud Formation console.
- Get the URL for the API from the Output tab of your stack deployment.
Open your API testing platform like Postman. The interaction with this project will be through API calls. Remember to pass two important parameters in the body of your requests.
- `orderid` The unique identifier of your order. Two orders cannot have the same orderid
- `status` false = order is not accepted, true = order is accepted
You need to make a POST call to the following URL:
https://<API>.<region>.amazonaws.com/create
Request parameters:
- Required:`orderid` The unique identifier of your order. Two orders cannot have the same orderid
- Required:`status` false = order is not accepted, true = order is accepted
In the body of your request, send the following payload:
"{
"operation": "create",
"payload": {
"orderid": "1",
"status": false
}
}"
You need to make a GET call to the following URL:
https://<API>.<region>.amazonaws.com/get
Request parameters:
- Required:`orderid` The unique identifier of your order. Two orders cannot have the same orderid
In the body of your request, send the following payload:
"{
"orderid": "1"
}"
You need to make a POST call to the following URL:
https://<API>.<region>.amazonaws.com/update
Request parameters:
- Required:`orderid` The unique identifier of your order. Two orders cannot have the same orderid
- Required:`status` false = order is not accepted, true = order is accepted
In the body of your request, send the following payload:
"{
"operation": "update",
"payload": {
"orderid": "1",
"status": true
}
}"