Generative AI use case: Generate personalized product recommendations

Last reviewed 2026-11-11 UTC

This document describes a high-level architecture for using AI to generate personalized product recommendations for a retail application in Google Cloud.

The intended audience for this document includes architects, developers, and administrators who build and manage generative AI applications in the cloud for the retail industry. The document assumes that you have a foundational understanding of generative AI.

Architecture

The following diagram shows an architecture that uses an AI model to generate personalized product recommendations based on insights from clickstream metrics.

Architecture for using AI to generate personalized product recommendations. Architecture for using AI to generate personalized product recommendations.

The architecture shows the following flows:

  • Ingest and process user data:
    1. Clickstream data such as page views, clicks, and purchases are uploaded to a Dataflow pipeline.
    2. Dataflow processes the data and derives insights such as user profiles and preferences. Dataflow then stores the data, insights, and vector embeddings in BigQuery.
  • Generate and serve product recommendations:
    1. A customer visits the company's storefront, which is a Cloud Run service in this architecture.
    2. The storefront service sends the visitor's data to a recommender service that runs on Cloud Run.
    3. The recommender service performs a vector similarity search in BigQuery and retrieves data about the visitor's profile and preferences.
    4. The recommender service sends the visitor's profile and preferences data to Gemini Enterprise Agent Platform, with a prompt to generate product recommendations. On Agent Platform, a Gemini model generates product recommendations that are tailored for the visitor.
    5. The recommender service sends the product recommendations to the storefront service, which then displays the recommendations.

To optimize cost and performance, add a cache between the storefront service and the recommender service. The recommender service checks the cache for visitor data. If the cache doesn't contain relevant data, the service performs a vector similarity search in BigQuery. To set up the cache, you can use Memorystore or configure a load balancer with Cloud CDN.

Products used

This example architecture uses the following Google Cloud products:

  • Cloud Run: A serverless compute platform that lets you run containers directly on top of Google's scalable infrastructure.
  • Gemini Enterprise Agent Platform: A comprehensive platform that lets you build, scale, govern, and optimize enterprise‑grade AI agents.
  • BigQuery: An enterprise data warehouse that helps you manage and analyze your data with built-in features like machine learning, geospatial analysis, and business intelligence.
  • Dataflow: A service that provides unified stream and batch data processing at scale.

Design considerations

This section describes design factors, best practices, and recommendations in alignment with the Google Cloud Well-Architected Framework. Consider this information when you use this reference architecture to develop a topology that meets your specific requirements for security, reliability, cost optimization, operational efficiency, and performance.

Security, privacy, and compliance

To help protect customer data and meet your security, privacy, and compliance requirements in Google Cloud, consider the following recommendations:

  • To screen prompts and recommendation responses for prompt injection, jailbreak attempts, and harmful content, use Model Armor.
  • To inspect and de-identify personally identifiable information (PII) in clickstream data, user profiles, and prompts, use Sensitive Data Protection.

Reliability

To buffer bursty clickstream traffic and decouple storefront event producers from your Dataflow pipeline, ingest user events through Pub/Sub. Buffering events in Pub/Sub helps prevent data loss during traffic spikes or pipeline updates.

Cost optimization

To reduce input token costs when prompts share repeated system instructions or product catalog context, use context caching on Agent Platform.

Operational efficiency

To reduce operational overhead when you build and maintain your recommendation pipeline in Google Cloud, consider the following options:

  • If you prefer a managed retail recommendation service over a custom pipeline, consider AI Commerce Search in Gemini Enterprise for Customer Experience. AI Commerce Search trains and serves personalized recommendation models directly from your product catalog and clickstream events.
  • To automatically generate and refresh embeddings in BigQuery when source data changes, use autonomous embedding generation.

Performance optimization

To help meet low-latency serving requirements for storefront visitors in Google Cloud, consider the following recommendations:

Deployment

To experiment with generative AI applications in Google Cloud for retail workloads, use the following code samples:

What's next

Contributors

Author: Kumar Dhanagopal | Cross-Product Solution Developer

Other contributors: