Skip to main content

Architecting seasonal offers using AWS serverless

Greetings!

When I started writing lambda and serverless, I wanted to design a real-world project. The example that was in mind was a geolocation extractor using an image upload that my friend did. I thought to tweak it to an Excel file upload with another example that is based on real-world e-commerce requirements.
What I want to focus on here is the architecture.

Seasonal offers

Offers are common in any business. Now the marketing team decides that having a separate section to indicate seasonal offers with additional descriptions would increase the orders. As they are experts in excel they say hey Devs, we don't want a UI for us. We will give you an excel to make your lives easier.

Requirement

Design a restful API to expose seasonal offers that are coming as an excel sheet.

Technical breakdown

We can store the excel in our code and directly read it. But that is not an expandable solution. Hence we store the file in an S3 bucket and separate out the extraction logic.

Architecture

The main focus for me is the architecture in this article. I can combine my previous articles and design a complete architecture.



As I do not have time for coding, I will explain and add the necessary details. If I get time one day, I will add the code.

Excel data extractor

Our first component is the excel extractor. You can use xlsx JavaScript library for this. We extract the Excel into JSON and upload it to another S3 bucket. This helps us isolate logic. Each lambda has a separate responsibility.

JSON reader

The Excel is read and uploaded into another bucket. Use another lambda to listen to that event. As Nodejs is very easy to use with JSON, we can directly save these data in a DynamoDB table.

Rest API

Expose seasonal offers through a rest API that we define using an API gateway. A lambda is defined to read the data from the database.

Adding more features

We can introduce another lambda to mark a seasonal offer as expired. We can use event bridge as the scheduled executor.

Conclusion

Any big project is a collection of smaller elements. We have connected things we learned so far to achieve a somewhat bigger goal.

Keep learning. Learning is fun.

Comments