Skip to content

Commit 4496d36

Browse files
authored
AI realtime pricing (#199)
* AI Driven Real Time Pricing Draft * AI Driven Real Time Pricing Draft * AI Driven Real Time Pricing Draft for Manufacturing * AI Driven Real Time Pricing Draft Sub Bullets * AI Driven Real Time Pricing Final * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Github * Added Cards * RealTime Pricing Updated * RealTime Pricing Updated * RealTime Pricing Updated * RealTime Pricing Updated * Updated Solutions Lib * Updated Solutions Lib * Updated Solutions Lib * Updated Files * Updated Files * Updated Files * Updated Files * Updated Files * Updated SVG files * Updated SVG files * Deleted avif pictures
1 parent acd1dcf commit 4496d36

File tree

8 files changed

+258
-6
lines changed

8 files changed

+258
-6
lines changed

source/includes/images/industry-solutions/Dynamic Pricing 1.svg

Lines changed: 1 addition & 0 deletions
Loading

source/includes/images/industry-solutions/Dynamic Pricing 2.svg

Lines changed: 1 addition & 0 deletions
Loading

source/solutions-library.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,25 @@ kick-start their projects.
343343
:icon: industry_ai
344344
:icon-alt: Atlas industry_ai icon
345345

346-
Discover how Agentic RAG creates seamless and natural interactions with customers, enhancing their shopping experience.
347-
346+
Discover how Agentic RAG creates seamless and natural
347+
interactions with customers, enhancing their shopping
348+
experience.
349+
348350
Personalization
349351
---------------
350352

351353
.. card-group::
352354
:columns: 2
353355
:style: extra-compact
354356

357+
.. card::
358+
:headline: AI-Driven Real-Time Pricing with MongoDB and Vertex AI
359+
:url: https://deploy-preview-199--docs-atlas-architecture.netlify.app/solutions-library/AIDriven-real-time%20pricing/
360+
:icon: general_content_play
361+
:icon-alt: Atlas general_content_play icon
362+
363+
Leverage real-time data insights to optimize prices and gain a competitive edge.
364+
355365
.. card::
356366
:headline: Dynamic Pricing
357367
:url: https://deploy-preview-232--docs-atlas-architecture.netlify.app/solutions-library/retail-dynamic-pricing/
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
.. _arch-center-is-ai-driven-realtime-pricing:
2+
3+
======================================================
4+
AI-Driven Real-Time Pricing with MongoDB and Vertex AI
5+
======================================================
6+
7+
.. facet::
8+
:name: genre
9+
:values: tutorial
10+
11+
.. contents:: On this page
12+
:local:
13+
:backlinks: none
14+
:depth: 1
15+
:class: singlecol
16+
17+
Leverage real-time data insights to optimize prices and gain a
18+
competitive edge.
19+
20+
**Use cases:** `Personalization <https://www.mongodb.com/solutions/use-cases/personalization>`__, `Gen AI
21+
<https://www.mongodb.com/use-cases/artificial-intelligence>`__
22+
23+
**Industries:** `Retail <https://www.mongodb.com/industries/retail>`__
24+
25+
**Products:** `Atlas <http://mongodb.com/atlas>`__, `Vertex AI <https://cloud.google.com/vertex-ai/?hl=en>`__
26+
27+
**Partners:** `Google Cloud <https://cloud.google.com/gcp/?hl=en>`__
28+
29+
30+
Solution Overview
31+
-----------------
32+
33+
Dynamic pricing, the art of adjusting prices in real time based on
34+
market conditions, has become a crucial strategy for businesses aiming
35+
to maximize revenue and gain a competitive edge. To effectively
36+
implement dynamic pricing, a robust technological infrastructure is
37+
essential. This solution integrates `MongoDB Atlas
38+
<https://www.mongodb.com/atlas>`__ and Google Cloud Vertex AI to create
39+
a real-time dynamic pricing microservice. By utilizing Google Cloud
40+
Pub/Sub for rapid data ingestion, Vertex AI Notebooks and TensorFlow
41+
models analyze customer behavior to optimize pricing strategies. MongoDB
42+
Atlas serves as a flexible feature store for intricate pricing data,
43+
while Google Cloud's robust computational resources power complex
44+
calculations and hosting.
45+
46+
The outcome is a scalable and adaptable pricing system that delivers
47+
instant price adjustments based on the latest market intelligence. This
48+
integration enhances operational efficiency by effectively handling
49+
large datasets and complex pricing scenarios. Continuous model
50+
retraining guarantees ongoing accuracy and market competitiveness.
51+
52+
.. video:: https://youtu.be/32_yHQqx8qU
53+
54+
Reference Architectures
55+
-----------------------
56+
57+
The architecture for a dynamic pricing microservice integrates MongoDB
58+
and Google Cloud Vertex AI to facilitate real-time data processing and
59+
responsive pricing adjustments. At the core, Google Cloud Pub/Sub
60+
handles the ingestion and distribution of customer behavior data,
61+
allowing for scalable and efficient message processing. This data is
62+
then cleaned and processed in Vertex AI Notebooks, where machine
63+
learning models are developed using TensorFlow to predict optimal prices
64+
based on patterns identified in historical data.
65+
66+
MongoDB Atlas serves as the central data repository and feature store,
67+
storing complex pricing data and supporting the machine learning models.
68+
The document model of MongoDB provides the flexibility needed to manage
69+
and update pricing data dynamically. Google Cloud Functions orchestrate
70+
the entire workflow, processing customer events, converting them into
71+
tensors, and ensuring that the model predictions are updated in real
72+
time in the MongoDB Atlas product catalog. In the architecture diagram,
73+
the blue data flow illustrates how customer event data is ingested into
74+
a Pub/Sub topic, leading to a push subscription that triggers the Cloud
75+
Function. This function transforms raw events into tensors and updates
76+
the predicted prices in the MongoDB product catalog.
77+
78+
This architectural approach allows for the isolation of raw event
79+
threads, enabling the development of various services that can react in
80+
real time for dynamic pricing or operate asynchronously for model
81+
training. By maintaining loose coupling between components, the system
82+
is resilient and avoids complete failures if one part experiences
83+
issues. Publishers and subscribers can independently continue processing
84+
their logic, ensuring a robust and flexible system that supports
85+
continuous operation and seamless updates.
86+
87+
.. figure:: /includes/images/industry-solutions/Dynamic Pricing 1.svg
88+
:figwidth: 1200px
89+
:alt: Dynamic pricing architecture integrating different Google Cloud components and MongoDB Atlas as a Feature Store
90+
91+
Figure 1. Dynamic pricing architecture integrating different Google Cloud components and MongoDB Atlas as a Feature Store
92+
93+
94+
Building the Solution
95+
---------------------
96+
97+
In the `GitHub repository <https://github.com/mongodb-industry-solutions/retail-store/blob/main/microservices/dynamicPricing/gettingStarted.md>`__, you will find detailed instructions on how to build this solution.
98+
99+
.. procedure::
100+
:style: normal
101+
102+
.. step:: Setting Up MongoDB Atlas
103+
104+
- Sign in to `MongoDB Atlas <https://www.mongodb.com/atlas>`__ and
105+
create a new `cluster
106+
<https://www.mongodb.com/resources/products/fundamentals/mongodb-cluster-setup>`__.
107+
- Choose a region closest to your user base for optimal performance.
108+
- Configure security by:
109+
- Creating database users with specific roles.
110+
- Enabling IP access to secure the database connection.
111+
- Connect to your cluster using the connection string provided
112+
by Atlas for application integration.
113+
114+
.. step:: Setting Up Google Cloud:
115+
116+
- Log into `Google Cloud console <https://console.cloud.google.com/>`__ and create a new project for your microservice.
117+
- Ensure that the `necessary APIs <https://www.mongodb.com/developer/products/mongodb/dynamic-pricing-microservice-vertexai/#step-2--setting-up-gcp>`__ are enabled for your project.
118+
- Install and initialize the Google Cloud CLI.
119+
- Authenticate with your Google Cloud account.
120+
- Set your project as the default.
121+
122+
.. step:: Develop the Microservice and Model
123+
124+
- Clone the `repository <http://github.com/mongodb-industry-solutions/retail-store.git>`__ and navigate to the dynamicPricing microservice directory.
125+
- Install required Python packages using pip.
126+
- Set up environment variables for MongoDB Atlas, Google Cloud credentials, and Pub/Sub.
127+
- Configure a Pub/Sub topic in Google Cloud.
128+
- Develop the pricing logic for the dynamicPricing service.
129+
- Use `Vertex AI <https://cloud.google.com/vertex-ai?hl=en>`__ to create a new notebook for connecting to MongoDB and training the model.
130+
- Train a `TensorFlow <https://www.youtube.com/watch?v=nykQEHp-fYg&t=7s>`__ model by cleaning data, building the model, and training it.
131+
- Save and upload the trained model to Google Cloud Storage.
132+
- Register the model in Vertex AI for management and deployment.
133+
134+
.. step:: Deploy a Model to an Endpoint:
135+
136+
- Deploy the Model:
137+
- Access the Vertex AI section in Google Cloud console.
138+
- Locate and select the model you want to deploy.
139+
- Click on `"Deploy to endpoint" <https://cloud.google.com/vertex-ai/docs/general/deployment>`__ under the "Deploy & Test" tab.
140+
- Complete the deployment setup by configuring model settings and monitoring.
141+
142+
- Retrieve Endpoint ID:
143+
- Go to "Endpoints" in Vertex AI and note the Endpoint ID for use in Cloud Function configuration.
144+
145+
- Configure Cloud Function:
146+
- Create a new Cloud Function in Google Cloud.
147+
- Set the function's trigger to the Pub/Sub topic you created.
148+
- Implement code in the function to preprocess event data,
149+
invoke the Vertex AI model for predictions, and update MongoDB
150+
with the results.
151+
152+
- Prepare Dependencies:
153+
- Ensure the requirements.txt file includes all necessary libraries for the Cloud Function.
154+
155+
- Simulate Customer Events:
156+
- Use a provided script to generate synthetic customer behavior data.
157+
- Push this data to MongoDB and Pub/Sub to test the model and
158+
microservice integration.
159+
160+
- Run the Simulation:
161+
- Execute the script to validate the complete end-to-end system.
162+
163+
Advantage of MongoDB for Modeling Events
164+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165+
166+
Adding a tensor allows for an event-driven architecture with all
167+
features in a single collection, which can streamline data retrieval and
168+
processing but may lead to large, complex documents that require careful
169+
management to maintain performance. This flexibility enables MongoDB to
170+
house both operational data and a feature store within the same
171+
collection, facilitating integrated data analytics and real-time
172+
decision-making while potentially increasing storage costs and
173+
complexity in data management.
174+
175+
.. figure:: /includes/images/industry-solutions/Dynamic Pricing 2.svg
176+
:figwidth: 1200px
177+
:alt: Data structure within the events collection representing a simulated user view of MongoDB white socks, including price information.
178+
179+
Figure 2. Data structure within the events collection representing a simulated user view of MongoDB white socks, including price information.
180+
181+
For more-detailed instructions on how to build your own dynamic
182+
microservice, please refer to our blog post, `Building a Dynamic Pricing
183+
Microservice with Vertex AI and MongoDB Atlas
184+
<https://www.mongodb.com/developer/products/mongodb/dynamic-pricing-microservice-vertexai/>`__.
185+
186+
Key Learnings
187+
-------------
188+
189+
- **Centralized feature store:** MongoDB serves as a feature store, acting
190+
as a centralized repository specifically designed for storing, managing,
191+
and serving features for `machine learning
192+
<https://www.mongodb.com/resources/basics/machine-learning>`__ (ML)
193+
models. Its `polymorphic
194+
<https://www.mongodb.com/developer/products/mongodb/polymorphic-pattern/>`__
195+
capabilities enable the utilization of a single interface to represent
196+
various types of data. This implies that as new features are introduced
197+
or pricing models evolve, MongoDB can adeptly manage diverse data types
198+
within the same system. In the context of dynamic pricing, this
199+
capability facilitates the seamless incorporation of new pricing factors
200+
or variables without causing disruptions to existing data structures or
201+
operations.
202+
- **Scalability and efficiency:** `Google Cloud Pub/Sub
203+
<https://cloud.google.com/pubsub?hl=en>`__ can handle massive
204+
volumes of customer data efficiently, ensuring scalability for
205+
real-world applications. While this microservice simulates only 25
206+
customer events every three seconds, Pub/Sub is capable of processing
207+
much larger data streams.
208+
- **Real-time price updates:** `Cloud functions
209+
<https://cloud.google.com/functions?hl=en>`__ trigger `TensorFlow
210+
<https://www.youtube.com/watch?v=nykQEHp-fYg&t=7s>`__ models to
211+
generate dynamic prices based on customer behavior. These generated
212+
prices are then inserted or updated (upserted) back into the product
213+
catalog collection in MongoDB. This enables real-time adjustments in
214+
the e-commerce application because the application's front end
215+
retrieves data directly from the same collection.
216+
217+
Technologies and Products Used
218+
------------------------------
219+
220+
MongoDB Developer Data Platform
221+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
222+
223+
- `MongoDB Atlas <https://www.mongodb.com/atlas>`__
224+
- Atlas Collections
225+
- Atlas Clusters
226+
227+
228+
Partner Technologies
229+
~~~~~~~~~~~~~~~~~~~~
230+
231+
- `Google Cloud <https://cloud.google.com/>`__
232+
- `Vertex AI <https://cloud.google.com/vertex-ai>`__
233+
- `Cloud Functions <https://cloud.google.com/functions>`__
234+
235+
Author
236+
------
237+
238+
- Francesco Baldissera, MongoDB
239+
- Sebastian Rojas Arbulu, MongoDB

source/solutions-library/manufacturing-iot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Manufacturing & Motion IoT
66
:titlesonly:
77

88
Building an IoT Data Hub <solutions-library/IoT-datahub-manufacturing>
9-
Real-Time Audio Diagnostics <solutions-library/audio-based-AI-diagnostics>
9+
Real-Time Audio Diagnostics <solutions-library/audio-based-AI-diagnostics>

source/solutions-library/retail-gen-ai.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Retail Gen-AI
77

88
AI Product Search </solutions-library/retail-ai-product-search>
99
Automating Product Descriptions <solutions-library/retail-asset-product-description>
10-
Launching an Agentic RAG Chatbot <solutions-library/retail-asset-rag-chatbot>
10+
Launching an Agentic RAG Chatbot <solutions-library/retail-asset-rag-chatbot>

source/solutions-library/retail-personalization.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ Retail Personalization
55
.. toctree::
66
:titlesonly:
77

8-
Dynamic Pricing </solutions-library/retail-dynamic-pricing.txt>
8+
AI-Driven Real-Time Pricing </solutions-library/AIDriven-real-time pricing>
9+
Dynamic Pricing </solutions-library/retail-dynamic-pricing>

source/solutions-library/retail.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Retail
77

88
Catalog <solutions-library/retail-catalog>
99
Gen AI <solutions-library/retail-gen-ai>
10-
Personalization <solutions-library/retail-personalization>
10+
Personalization <solutions-library/retail-personalization>

0 commit comments

Comments
 (0)