A peek into multifaceted Promotions platform

Puneeth Prakash Kadamba
redbus India Blog
Published in
6 min readFeb 25, 2022

Acquiring & retaining customers is an eternal process for any organization.

How we adapt and experiment to meet the current trends, adds great value to the business.

At redBus, we have broadly classified promotional programs into 2 categories.

1.Operator offer system is explained in The redDeal story.

2. Focusing on offers powered by redBus, the initial version is detailed out here.

Within the last few years, varieties of promotional strategies are introduced.

  • Percentage/Flat Discounts
  • Cashbacks for transactions[Percentage/Flat]
  • Referral Rewards
  • Promotional credits through campaign programs
  • Rewards for Reviews on Journey/Safety Index of the Bus
  • Scratch Card Gamification[Cashbacks and Amazon Vouchers]
  • Prize Draw[ 1 gm Gold, TVs and other prizes]
  • 1 SOL, 1 RM Flash Sales for first N customers.

The complexity multiplexes when you dive deep into each of the above strategies.

Building an ecosystem to dynamically handle such use cases and scale for technical challenges is ever-evolving. Broadly the ecosystem can be represented as below.

Promotions Ecosystem
Promotions Ecosystem

Microservices design patterns play an important role in this ecosystem. We have implemented Decomposition, Integration, Database and Observability patterns.

Each of these sub components requires a great deal of deep understanding, however, I will try to highlight the responsibilities on a high level.

  • Offer discovery: systems that provide the necessary interactions with the users to push the benefits and drive the adoption of promotion strategies.
    - Offer Tiles, Personalized Offers & Promotional notifications.
    are some of the examples. They generate a great deal of traffic on Promotions service. Static and dynamically processed data points are served within 10ms average. This also includes real time evaluation of multiple promotions applicable for the customer at various touchpoints in the funnel.
  • Transactions & Rewards: These are interfaces through which customer becomes eligible for promotional benefits.
    - Bookings, User Reviews, Referrals and Milestones.
    These are transactional in nature and it is managed by a set of services through the funnel. Multiple data layers based on MySQL & services based on Go and Erlang serve the technical capabilities.
  • Promotion Configuration Tool: A web interface for product ops to configure and update promotion rules. This also helps maintain the sanity in auditing process adherence, compliance related to promotion configuration and accesses. Realtime monitoring and alerts on updates/expiry & extension details. Built on Angular, c# .Net, MySQL, ArangoDB & MongoDB.

Discount Engine:

As discussed earlier, the initial version had few limitations

  • Lookups: we were supposed to set the lookups as variables in the custom rule engine, which had a scalability issue.
  • Bulky libraries & metadata: Loading all the rules into memory and going through the parser, AST walker and c# compiler required optimization for frequent changes and updates
  • Differential discount support: Earlier the discount percentage/value was more or less fixed. With the introduction of personalized offers and spend optimization, supporting differential values based on multiple user variables and business variables became an important requirement. Achieving these on the Legacy system was becoming cumbersome.
  • Learning curve: Understanding the rule within DSL and trying to troubleshoot, extend the rules required an extended learning curve.

Introducing JSON-based rules and JS-based evaluation.

