Recommendation Engine

Build intelligent product and content recommendations in a single multi-model database — no external recommendation service required. Graph traversal powers collaborative filtering through relationship patterns like User-PURCHASED→Product and User-WATCHED→Show, vector similarity drives content-based recommendations using vectorNeighbors() with LSM_VECTOR indexes on product and show embeddings, and time-series analysis detects trending items by aggregating interaction counts over time windows.

Architecture Overview

Vertices

User, Product, Show (each with embedding vectors)

Edges

PURCHASED, WATCHED, INTERACTED

Documents

ProductInteraction (productId, purchaseCount, timestamp)

Users connect to products and shows through purchase, watch, and interaction edges. Each item carries a 4-dimensional embedding vector for content-based similarity. A ProductInteraction document type tracks interaction counts over time for trending analysis.

Key Queries

Collaborative Filtering — Find products purchased by users who bought the same items:

MATCH (u:User)-[:PURCHASED]->(p:Product)<-[:PURCHASED]-(other:User)-[:PURCHASED]->(rec:Product)
WHERE u.name = 'Alice' AND NOT (u)-[:PURCHASED]->(rec)
RETURN rec.name, count(other) AS score ORDER BY score DESC

Vector Similarity Search — Find products similar to a given product by embedding:

SELECT name, category, distance FROM (
  SELECT expand(vectorNeighbors('Product[embedding]', [0.9, 0.1, 0.8, 0.2], 5))
) ORDER BY distance

Trending Detection — Identify trending products by recent interaction volume:

SELECT productId, SUM(purchaseCount) AS total
FROM ProductInteraction
WHERE timestamp > date('2024-01-14', 'yyyy-MM-dd')
GROUP BY productId ORDER BY total DESC

Try It Yourself

git clone https://github.com/ArcadeData/arcadedb-usecases.git
cd arcadedb-usecases/recommendation-engine
docker compose up -d
./setup.sh
./queries/queries.sh