Electronics Catalog (local)
A local catalogue of real electronics products sold in India, with a Tamil Nadu focus:
the products, their prices, images and the e-commerce platforms that list them. It is a
converted copy of Project_Deploy, which stays untouched. It runs only on this machine
and is not pushed anywhere.
How data is collected (search-first)
- Discover:
- Web search runs
site:<platform> <brand> <variant terms>on every registered platform. Providers are asked in order until one answers: a self-hosted SearXNG (whenSEARXNG_URLis set), DuckDuckGo (ddgs), then Google Programmable Search (when a key is set). Only single-product URLs are kept. - Readable (grade A/B) sites are also listed from their own sitemaps (named in robots.txt). A sitemap URL is read only when its slug names the brand and a full variant, and it is stored only if the page itself confirms that model. Sitemap URL lists are cached for 72 hours.
- Web search runs
- Gate each platform (
probe), grading it A, B or C:- A: robots.txt allows the page, it returns HTTP 200 with no bot check, and it carries schema.org Product JSON-LD with an INR price. The product page is read.
- B: fetchable, but only the page HTML/meta is readable.
- C: blocked, CAPTCHA, robots.txt disallows, or no data without JavaScript. Web search results only, with nothing fetched from the site.
- Amazon.in and Flipkart are
serp_onlyby policy and are never fetched directly.
- Collect:
- A/B pages are read politely: robots.txt obeyed, an honest User-Agent, 3 s between requests to a site, and a circuit breaker on any 403/429/CAPTCHA.
- C platforms contribute what their search result shows: the title (with variant) and URL, plus a price or stock status only when the snippet or the search engine's own structured data states it.
- Match each listing to one canonical variant (brand + model + RAM + storage; MPN for laptops). A different model number is never merged. Uncertain matches go to a review queue.
- Verify: a product is shown only when listings on at least two platforms (at least one a retailer) confirm it.
Anti-fabrication rules:
- Every listing and price row stores its source URL and the text the value was read from.
- Prices come only from parsers, never from the LLM. EMI, "₹X off", exchange and bank-offer amounts are rejected.
- The local LLM (qwen2.5:1.5b) only fills missing spec fields from fetched text. Every value it returns must appear in that text, or it is dropped.
- Images come only from a product's own listings and are checked live. Only URLs are stored.
- Unknown stays unknown:
in_stockis NULL and the price is "not stated". pincode_appliedis true only if a site actually accepted the pincode. Currently none does, so prices are national listing prices.
Platforms
| Platform | Region | Mode (as probed on 29 Sep 2026) |
|---|---|---|
| Amazon.in, Flipkart | national | C: search only (policy) |
| Croma | national | C: blocked (HTTP 403), search only |
| Tata CLiQ | national | C: bot-check page, search only |
| Reliance Digital, Vijay Sales | national | A: product pages read |
| Poorvika, Vasanth & Co | Tamil Nadu | A: product pages read |
| Sangeetha Mobiles | Tamil Nadu | C: no data without JavaScript, search only |
| Viveks | Tamil Nadu | C: few product pages indexed |
| Brand official sites | - | probed per brand |
Grades are re-checked every 7 days (probe). A tripped breaker pauses a site for 24 h.
Setup (once)
# 1. Local database (container elec_catalog_pg, 127.0.0.1:5433, DB electronics_catalog)
copy .env.example .env # set POSTGRES_PASSWORD
docker compose up -d
# 2. Backend
cd backend
copy .env.example .env # same DB_PASSWORD; set ELEC_CONTACT to a real email
py -3.13 -m venv .venv
.venv\Scripts\pip install torch --index-url https://download.pytorch.org/whl/cpu
.venv\Scripts\pip install -r requirements.txt -r requirements-dev.txt
.venv\Scripts\python -m app.electronics.cli migrate
.venv\Scripts\python -m app.electronics.cli seed-reference
# 3. Frontend
cd ..\frontend
npm install
Optional: SearXNG search (more reliable discovery when DuckDuckGo throttles). Set
SEARXNG_SECRET in the root .env to a long random string, then:
docker compose --profile search up -d # container elec_catalog_searxng on 127.0.0.1:8888
and set SEARXNG_URL=http://127.0.0.1:8888 in backend/.env.
Run
start_app.bat # database + API (127.0.0.1:8000) + UI (http://localhost:5173)
AUTH_ALLOW_ANY_LOGIN=true in backend/.env accepts any password for user admin. That
is fine locally because the API binds to 127.0.0.1.
Collect data (CLI, from backend/)
.venv\Scripts\python -m app.electronics.cli probe # grade platforms A/B/C
.venv\Scripts\python -m app.electronics.cli collect --category mobiles --brand samsung --brand xiaomi --limit 10
.venv\Scripts\python -m app.electronics.cli collect --category laptops --brand hp --brand lenovo --limit 10
.venv\Scripts\python -m app.electronics.cli seed-reference # after brands.yaml changes
.venv\Scripts\python -m app.electronics.cli collect --category washing-machines --brand lg --brand samsung --limit 5
.venv\Scripts\python -m app.electronics.cli report # what is in the catalogue
.venv\Scripts\python -m app.electronics.cli review # uncertain matches
.venv\Scripts\python -m app.electronics.cli verify-grounding # audit: every price has evidence
Home-appliance categories (identified by model code + capacity, see backend/app/electronics/normalise/appliance_parser.py): televisions, refrigerators, washing-machines, air-conditioners, inverters, wet-grinders, mixer-grinders, microwave-ovens, water-purifiers, air-coolers, water-heaters. Brands per category are in backend/app/electronics/reference/brands.yaml.
Useful flags:
--no-fetch: search results only.--no-llm: fully deterministic.--budget N: cap on search queries.--reprobe: re-grade the sites.--no-sitemaps: find pages through web search only.--sitemap-pages N: new product pages read from each site's sitemap, per brand (default 10).
The same run can be started from the Admin page.
Prices for Amazon, Flipkart and Croma. Free search snippets almost never show a price
for these platforms, so their listings usually record availability only. To get their
prices without ever fetching them, set GOOGLE_API_KEY and GOOGLE_CSE_ID in
backend/.env (Google Programmable Search, 100 free queries a day). The Google Cloud
project behind the key must have the Custom Search API enabled. Then run:
.venv\Scripts\python -m app.electronics.cli prices --limit 40
- Google queries are kept for this price pass. Discovery asks SearXNG and DuckDuckGo first and falls back to Google only when neither gives an answer.
- A price is taken only from Google's structured offer data for the same product page (same site product ID), and it is stored with that data as evidence.
- A rejected key switches Google off for the rest of the run and reports why.
Ratings and reviews refresh. Re-reads every readable product page for its rating, star breakdown and reviews (and finds brand-store pages that publish reviews). Run it weekly, for example with Windows Task Scheduler or cron:
.venv\Scripts\python -m app.electronics.cli reviews
Amazon.in and Flipkart data (Bright Data, paid per record). Our own crawler never
reads these two sites, so their ratings come from Bright Data's scrapers
(docs/BRIGHTDATA_PLAN.md). Flipkart runs also keep images and the
specs its phone descriptions state (§14). Set BRIGHTDATA_API_KEY and
USE_BRIGHTDATA=true in backend/.env. Each run fetches only unrated listings unless you
pass --refresh, and stops at BRIGHTDATA_MONTHLY_CREDIT_CAP (default 4,500). The cap is
counted from elec.crawl_run (kind brightdata). Run it once a month:
.venv\Scripts\python -m app.electronics.cli reviews --provider brightdata --dry-run # targets + cost, spends nothing
.venv\Scripts\python -m app.electronics.cli reviews --provider brightdata --site flipkart
.venv\Scripts\python -m app.electronics.cli reviews --provider brightdata --site flipkart --reviews-only # 20 reviews/product
.venv\Scripts\python -m app.electronics.cli reviews --provider brightdata --site flipkart --refresh # re-read rated listings for details: 1 credit each
Each product page shows up to 5 real reviews. A product rated 4 or higher gets 3 positive and 2 neutral. A lower-rated product gets 3 neutral and 2 negative (BRIGHTDATA_PLAN.md §13).
Tests
cd backend
.venv\Scripts\python -m pytest -q
The tests need no network and never touch real data. The database tests use a separate
electronics_catalog_test database on the same local server, and they are skipped if the
container is down.
Layout
docker-compose.yml local Postgres + pgvector only
backend/app/electronics/
reference/*.yaml brand allow-list + aliases, platforms, spec dictionary
db/migrations/*.sql schema `elec` (tables + views), applied by `cli migrate`
net/ polite HTTP client, circuit breaker
search/ DuckDuckGo / Google CSE providers, cache + budget
probe/ A/B/C platform grading
extract/ JSON-LD, HTML meta/spec tables, search-snippet prices
normalise/ brand aliases, title parser, spec units, grounding, LLM gap-fill
match/ listing -> canonical variant
collector.py the pipeline
cli.py command line
backend/app/api/routers/elec*.py read API + admin API
frontend/src catalogue UI (category -> brand -> product -> platforms)