<?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: WhatNotSell</title>
    <description>The latest articles on DEV Community by WhatNotSell (@whatnotsell).</description>
    <link>https://dev.to/whatnotsell</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%2F4146082%2F6003abfe-a845-4c51-8bbd-2ad719db6b22.png</url>
      <title>DEV Community: WhatNotSell</title>
      <link>https://dev.to/whatnotsell</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/whatnotsell"/>
    <language>en</language>
    <item>
      <title>We built a deal site that refuses to show fake discounts. Here's what broke along the way.</title>
      <dc:creator>WhatNotSell</dc:creator>
      <pubDate>Sun, 27 Sep 2026 23:27:38 +0000</pubDate>
      <link>https://dev.to/whatnotsell/we-built-a-deal-site-that-refuses-to-show-fake-discounts-heres-what-broke-along-the-way-b68</link>
      <guid>https://dev.to/whatnotsell/we-built-a-deal-site-that-refuses-to-show-fake-discounts-heres-what-broke-along-the-way-b68</guid>
      <description>&lt;p&gt;Most deal sites have the same problem: the discount is whatever the store says it is. "Was $299, now $149" gets published as 50% off, even when nobody ever paid $299.&lt;/p&gt;

&lt;p&gt;We built WhatNotSell to do one thing differently. We only show a discount when the store's real original price backs it up. No estimates, no "compare at" guesses, no inflated percentages. If a product has no real higher original price, it shows no discount at all.&lt;/p&gt;

&lt;p&gt;That rule sounds simple. Enforcing it across hundreds of thousands of product feed rows a day, from eight different sources, turned out to be the whole job. Here's how the system works and the mistakes that taught us the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Next.js 16&lt;/strong&gt; (App Router, Turbopack) on &lt;strong&gt;Vercel&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supabase&lt;/strong&gt; for Postgres and auth&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Actions&lt;/strong&gt; plus &lt;strong&gt;Vercel Cron&lt;/strong&gt; to run the imports&lt;/li&gt;
&lt;li&gt;Product feeds from affiliate networks (Awin, CJ, Impact, Rakuten and others), plus eBay and Amazon&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today that adds up to roughly 11,000 live items from 180+ stores, refreshed every day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule #1: one function decides every discount
&lt;/h2&gt;