ArangoDB has been our go-to multi-mode NoSQL service for Systems like UGC & Notifications. We started off with a POC for offer evaluation using the documents which are represented as JSON and their Foxx services.

  • Look ups are easy & extensive as we have collections of data and rules are evaluated close to the data layer, rather than the application layer. This includes both rule lookups and eligibility lookups in transactions and promotion usage from the same data layer.
  • Rules and JSON are available as a service on top of the data layer. Updates and extensions are instant without any dependency on the application layer. On the other side, it is disconnected from the data storage unlike the stored procedure and can be scaled individually.
  • Using the extensibility of JSON structure with multiple maps and objects, differential discounting rules can be easily configured. User Variables/Business variables & transaction variables form different groups. group-wise rules and promotion percentage can be configured dynamically.
  • Basic JSON and JS knowledge are enough to troubleshoot and extend the functionalities.
    This is how a sample rule looks like
    {
    “BU”: 1,
    “Country”: “1”,
    “EndUTC”: 1562265000000,
    “SRC_DST_QUADRANT”: {},
    “AGE_RULE”: [
    {
    “condition”: “arg1==20”,
    “discount”: 100
    }
    ],
    “CHANNEL_RULE”: [],
    “DEVICE_RULE”: [],
    “TRAFFIC_SOURCE”: []
    },
    “StartUTC”: 1561660200000,
    “Status”: 1,
    “TimesUsed”: “1”,
    “TimesValid”: “-1”,
    “WHAT_BUYING”: {
    },
    “WHEN_BUYING”: {
    },
    “metaData”: [
    {},
    {
    “ChannelsEnabled”: [
    “WEB_DIRECT”
    ],
    “Message”: “Offer not applicable on this channel”,
    “name”: “IsChannelsEnabled”
    }
    ],
    “ruleKey”: “26730660”,
    “maxDiscountValue”: 100,
    “maxCashbackValue”: 0,
    “maxDiscountPercent”: 10,
    “maxCashbackPercent”: 0,
    “successMessage”: “Success”,
    “minTranscationMessage”: “Sorry! Offer valid for a minimum ticket price of Rs.1”,
    }

We still use the DSL engine for specific use cases. The advantage of having micro services pattern helps us switch between engines based on Geo and verticals

Other components of the ecosystem:

We have built a few other services handling specific responsibilities with relevant tech solutions.

  • Wallet Engine: The discount engine is used to apply promotional rules and wallet cashback usage by handling wallet functionality as a specific offer on the JSON & JS-based service.
    This also includes uploading millions of wallet top-ups for promotional offers. Go routines help in achieving the same with a minimal TAT.
    Wallet System also manages variable cashback credits based on multiple rules.
  • Gamification Engine: Gamification strategy servers retention as well as engagement capabilities. Scratch card programs, milestone programs, prize draws, Flash Sales are powered with this engine.
    Event streams, Randomness Engine, static rules and forecast data
    are some of the building blocks.
    KAFKA streams and rabbitMQ topics are used to handle different kinds of feeds for data needs.
    Redis-based Transactions form a greater part of our fulfillment flows.
    Randomness is built across sequential and concurrent data streams.
    The engine covers a wide range of functionalities from a basic flow with picking random events based on time and transaction attributes to
    Complex forecast-based spend optimization with distribution across various value bands.
    Configuration support for switching value bands/distributions and
    Circuit breakers for curtailing business loss in case of out of bound spends are other major offerings. More on this in the subsequent blog posts.
  • Downstream systems: The data from all of these engines are available in a distributed manner across multiple data layers. Streams are set up to make this available in a meaningful aggregated manner to the stakeholders.
    Data Engineering & Data Science: process this data and share the same with data science. A lot of statistical analysis and processes are applied to this data and shared with the Finance team. The finance team is now able to make a lot more informed decisions on the promotional strategy and maintain the promotions through the promotion configuration tool.
  • Analytics: Data from the data lake is processed and used to power multiple BI tools from which the stakeholder can make sense of the current promotion strategy. Region-based and user-based performances are some examples.

As mentioned in the title, this is just a peek into the promotion ecosystem, I would need lot more blog posts to get deep into the technical challenges and solutions which helped us drive the ever-changing promotion strategy of the business.

The key takeaway in building this ecosystem over the years is that your technical system should be ready to adapt to the business goal and build scalable solutions. These systems might not be used on a daily basis, however, when the season arrives, a sample part of the system drives a great deal of the business metrics.

I would like to thank all the team members who have worked on this ecosystem over the years. The current team is set to take this up to the next level. Airdrops and NFTs to customers in the future, maybe…

--

--