BLOGAtlas Vector Search voted most loved vector database in 2024 Retool State of AI report — Read more >>

Enabling real-time pricing with MongoDB and Databricks

Orchestrate real-time analytics with Atlas App Services and serverless functions to create dynamic pricing strategies on the fly.
Start Free
An image of general retail industries
Solution Overview

Deploying real-time analytics solutions with the right tech stack can transform a retail pricing strategy. Retailers want to grow their brand name and improve customer experience with value-based pricing while remaining competitive and cost effective.

With real-time pricing strategies, businesses can change product prices on the fly — both online and in-store through digital price tags — by leveraging data points across a wide variety of systems, such as inventory, marketing performance, and even regional and digital trends. Imagine dynamically lowering prices in response to excess inventory or new promotions, or increasing the price on something trending, without manual intervention.

Despite their ambition to become “data driven” operations, companies often fail in their endeavors because they struggle performing real-time analytics.

By the end of this demo you will get a detailed view of how to leverage MongoDB Atlas App Services in addition to Databricks model building and deployment capabilities to fuel data-driven strategies with real-time events data.

Other Applicable industries and use cases
  • Transport: Transportation companies, such as airlines, taxis, and ride-sharing services, can use real-time pricing to adjust fares based on factors like demand, supply, and external events. This enables them to optimize revenue and manage passenger demand during peak hours or special occasions.

  • Telecommunications: Telecom companies can use real-time pricing for data plans, international calling, and roaming charges. They can adjust prices based on network capacity and demand to manage traffic and ensure optimal service levels.

  • Insurance: Insurance companies can implement real-time pricing for usage-based insurance products, such as pay-as-you-drive or pay-as-you-live. Premiums can be adjusted based on actual customer behavior or risk factors.

Reference Architecture
The illustration depicts the Bob Ross Dynamic Pricing Reference Architecture
Data Model Approach

The event-driven architecture is very simple. It is made up of only four different events that a user can perform on the e-commerce site:

event_typedescription
“view” A customer views a product on the product detail page.
“cart” A customer adds a product to the cart.
“remove_from_cart” A customer removes a product from the cart.
“purchase” A customer completes a transaction of a specific product.

Event Schema
Purchase log
Building the Solution

Follow this step-by-step guide and learn how to orchestrate MongoDB Atlas through MongoDB App Services triggers and serverless functions in conjunction with Databricks to create a real-time analytics and pricing solution for the retail industry.

1. Data Ingestion

The GitHub repo contains the eventsGenerator directory, in which you will find a generator.py file. Edit the file with the connection string, database and collection parameters to mimic the purchase events happening on an ecommerce storefront in real time.

2. Data Transformations

In this GitHub directory you'll find instructions on how to use triggers and functions to:

  • Compute a historic purchase log per product in your collection
  • Send an HTTP POST request to a Databricks-deployed endpoint

3. ML/AI

In this GitHub folder you will find a test code to run on a Databricks notebook. The code computes a simple calculation of the price elasticity of demand per product, receiving as input the purchase log per product and giving as output the price elasticity.

Technologies and Products Used
MongoDB developer data platform:
Partner technologies:
  • Databricks
Key Considerations
  • Data transformation: Recognizing the importance of transforming raw data into a more usable format or structure. In this project, triggers and functions are used to compute a historic purchase log and send data to external systems like Databricks.

  • Serverless architecture: Gaining insights into the benefits and workings of serverless functions and triggers, which can automatically respond to changes in data and execute predefined actions without the need for a dedicated server.

  • Real-time data processing: Understanding the importance and mechanisms of processing data in real-time, especially in the context of the retail industry where timely insights can drive immediate actions, such as dynamic pricing.

Related Resources
general_content_tutorial

GitHub Repository: Dynamic Pricing

Create this solution yourself with the associated sample data, functions, and code.

general_content_play

Fueling real-time pricing strategies

See this solution in action to learn more about how MongoDB and Databricks partner to enable real-time dynamic pricing.

general_content_presentations

Strategies for Modern Retail Customer Experiences

Learn how retailers are escaping monolithic, siloed data structures along the modernization journey.

general_content_white_paper

What is MACH architecture?

The MACH approach is designed to help ecommerce businesses ensure their solutions can develop and evolve.

Get started with Atlas today

Get started in seconds. Our free clusters come with 512 MB of storage so you can experiment with sample data and get familiar with our platform.
Try freeContact sales
Illustration of hands typing on a laptop in the foreground and a superimposed desktop window and coffee cup in the background.