Docs Menu
Docs Home
/ /
Atlas Architecture Center
/ / /

Real-Time Personalization with Receipt Data

Make receipts a growth engine with the document model and AI insights powered by MongoDB.

Use cases: Modernization, Personalization, Single View

Industries: Retail

Products: MongoDB Atlas, MongoDB Atlas Triggers, MongoDB Atlas Vector Search, MongoDB Change Streams, Voyage AI

Partners: Microsoft Azure

We live in an era where paper processes are quickly being replaced by automated, personalized solutions like digital receipts. These elements are becoming the industry standard and are delivering tailored customer experiences.

Retailers who embrace this transformation gain a competitive advantage by unlocking the value of their data. Digital receipts provide rich, actionable insights that can drive personalized product recommendations and help businesses stand out from their competition.

This document explores how retailers can use MongoDB to store and manage digital receipt data to deliver personalized product recommendations and enhance the post shopping experience. You'll discover the common challenges of managing receipt data and how MongoDB simplifies access and activation for real-time, customer-centric experiences.

When a customer shops in a physical store, digital receipts become a strategic touchpoint. Retailers can use these items to provide tailored suggestions and as a link to continue online shopping, all within the same digital receipt.

When moving to the online experience, whether through a mobile app or a browser, customers receive personalized product recommendations based on their complete purchase history. They also keep their loyalty benefits across all channels, enjoying a personalized experience powered by a unified 360° customer journey.

digital receipts connect in-store and online journeys with real-time AI-powered recommendations

Figure 1. With MongoDB, digital receipts connect in-store and online journeys with real-time AI-powered recommendations, enabling a 360° customer experience

Digital receipts provide businesses access to multiple strategic advantages, including:

  • Enhancing customer engagement through personalized experiences: With transaction data, retailers can tailor marketing efforts such as delivering smart product recommendations, sharing personalized offers, and running targeted ad campaigns.

  • Unlocking valuable customer insights: By analyzing behavior and preferences at scale.

  • Reducing operational costs: By eliminating the need to print, store, and manage paper receipts.

Note

Customer Success Story

Discover how Albert Heijn, the largest supermarket chain in the Netherlands, uses MongoDB to support customer-facing applications.

Managing receipt data can be difficult. In this section, you will explore the key obstacles and learn how MongoDB can help overcome them.

Retailers often store multiple copies of sales data across disconnected third-party tools, leading to limited visibility and fragmented information that's hard to analyze, or activate. MongoDB addresses this challenge by acting as a centralized, flexible data platform that consolidates data from multiple systems. It simplifies integration, breaks down silos and creates a unified operational data layer that supports real-time data analysis for actionable insights.

Sales data often comes from legacy systems and is stored in complex, high-volume formats like XML, which are deeply nested and inconsistent. In RDBMS, architects must spread the data in multiple tables to handle that complexity. Instead, MongoDB uses its flexible document model to adapt to the data requirements, not the other way around. This capability enables faster development and easy schema changes, such as adding fields for personalized recommendations, at any time with no downtime.

Retailers generate massive volumes of receipt data every day and systems must keep up. For example, Albert Heijn, the largest supermarket chain in the Netherlands, uses MongoDB to process over one million daily transactions across 50 services. MongoDB scales automatically, offers sharding and replica sets for high availability, and allows you to separate workloads. This means real-time AI, reporting, or analytics can run without disrupting your main application.

Receipts often contain personal customer data making security and compliance essential. MongoDB supports secure and compliant data handling with robust, built-in enterprise security features and data privacy. Including full lifecycle data encryption, RBAC, and auditing. In addition, zone sharding allows you to store data in your chosen region, supporting compliance and performance across regions.

Turn receipt data into real-time value with this proof of concept using MongoDB Atlas as the central data store. The demo showcases a backend microservice for invoice creation in a mock e-commerce system, adaptable to physical stores. MongoDB unifies operational and AI data, providing full control over your data while keeping it accessible for downstream use.

Personalized customer experiences start with connected, accessible, and actionable data. A unified view of operational data is key to unlock the full potential of modern technologies.

This demo shows how MongoDB's flexible document model and real-time integration capabilities can turn operational data into intelligent, responsive customer journeys. The diagram below shows a high-level view of the solution:

  • E-commerce and in-store transactions flow into the MongoDB invoices collection, creating a complete and unified purchase history for each customer.

  • Operational data is stored using the MongoDB document model as a single source of truth.

  • Microservices and external systems seamlessly integrate with MongoDB capabilities to deliver real-time and AI-powered recommendations, triggered by invoice data.

Core solution components

Figure 2. This diagram illustrates the core components of the demo solution

To build this solution, you deploy two backend microservices - invoice and recommendation - on Azure App Services, and use Azure Functions to simulate external integrations, such as tax logic or loyalty programs. Rendered receipts are stored as PDFs in Azure Blob Storage, tightly linked to their structured metadata in MongoDB.

The document model stores all invoice-related data in a single collection, from tax details to a list of personalized product recommendations based on a specific purchase. This flexibility ensures that the schema can evolve alongside the business, enabling seamless updates without friction or downtime.

To enable personalization, you can store semi-structured data in MongoDB. The product catalog contains core details—like price, description, and categories—plus semantic data generated by AI embedding models. With Voyage AI voyage-3-large text embedding model, you can enrich product data with vector embeddings for smarter, AI-driven catalog retrieval.

