Skip to content
All work

Sconti Nova

Amazon deals, verified every hour. Built with a partner.

Open the live demo

Source available on request

The problem

Deal sites go stale fast: prices change, coupons expire and the same product shows up three times from three sources. Sconti Nova imports offers from a Telegram channel and from Amazon itself, checks every price against Amazon before it is shown, and keeps one card per real offer.

Status
Live, with an hourly catalogue cycle
Stack
Next.js 16, React 19, TypeScript, Tailwind 4, Supabase, PostgreSQL, Vercel Cron, Tiptap, Vitest, Playwright
Facts
75 test files, including database tests on PGlite
29 migrations
Accessibility checks with axe in end-to-end tests

Decisions worth explaining

Two sources can’t create the same offer twice

Telegram and Amazon both feed the catalogue. Before inserting, the lookup takes a transaction-level advisory lock on the product’s ASIN, so two imports running at the same moment can’t both decide the card is missing. The lock is in the save functions, so it also covers the hourly job.

Same product is not the same offer

Two offers are merged only when variant, Prime access, quantity, coupon, code, seller and purchase limits all match. A similar name proves nothing, and an unknown seller is never treated as equal to any seller.

The hourly job survives timeouts and duplicates

Each hour of work is a row with an owner, a lease and a fencing token. Every chunk runs inside a serverless request with a time budget, writes a checkpoint, and a stale worker whose fence has moved on can’t write at all. If the hour runs out, the summary says partial, never done.

A piece of the code

The lock is taken before the lookup, so the check and the insert can’t be split by another import.

supabase/migrations/…_verified_offer_deduplication.sql
-- Separate commands after the lock give the lookup a fresh Read Committed snapshot.
create function nova_catalog.find_verified_product(p_asin text,p_conditions jsonb,p_preferred_id uuid default null)
returns uuid language plpgsql volatile security invoker set search_path='' as $$
declare pid uuid;
begin
 if p_asin is null or p_asin !~ '^[A-Z0-9]{10}$' then return null; end if;
 perform pg_catalog.pg_advisory_xact_lock(pg_catalog.hashtextextended('sconti-nova:verified-offer:'||p_asin,0));
 -- An unknown seller is not evidence that two commercial offers are equal.
 if jsonb_typeof(p_conditions) is distinct from 'object' or nullif(p_conditions->>'merchantId','') is null then return null; end if;
 select p.id into pid from public.products p
 where p.verified_asin=p_asin and (p.catalog_source_offer_id is not null or p.catalog_discovery_id is not null)
  and nova_catalog.product_verified_conditions(p)=p_conditions
 order by (p.id=p_preferred_id) desc nulls last,p.created_at asc,p.id asc
 limit 1 for update of p;
 return pid;
end $$;
Next projectIter