Overview:
Kmart Australia has introduced digital ‘smart’ receipts for in-store and Online purchases where customers get a digital copy of the transaction receipt on their mobile through SMS or through the OnePass Digital Wallet application. By switching to digital smart receipts, we can give our customers a more seamless shopping experience, by taking away the stress of needing to keep hold of a physical printed receipt, which is important to us as we continue to work through ways, we can reduce our environmental impact. By introducing digital smart receipts, we aim to deliver a more enjoyable and convenient shopping experience to those customers who prefer to use technology to manage their receipts, however a paper receipt will continue to remain available for those customers who instead prefer a printed copy.
Benefits of introducing Digital Receipt
In this blog, we cover high-level technical architecture and how architecture evolved.
The Problem:
To implement these smart digital receipts for Kmart and provide our customers with seamless shopping experience we had to implement a real-time data integration solution between Kmart and OnePass, and between Kmart and Slyp (Banking system to send digital receipt SMS to Customers). Also, no data program is complete without data analytics. So, we had to ensure that the data is also available at our cloud data warehouse where the data analyst can crunch numbers and provide meaningful insights related to the program.
Solution:
Just like any data integration project the initial requirement was simple - send the transaction data from one system to another by making use of synchronous communication (yes APIs) – and so, start with the Monolith. To put it simply, this is how it was supposed to look.
Sounds simple right? Well turns out, it wasn’t that simple.
Each source system, store or online generates data fields which are very specific to the channel. So, we had to transform this data in flight and convert the payload into a canonical model set up by OnePass and Slyp. Yes, there are 2 consumers. Perhaps you guessed it, wait for it 😉 (not mimicking Barney).
Also, a lot of descriptive information about the products being sold is not available in the source systems. This means in the transformation in flight we also had to enrich the payload.
So, it would turn out we need a box in between to perform the tasks above. To put it in a diagram, this is how it would look -
Seems Sorted!!! Wait a minute...
Hmm... Let’s revise this.
We now introduce our data warehouse which gets reference data feed continuously from other systems and needs to be available in flight to enrich the payload. At the same time, each transaction needs to be recorded at the data warehouse for analytics. So, this is both a producer and consumer.
Ok. Let’s count the producers and consumers now.
3 Producers:
3 Consumers:
Wonder what could help here! Yes, you guessed it correctly earlier in this blog (if you read it!). Introducing Confluent Kafka. Confluent Kafka allows us to do all the above by using several components of Kafka stack.
In our solution, we used Confluent Kafka as it is a managed service. We didn’t have to worry about cluster maintenance and uptime. We could focus more on creating solutions than maintaining the infrastructure.
Coming back to the solution, we had to
To achieve all of these we used Kafka Streams application.
Cool, seems sorted. Well, not yet! There are few things we still need to handle -
Let’s tackle each of these one at a time!
How would Store and Website send data to Kafka in a secure manner using APIs?
Here we used 2 components:
Kafka Rest Proxy
Kafka rest proxy allows us to use RESTful interface to publish messages to Kafka cluster.
Instead of writing custom producer applications, a rest proxy allows seamless connectivity from clients to Kafka cluster to publish or even consume messages.
This Kafka rest proxy is from Apache and is hosted through a docker container on AWS EKS
However, the Rest proxy does not offer advanced security posture and so we make use of API gateway to manage our APIs in a secure manner.
AWS API Gateway
A diagram of this step -
How to send and receive data from snowflake?
To handle data exchange to and from snowflake we make use of the following components.
Send data to Snowflake -
Receive data from Snowflake -
This is handled by the enriching microservice Kafka stream application which queries a Snowflake view to enrich data of the payload and write it back to a Kafka topic.
Time to tackle the 3rd question
How will data be sent to External systems with fault tolerance?
So far, we were playing in our own ground and now was the time to send the prepared payload out of the perimeter.
It makes sense and seems good. But few pertinent questions -
Our feed is real time, what if the external service goes down (for whatever reasons)? What happens to our feed? Should we stall the process or keep sending the messages?
Here is what we did...
We introduced a circuit breaker pattern.
Putting all of it together -
Some Stats:
This is how we achieved real-time secure data integration for generating smart digital receipts for our customers. It wasn’t easy to develop such complicated architecture and have it running in production. Kudos to the Anko team who worked on it day and night to achieve such a masterpiece. This is what we call Legend (Wait for it) Archy – LegendArchy 😎
Authors:
Vivek Sinha - Manager Data Engineering, Enterprise Technology
jimmy lamba - Manager Data Engineering, Enterprise Technology