Combination of traditional product details with vector embeddings from Voyage AI

Figure 3. MongoDB combines traditional product details with vector embeddings from Voyage AI, enabling semantic search and AI features directly in the product catalog.

Note

Embedding Models with Voyage AI

Voyage AI offers multiple text embedding models tailored to different domains, including legal, code, and finance. To explore the available models and find the best fit for your use case, visit the Text Embeddings Documentation.

Furthermore, you can implement product recommendations with Vector Search to identify products similar to those previously purchased by the customer. In this use case, a recommendation microservice generates suggestions for each customer. This microservice can be further improved by incorporating an AI model trained on previous purchase data.

Real-time customer experiences rely on systems that respond instantly to events. Event-driven architecture makes this possible by enabling services to communicate through events, signaling that something important has happened. This pattern is widely adopted in modern retail systems because it allows services to stay decoupled, scalable, and highly responsive.

You can apply Change Streams and Atlas Triggers to detect database changes and coordinate microservices through a choreography pattern. This pattern is explained in the invoice and recommendation microservices.

Event-driven choreography

Figure 4. Event-driven choreography enables real-time recommendations based on a customer's most recent purchase, improving their overall experience

Invoice microservice: When a customer places an order (step 1), the invoice microservice listens to the orders collection via Change Streams. It automatically detects the new order and creates the invoice document inserting it into MongoDB Atlas (step 2). Then, the transaction data can continue its flow to external providers like ERP platforms (step 3).

Recommendation microservice: As soon as a new invoice is added to the collection, the recommendation microservice reacts and creates AI-powered product suggestions based on the purchase (step 4). These recommendations are embedded in the invoice and the user profile documents using Atlas Triggers (step 5). This update personalizes the invoice and enriches the user profile with the latest embedded recommendations. The frontend can then quickly retrieve this data with a simple query and display it on the homepage (step 6), keeping the systems updated and the user experience responsive.

You can integrate MongoDB into an event-driven architecture using an event broker to route and distribute events across multiple services. This enables systems to react in real time, ensuring decoupling, scalability, and fault tolerance.

Azure cloud integrations in action

Figure 5. Azure cloud integrations in action

In the demo, the microservice serves as a Change Stream listener that reacts to database events. These events could then be forwarded to Azure Event Grid or Azure Service Bus to trigger downstream workflows, or integrate with external systems. Alternatively, an Azure Function can act as a serverless bridge to capture Change Stream events from the database and push them to the event broker. For high-throughput scenarios, such as real-time analytics or AI training, you can stream events using the Kafka Connector to Azure Event Hubs.

This solution shows how retailers can centralize invoice data and deliver real-time personalization with a clean, event-driven architecture powered by MongoDB Atlas.

The backend repository implements two microservices: one for invoice generation and one for recommendations, along with supporting components such as Atlas Triggers, Azure Functions, and Azure Blob Storage. These services simulate how systems react to customer purchases in real time.

The frontend repository contains a mock e-commerce site, Leafy Popup Store, for handling orders and users. To get started, follow the pre-requisites and setup instructions, then use the UI to simulate purchases and see the demo in action.

1

Before running this solution you will need:

  • A MongoDB Atlas Account

  • A database pre-loaded with product embeddings (you can restore it using the dump provided here)

  • An Azure Account

  • Python 3.10

  • Poetry installed

  • Docker installed

  • GNU Make (default on macOS/Linux)

2

The project is organized as a multi-service backend system, with each microservice in its own folder and a shared Makefile and Docker Compose setup at the root level. To run the full solution or work on individual services, you'll find detailed setup steps in each README.

Here’s a quick summary of what each part contains:

  1. Main Project README: Overview of the architecture, system components, and how to run all services together using make commands and Docker Compose.

  2. services/invoice-ms: Setup instructions for the invoice microservice. Covers how to run it locally or in Docker, configure Azure Blob Storage and Azure Functions, and connect to MongoDB.

  3. services/recommendations-ms:. Setup for the recommendation engine, which listens to new invoices and performs a vector search in MongoDB Atlas. It includes the environment setup, connection to the vector index, and how to trigger and observe recommendations. Additionally, you will also find:

    • A /docs/adr/ folder with ADRs explaining modeling and design choices.

    • An /external/ folder containing sample Azure Functions and Atlas Triggers used in the demo, each with its own corresponding README.

Note: Deploy the frontend and order system from the Leafy Pop-Up Store demo before using this solution.

Lets recap some of the key takeaways from the solution:

  • AI-Powered personalization is crucial to stay competitive and on top of the game: It can boost customer engagement and strengthen loyalty.

  • Digital receipts offer more value than just a transactional record: Their insight can be used to personalize a 360 shoppers journey.

  • MongoDB is built for modern use cases: It offers flexibility at scale, built-in security, and removes friction for seamless integration with real-time architectures and AI features.

Ready to turn your receipt data into personalized customer moments? Start building with MongoDB today or join the MongoDB Developer Community to connect with other tech lovers.

  • Florencia Arin, MongoDB

  • Angie Guemes, MongoDB

Back

Building Modern Omnichannel Ordering on MongoDB

On this page