This project contains an example of building an AWS native, event driven, customer review analysis application. It uses serverless components and native AWS service integrations. The application is deployed using the AWS CDK, written in C#.
The intention of this application is to show the art of the possible, that does not necessarily mean this would be replicated directly into a production system. AWS Lambda still has a place in the serverless world, these Step Functions show the possibilities.
The application consists of 6 services:
A storage first API that receives requests from a front-end, stores them durably and publishes an event to notify other services that a new review has been received.
This storage first API utilises the native service integrations between Amazon API Gateway and Step Functions to pass the HTTP request directly to a step functions execution. The workkflow stores the request to DynamoDB and then publishes an event to notify other services that an API request has been received.
Service to translate the review to English if not currently in English, analyze the review content and detect the sentiment.
This service demonstrates the true power of Amazon Step Functions. There are native service integrations with Amazon Comprehend and Translate. The workflow is also invoked directly from an Amazon Event Bridge rule.
Sends email notifications back to the reviewer.
Negative reviews are followed up by a customer service representative. This service manages that customer service flow.
An audit service, to store all events to a DynamoDB table.
Before you deploy the application you will first need to add the email address to be used for customer service notifications. Email sending uses SES, so ensure that the AWS account you deploy the stack to has permissions to send email to the email address used. You can find details on verifying an email identity in the AWS documentation..
If you want to disable the email notifications, you can comment on lines 21-24 in the customer service workflow file..
// negativeReviewNotification.AddSubscription(new EmailSubscription("[email protected]", new EmailSubscriptionProps()
// {
// }));
If you do wish to enable emails enter the email identity you have verified in the customer contact service workflow:
- Open src/EventDrivenCdk/CustomerContactService/WorkflowStep.cs
- Add your email address to the AddSubscription line
negativeReviewNotification.AddSubscription(new EmailSubscription("", new EmailSubscriptionProps()
The entire application can be deployed by running the below command from the root directory.
cdk bootstrap
cdk deploy
Post deployment the CDK stack will output two parameters, one for the FrontEndApiEndpoint and the other for the AuditApiEndpoint.
The repository includes a simple Blazor Server application that you can use to test the application:
- Navigate to the EventDriven.Front folder
- Open the appsettings file and populate the FrontEndApiEndpoint and AuditApiEndpoint properties using the output values from the 'cdk deploy' command
- Run the front end application on local host using the 'dotnet run' command
- Note, the front-end application interacts directly with the StepFunction and SQS API's. When running the application locally ensure you have configured your default AWS credentials locally
- Naviate go http://localhost:5225/
Below are sample API request bodies you can use to test positive and negative workflows.
Tests can be executed using the API testing tool of your choice. On deployment the CDK project will output the FrontEndApiEndpoint to use. Make a POST request to the root path using the schema below.
{
"reviewIdentifier": "test",
"emailAddress": "",
"reviewContents": "This is a great demo of CDK native integrations."
}
{
"reviewIdentifier": "test",
"emailAddress": "[email protected]",
"reviewContents": "Esta no es una muy buena demostración, viva Lambda"
}