Blueprint: e-commerce analytics
Basket analysis and recommendations from one connected graph.
Cross-sell, basket analysis, and lifetime-value questions all depend on how products, orders, and customers connect — relationships that flat order tables encode poorly. This blueprint stores that connected structure directly as products, orders, and customers link to each other on write, so those questions run as graph queries against live catalog and order data instead of a nightly analytics job.
E-commerce graph analytics is a RushDB blueprint that connects PRODUCT, ORDER, and CUSTOMER records as one graph, so basket analysis, cross-sell recommendations, and lifetime-value queries traverse purchase relationships directly instead of running through a separate analytics pipeline.
Product and purchase relationships live outside the operational database.
Which products are frequently bought together, which customers are trending toward higher lifetime value, and which browsing sessions preceded a purchase are all relationship questions. Flat order-line tables answer them only after significant manual joins, usually rebuilt in a batch job or spreadsheet that is already stale by the time a merchandising or recommendation decision needs it.
Before
- Basket analysis requires exporting order line items into a separate tool
- Product relationships are recomputed in batch jobs
- Recommendation logic is disconnected from live catalog and inventory state
- Customer lifetime value is calculated in a spreadsheet or BI tool on a delay
With RushDB
- Products, orders, customers, and browsing events are connected Records
- Basket and cross-sell queries traverse purchase relationships directly
- Recommendations read current catalog and inventory state, not a stale export
- Lifetime-value queries run against live order history
Graph intelligence on ingest
Incoming data becomes queryable graph context.
An ORDER record with a nested ITEM array referencing PRODUCT records lands connected on write, so a basket query never needs to reassemble order lines after the fact. RushDB infers price, quantity, and category types from the payload, links each ITEM to its ORDER and PRODUCT automatically, and can suggest CO_PURCHASED-style relationships once enough order history accumulates.
01
Normalize catalog and order data as it arrives
Import PRODUCT and ORDER records, including nested ITEM arrays. RushDB infers price, quantity, and category types without a schema migration.
02
Auto-link orders to line items
Nested ITEM entries in an order payload become Records connected to both the ORDER and the PRODUCT automatically, preserving basket structure on write.
03
Enrich with co-purchase and browsing patterns
Once orders accumulate, suggested-relationship analysis can propose CO_PURCHASED links between products or connect imported browsing EVENT data to the same graph.
Suggested relationship analysis requires an LLM configured for the project. Suggestions stay in draft form until you approve them, so inferred domain meaning never mutates the graph silently. You can also add explicit relationships through the SDK or API.
Review suggested relationship patternsData model
One flexible graph for the workflow.
Start with the payload shape your product already produces. RushDB stores it as Records, infers typed properties, and keeps nested or approved domain relationships queryable.
One order write links to its customer and each purchased product, making basket relationships queryable immediately.
{
"orderId": "ord-7741",
"customerId": "cust-330",
"ITEM": [
{ "productId": "sku-mug-01", "qty": 1 },
{ "productId": "sku-notebook-04", "qty": 2 }
]
}Working example
Find frequently co-purchased products in one query.
Once orders and products are connected, a basket-analysis query traverses purchase relationships directly instead of aggregating a flat order-line export.
ORDER ord-7741
customerId: "cust-330"
ITEM: [
{ productId: "sku-mug-01", qty: 1 },
{ productId: "sku-notebook-04", qty: 2 }
]{
"labels": ["PRODUCT"],
"where": { "productId": "sku-mug-01" },
"relatedTo": { "label": "PRODUCT", "via": "CO_PURCHASED" }
}{
"product": "sku-mug-01",
"frequently_bought_with": ["sku-notebook-04", "sku-coaster-02"]
}TypeScript SDK
Push order data, then query product relationships directly.
This works today over JSON pushed through the SDK. Native source connectors (MongoDB, Postgres, API or CDC pipelines) are on the roadmap — not required to use this pattern now.
from rushdb import RushDB
db = RushDB('RUSHDB_API_KEY')
schema = db.ai.get_schema_markdown({'labels': ['PRODUCT', 'ORDER', 'CUSTOMER']}).data
db.records.import_json(
label='ORDER',
data={
'orderId': 'ord-7741',
'customerId': 'cust-330',
'ITEM': [
{'productId': 'sku-mug-01', 'qty': 1},
{'productId': 'sku-notebook-04', 'qty': 2},
],
},
)
basket = db.records.find({'labels': ['PRODUCT'], 'where': {'productId': 'sku-mug-01'}})Implementation blueprint
Build the e-commerce analytics graph.
Use this sequence to connect catalog, order, and customer data for basket analysis and recommendations.
- 01Import PRODUCT records with category, price, and inventory fields
- 02Import ORDER records with nested ITEM records linking to products
- 03Link ORDER to CUSTOMER for lifetime-value queries
- 04Query co-purchased products and customer order history directly
- 05Extend with browsing EVENT records for pre-purchase journey analysis
Build path
- Keep product, order, and customer relationships explicit, not flattened into a single order-line table.
- Use exact filters for category, price, and inventory before any semantic ranking on product descriptions.
- Treat recommendation output as a candidate list for your application to rank and present, not a final decision.
- Push data via the SDK today; native MongoDB/Postgres/API/CDC connectors are roadmap items, not current capabilities.
Relevant docs
Read the exact primitives behind this pattern.
These links point to the RushDB docs pages that map directly to this blueprint: ingestion, labels, properties, values, SearchQuery, relationships, semantic search, MCP, or deployment.
Import JSON data
Push nested product and order data and let RushDB create the connected records automatically.
Open docsSearch introduction
Query co-purchased products and customer order history with exact filters and relationship traversal.
Open docsSemantic search
Index product descriptions for semantic search alongside exact category and price filters.
Open docsHow it works
Build the smallest useful workflow first.
01
Connect catalog and orders
Import products and orders so purchase relationships are queryable, not just stored as flat rows.
02
Query basket and cross-sell patterns
Traverse from a product to what else is frequently ordered alongside it.
03
Extend with browsing events
Add pre-purchase browsing events to connect journey analysis to the same graph.
Know where it fits.
Ingestion today vs. roadmap
JSON import via the SDK works now. Native connectors for MongoDB, Postgres, APIs, and CDC pipelines are planned but not yet available — push exported JSON in the meantime.
Recommendations need application logic
RushDB returns connected candidates. Ranking, personalization rules, and final recommendation logic remain your application’s responsibility.
Questions developers ask.
Next step
Start with one focused workflow.
Related use cases
Explore all use casesSupply chain graph analytics
Map suppliers, shipments, products, and warehouses to uncover dependencies and disruption risk.
Explore supply chain analyticsCustomer 360 graph analytics
Connect users, orders, subscriptions, support interactions, and events into one queryable customer graph.
Explore customer 360 analyticsAI-powered apps
Add search and connected-data features without another sync pipeline.
Explore AI-powered apps