Building Loyalty Program in AWS with Lambda, DynamoDB and serverless framework

Slava Guzenko
2 min readFeb 22, 2018

--

According to Dr. Deming, profit from the sale to a loyal customer is 6 to 8 times the profit from other customers. Loyal customers generate income, refer other clients, and help businesses thrive.

There are multiple ways to reward loyal customers but the first problem is to recognize all their activities and assign them a particular status or tier. For example, when a customer refers another customer, 1 point is added to their account. When 10 points are scored, they move to another tier that entitles them to purchase products with 10% discount and so on. What does it take to build a loyalty program?

First of all we need to define all activities that score points. In addition to a referral, we can reward customers for certifications, active participation in community forums, etc. How many points should be awarded for each activity depends on business requirements and can change over time. Therefore we need a Loyalty Engine that would let us easily manage rules for points, tiers, activities, and promotions.

Another important component is an aggregation service that would keep all activities, points, and tiers in a single place for consumption by other systems. This is a Loyalty Service.

Customers should obviously have access to their activity statements and see their points balance, current tier, and how many points are needed to go to the next level. This becomes Customer UI.

Dealing with lots of data is challenging so we need a robust way of importing daily customer activities into Loyalty Service. We can use AWS S3 as a storage for data uploaded from various business systems. Loyalty programs do not require real-time processing so we can organise background ingesting jobs that run nightly. To simplify maintenance and hosting costs we can use AWS Lambda to process the data and DynamoDB to store it. Deployment of the system is orchestrated by serverless.com framework.

Here is the high-level architecture of our loyalty program.

As a result we get a highly scalable system that is capable of processing hundreds of thousands of transactions daily with operational costs below $500 a month. A loyalty program is a perfect example of the Serverless formula in action that allows us to achieve business goals more effectively.

--

--