&lt;p&gt;Every import route, no matter which network it reads from, has to run its discount through the same function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;honestDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;originalPrice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&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;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;originalPrice&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;originalPrice&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="k"&gt;return&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;round&lt;/span&gt;&lt;span class="p"&gt;(((&lt;/span&gt;&lt;span class="nx"&gt;originalPrice&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;originalPrice&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. No real higher original price means 0%, and a 0% item is treated as a plain catalog listing, not a deal.&lt;/p&gt;

&lt;p&gt;It sounds almost too basic to write about. But during a review we found that &lt;strong&gt;two of our own import routes weren't using it&lt;/strong&gt;. They were calculating a discount some other way, which meant we were doing exactly the thing the site exists to prevent. Nothing crashed. The numbers just looked plausible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; a rule that matters has to live in one function, and every new or changed code path has to be checked against it. "We have a helper for that" is not the same as "everything uses the helper."&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule #2: we replaced an AI classifier with boring rules
&lt;/h2&gt;

&lt;p&gt;Every product needs a category (Electronics, Home, Fashion and so on). Feeds are messy: some give you a category, some give you a merchant-specific taxonomy, some give you nothing but a title.&lt;/p&gt;

&lt;p&gt;Our first version sent uncertain products to an LLM to classify. It worked, but two things bothered us:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cost grew with volume.&lt;/strong&gt; More feeds meant more calls, every day, forever.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wrong answers were hard to fix.&lt;/strong&gt; When it filed a drill under "Home", there was no rule to correct. We could only hope it did better next time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once we understood the patterns, we replaced it with a deterministic pipeline. First match wins:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Merchant pin (a single-category store)&lt;/li&gt;
&lt;li&gt;Strong title keyword (unambiguous product names)&lt;/li&gt;
&lt;li&gt;The feed's own taxonomy&lt;/li&gt;
&lt;li&gt;Fetch context (the search the item came from)&lt;/li&gt;
&lt;li&gt;Weaker title keywords&lt;/li&gt;
&lt;li&gt;The merchant's default category&lt;/li&gt;
&lt;li&gt;Misc&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All the keywords, pins and categories live in database tables, not in code. There's no cache, so fixing a rule corrects every affected product on the next import. Classification now costs nothing to run, and when something is wrong we can see exactly which layer made the call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; an LLM is a great way to &lt;em&gt;discover&lt;/em&gt; the rules. For a repetitive, high-volume job, it's often better as the prototype than as the permanent solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule #3: scores are recomputed, never nudged
&lt;/h2&gt;

&lt;p&gt;Each deal gets a 0 to 100 score from the real discount, how much we trust the retailer, price history, and community votes. The one design decision we'd repeat: the score is a pure function, recomputed from scratch every time. Votes are stored separately and folded in on each recompute. Nothing ever does &lt;code&gt;score += 5&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That makes the score reproducible and debuggable. If a number looks off, we can recompute it from its inputs and see why.&lt;/p&gt;

&lt;h2&gt;
  
  
  The failures that taught us the most
&lt;/h2&gt;

&lt;p&gt;None of our worst bugs threw an error. They all failed silently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An import that vanished for two months.&lt;/strong&gt; Our Amazon import was accidentally dropped from the daily GitHub Actions schedule during an unrelated edit. Nothing failed, because nothing ran. Our monitoring checked for runs that went stale, but a job that's never started doesn't produce a stale run. We found it by noticing the Amazon section looked thin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Runs that never finished.&lt;/strong&gt; One feed request had no timeout. When the network hung, the import sat in a "running" state indefinitely. These piled up for about two months before we caught them. The fix was a timeout on every external fetch, plus an automatic close for any run stuck too long.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A green workflow hiding red endpoints.&lt;/strong&gt; Our GitHub Actions job calls about 30 endpoints in sequence. If one returned a 504, the workflow used to finish green anyway, so the only way to catch a failure was to read the log. Now any non-2xx response fails the run, and GitHub emails us.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two jobs fighting each other every day.&lt;/strong&gt; This one we found just this week. Our import classifies each product using the feed's own category data. A separate nightly job re-checks every product's category using only its title, so rule fixes spread without waiting for the next import. The problem: the nightly job had &lt;em&gt;less&lt;/em&gt; information than the import, so for about 280 products a day it replaced a correct category with a worse guess (laptops moved from "Computers &amp;amp; Laptops" to "Electronics", drills to "Home"). The next import fixed them, and the nightly job broke them again. Since the nightly job ran last, the wrong answer was what shipped.&lt;/p&gt;

&lt;p&gt;The fix was to make the classifier report &lt;em&gt;which layer&lt;/em&gt; produced its answer. The nightly job now only overrides a category when its answer comes from a layer that outranks the feed's own data. Daily changes dropped from about 280 to 17.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; for a data pipeline, "no errors" means very little. We now keep a run ledger for every import (what ran, how many rows, how many skipped and why) and alert on anything unusual: a source going quiet, a run stuck open, skip counts that jump. Most of our real bugs were found by reading those numbers, not by an exception.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the data says
&lt;/h2&gt;

&lt;p&gt;Because every discount on the site is backed by a real original price, the data is useful on its own. Across the 3,543 deals we had with verified discounts at the end of September, the average real discount was 36% and the median 33%. It varies a lot by category: laptops averaged just 17% off, electronics 27%, men's clothing 51% and fragrance 70%. Only 5% of genuine discounts reached 70% or more.&lt;/p&gt;

&lt;p&gt;That's the practical takeaway for shoppers: a "70% off" banner is far more likely to be measured against an inflated price than to be a real 70% drop. We keep a live version of these numbers in our &lt;a href="https://www.whatnotsell.com/deal-index" rel="noopener noreferrer"&gt;Deal Index&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you're building something similar
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Put your most important business rule in one function, and audit every code path against it.&lt;/li&gt;
&lt;li&gt;Use AI to learn the rules, then consider replacing it with the rules.&lt;/li&gt;
&lt;li&gt;Make derived values (scores, categories) pure functions of their inputs.&lt;/li&gt;
&lt;li&gt;Assume your pipeline fails silently. Monitor for &lt;em&gt;missing&lt;/em&gt; activity, not just errors.&lt;/li&gt;
&lt;li&gt;When two jobs write the same field, make sure the one with less information can't overrule the one with more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;WhatNotSell is live at &lt;a href="https://www.whatnotsell.com" rel="noopener noreferrer"&gt;whatnotsell.com&lt;/a&gt;. If you want to check whether a sale is real, there's a free &lt;a href="https://www.whatnotsell.com/discount-checker" rel="noopener noreferrer"&gt;Discount Checker&lt;/a&gt;. We're happy to answer questions about the pipeline in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>showdev</category>
      <category>nextjs</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
