<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bhaumik Tandan</title>
    <description>The latest articles on DEV Community by Bhaumik Tandan (@bhaumik_tandan_8685cfeaf2).</description>
    <link>https://dev.to/bhaumik_tandan_8685cfeaf2</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4089409%2F3a5f2f97-c40e-4ac9-8c56-dadffbb4e556.png</url>
      <title>DEV Community: Bhaumik Tandan</title>
      <link>https://dev.to/bhaumik_tandan_8685cfeaf2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bhaumik_tandan_8685cfeaf2"/>
    <language>en</language>
    <item>
      <title>I built a TikTok-style shopping feed with a recommender system — in pure client-side JS</title>
      <dc:creator>Bhaumik Tandan</dc:creator>
      <pubDate>Sat, 22 Aug 2026 08:42:41 +0000</pubDate>
      <link>https://dev.to/bhaumik_tandan_8685cfeaf2/i-built-a-tiktok-style-shopping-feed-with-a-recommender-system-in-pure-client-side-js-320a</link>
      <guid>https://dev.to/bhaumik_tandan_8685cfeaf2/i-built-a-tiktok-style-shopping-feed-with-a-recommender-system-in-pure-client-side-js-320a</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; I built &lt;a href="https://thodasa.com" rel="noopener noreferrer"&gt;ThodaSa&lt;/a&gt; — a reels-style impulse-shopping demo for the Indian market. You scroll products like Instagram reels, and the feed &lt;em&gt;learns your taste&lt;/em&gt; — with no backend, no login, and no tracking servers. The whole recommender is ~150 lines of client-side JavaScript. &lt;a href="https://github.com/Bhaumik-Tandan/thodasa" rel="noopener noreferrer"&gt;Code is on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;Quick-commerce apps in India (Blinkit, Zepto, Meesho) figured out something interesting: shopping &lt;em&gt;is&lt;/em&gt; entertainment. I wanted to push that to its logical end — what if the store was literally a reels feed? One product per screen, full-bleed photo, swipe up for the next dopamine hit, everything under ₹499.&lt;/p&gt;

&lt;p&gt;And because a feed is boring if it's the same for everyone, it needed a recommender system. The catch: this is a static site on GitHub Pages. No servers. So the recommender had to live entirely in the browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Products as vectors
&lt;/h2&gt;

&lt;p&gt;Every product gets embedded as a 13-dimensional feature vector — no ML libraries, just an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// [0..7] category one-hot (snacks, beauty, gadgets, home, ...)&lt;/span&gt;
&lt;span class="c1"&gt;// [8..10] price bucket one-hot (low ≤150, mid 151–300, high &amp;gt;300)&lt;/span&gt;
&lt;span class="c1"&gt;// [11] deal flag&lt;/span&gt;
&lt;span class="c1"&gt;// [12] highly-rated flag (≥4.5)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;vecOf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;CATS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rating&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mf"&gt;4.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The taste profile
&lt;/h2&gt;

&lt;p&gt;The user's taste is a weighted running sum of the vectors they engage with, persisted in &lt;code&gt;localStorage&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;Weight&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Purchase&lt;/td&gt;
&lt;td&gt;+10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add to cart&lt;/td&gt;
&lt;td&gt;+8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wishlist&lt;/td&gt;
&lt;td&gt;+5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Share&lt;/td&gt;
&lt;td&gt;+4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dwell &amp;gt; 4s on a card&lt;/td&gt;
&lt;td&gt;+2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flick past in &amp;lt; 1.2s&lt;/td&gt;
&lt;td&gt;−1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Un-wishlist&lt;/td&gt;
&lt;td&gt;−3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Dwell time comes from an &lt;code&gt;IntersectionObserver&lt;/code&gt; on the snap-scroll feed — if you pause on a card, that's a signal; if you flick past it instantly, that's a signal too. Every new session decays the profile by 0.85, so recent taste dominates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ranking = cosine similarity + deliberate randomness
&lt;/h2&gt;

&lt;p&gt;On each visit, every product is scored:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cosine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;profile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;vecOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;          &lt;span class="c1"&gt;// jitter&lt;/span&gt;
      &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seenCount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.06&lt;/span&gt; &lt;span class="c1"&gt;// fatigue penalty&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the feed interleaves: two "exploit" cards (best matches, badged ✨ For you) for every one "explore" card (random from the long tail, badged 🎲 Fresh find). Pure exploitation makes an echo chamber; the exploration slots keep the feed a discovery machine.&lt;/p&gt;

&lt;p&gt;Cold start (fewer than 3 signals) falls back to a hand-curated launch order.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fun parts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Guilt-free meter:&lt;/strong&gt; the cart judges you. Under ₹300 → "Totally fine 😌". Over ₹700 → "Okay big spender 👀". This is everyone's favorite feature.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1000+ SKUs from ~115 templates:&lt;/strong&gt; products expand into variants (flavour × size × colour) exactly like real q-commerce catalogs — the feed dedupes to one hero card per product, and a bottom sheet handles variant picking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance:&lt;/strong&gt; the feed renders in batches of 30 and images load in a ±2-card window around the viewport — a cold visitor downloads 3 images, not 45.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;scroll-snap-type: y mandatory&lt;/code&gt; + one &lt;code&gt;100dvh&lt;/code&gt; card per product gets you TikTok-feel scrolling with zero JS scroll handlers.&lt;/li&gt;
&lt;li&gt;An &lt;code&gt;IntersectionObserver&lt;/code&gt; is a shockingly good implicit-feedback sensor.&lt;/li&gt;
&lt;li&gt;A recommender doesn't need a GPU or even a server. For a catalog of ~1000 items, cosine similarity over 13-dim vectors runs in microseconds on a phone.&lt;/li&gt;
&lt;li&gt;localStorage as a "user model" is genuinely private-by-design — the taste profile never leaves the device.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Demo: &lt;a href="https://thodasa.com" rel="noopener noreferrer"&gt;thodasa.com&lt;/a&gt; (free, no login — it's a concept demo, nothing real is sold)&lt;/li&gt;
&lt;li&gt;Code: &lt;a href="https://github.com/Bhaumik-Tandan/thodasa" rel="noopener noreferrer"&gt;github.com/Bhaumik-Tandan/thodasa&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scroll a few beauty products and reload — watch the feed rearrange itself. Then check the "Your vibe" widget in the wishlist to see what it learned about you.&lt;/p&gt;

&lt;p&gt;Roast the code, star the repo, or tell me what you'd impulse-buy under ₹499.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>sideprojectscomma</category>
    </item>
  </channel>
</rss>
