E-Commerce Recommendation Engine

A store with a million products, and one shopper. Which handful do you put in front of them, right now, as they browse?

A hybrid recommender built during an internship: it blends what a shopper has bought before with what they're doing this very session, to personalise the storefront in real time.

Stage 1 · The problem

Too many products, too little attention

A large e-commerce catalogue holds hundreds of thousands of items; a shopper will look at a dozen. Showing everyone the same best-sellers wastes that attention. The job of a recommender is to put the few most relevant items in front of each person, and to update that choice as they move through the site, click by click.

Stage 2 · Two signals

Who you are, and what you're doing now

Good recommendations draw on two very different signals. One is long-term history: everything you've bought and rated before, which says who you are as a shopper. The other is the live session: the items you've clicked, searched and viewed in the last few minutes, which says what you want today. This engine uses both, and weighs the fresh signal heavily.

◴ LONG-TERM HISTORY
bought a camera last year
rated two lenses highly
a travel backpack
stable: who you are
⚡ THIS SESSION
just viewed a tripod
searched "low-light"
added a lens to cart
fresh: what you want now
Stage 3 · Collaborative filtering

"People like you also bought…"

Collaborative filtering never looks at what a product is. It learns from behaviour: every shopper and every item is turned into a vector (a learned embedding, from matrix factorisation over the purchase matrix), placed so that people who buy alike, and items bought together, sit close. To recommend, it simply reads off the nearest items. Click a product to see its neighbours in that learned space.

Distance = learned similarity. The clusters emerge from behaviour alone; no one labelled them.

Stage 4 · Content-based filtering

…and "more like what you looked at"

Collaborative filtering has a blind spot: a brand-new item nobody has bought yet has no behaviour to learn from (the cold-start problem). Content-based filtering fills it. Each item carries a feature vector (category, brand, price band, specs, text and image features), and the engine recommends items whose features match what you engaged with. It needs no purchase history, so it works from a shopper's very first click.

Content-based covers new items and new shoppers; collaborative captures taste that features can't describe. Together they cover each other's gaps.

Stage 5 · The architecture

Two stages: retrieve a few hundred, then rank them

Scoring a million items for every page view is impossible in the milliseconds a page has. So production recommenders split the work. Candidate generation cheaply retrieves a few hundred plausible items from collaborative neighbours, content matches and what's trending. Then a heavier ranking model scores just those, folding in live session features, and returns the top handful. Served behind a Flask API over a SQL store.

① CANDIDATE GENERATION
Narrow a huge catalogue to a few hundred candidates: fast and approximate.
collaborative neighbourscontent matchestrending
② RANKING
Score each candidate precisely, with live session features, and sort.
history ✕ sessionprice, recencytop-N

Flask serves the request; SQL holds the catalogue, interactions and precomputed embeddings.

Stage 6 · See it recommend

Pick a shopper, then browse

Choose a shopper profile to set the long-term history, then click products to "view" them and watch the recommendation rail re-rank in real time. Each pick shows why it's there: collaborative, content, your profile, or trending. This is the hybrid, two-stage idea in miniature.

Shopper:
The catalogue: click to browse
This session:nothing viewed yet
Recommended for youtop-N

Scores and the blend are illustrative: a faithful sketch of how a hybrid ranker behaves, not the production model.