For You

Personalized tile rankings per shopper. Same query, different per customer: _recommend with the household's pets, the month, the cart and the shopper's own history as context.

For You: screenshot from the E-commerce demo
🛒 E-commerce_recommend_predictE-commerce
In the demoPicked for you in the e-commerce demo's Shop: one _recommend over impressions, goal purchased, with the shopper's pets, the month, the cart and their own history as context, and anything from their last order re-asked as just bought.

The problem

The For-You feed is the load-bearing surface in any e-commerce or content product. It is the page where personalization either obviously works or obviously doesn't. Most catalog tools default to manually curated tiles plus a generic "popular" sort; personalization gets added as a separate ranking model that has to be trained, monitored, and re-tuned. The cost of building it is what keeps For-You feeds stuck at curated-default in most products.

The signal that should drive the feed is in the data already. Every customer's purchase history, browse pattern, segment membership, and engagement signal is queryable. The feed is asking the wrong question: "what's popular?" The right question is "what is this customer likely to want?" — and that is a _recommend query against the available signals.

How it works

_recommend ranks the candidate products per customer by the probability of a purchase when shown. The query takes the shopper's context (declared pets, the month, the categories in the cart and the last order, and the customer id) and returns the ranked list with probabilities and a $why, which the Shop turns into reasons such as "Fits your pets" or "Sells in April". Anything from the shopper's last order is re-asked in one _batch as _predict with just_bought set, and falls: shoppers rarely re-buy what they just bought.

Re-ranking adapts continuously. Every impression and purchase enters the index immediately; the next refresh reflects the new signal.

{
  "from": "impressions",
  "where": {
    "context.customer.pets": {
      "$and": [
        {
          "$match": "small_animal"
        }
      ]
    },
    "context.month": "2026-04",
    "context.basket_categories": {
      "$and": [
        {
          "$match": "small_animal_accessories"
        },
        {
          "$match": "small_animal_cage"
        },
        {
          "$match": "small_animal_dryfood"
        },
        {
          "$match": "small_animal_water_bottle"
        }
      ]
    },
    "context.customer": "CUST-00922",
    "just_bought": false
  },
  "recommend": "product_sku",
  "goal": {
    "purchased": true
  },
  "select": [
    "sku",
    "name",
    "brand",
    "pet_type",
    "category",
    "price_eur",
    "avg_rating",
    "tags",
    "$p",
    "$why"
  ],
  "limit": 16
}

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application. For the whole picture, see predictive e-commerce.

See it live

This use case runs in the 🛒 E-commerce demo today. Click through to the live application and inspect the queries that produce the result.

Open the live demo →

Build it with Claude Code

Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.

Personal recommendations: a prompt for Claude Code
Add personal recommendations to this codebase using Aito, a predictive database. The feature: recommend products for each shopper from our orders and browsing events.

1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code).
2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query.
3. Read the use-case guide: https://aito.ai/use-cases/for-you/
4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/src/recommend_service.py and https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/data/generate_fixtures.py
5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample.
6. Measure before wiring the UI: hold out recent rows and report how often the item actually chosen is in the top 3, against the order we show today.
7. In the UI, show the ranking as suggestions, with the reasons where the query gives them. Nothing is applied without the user.

Ask me before changing anything outside the new feature.

Frequently asked

How does this compare to traditional recommender systems (collaborative filtering, neural CF)?

Same conceptual family; different implementation. _recommend runs the conditional probability at query time from indexed signals; collaborative filtering and neural CF build offline models. The query-time approach reflects new data immediately, with no model to retrain.

What about new visitors with no history?

A shopper with no history is ranked by what is known: the household's declared pets, the month and the cart. Each signal joins the context as it appears; there is no fixed number of impressions before the ranking turns personal.

Can the For-You feed mix content types (products, articles, categories)?

Yes. _recommend works on any column with a candidate set; mix product IDs, category IDs, and content IDs as the target attribute. The application renders the mixed result. Many deployments run separate queries per content type and merge in the UI for editorial control.

How quickly does the ranking update after new clicks?

Immediately. Click enters the index, next query reflects it. There is no batch update or retraining schedule. Seasonal patterns, trend shifts, new product launches — all visible in the ranking within seconds.

Can the feed be controlled with editorial rules (boost X, demote Y)?

Yes. Add boost/demote modifiers in the application layer; the prediction provides the baseline ranking; the editorial layer adjusts. Most deployments run a hybrid: prediction provides the personalization signal, editorial rules handle the merchandising overrides.