How kushagra-garg-27/cartlens works
Purpose and entry points
SmartCompare Pro compares Indian e-commerce prices, records price history, and supports watchlists, alerts, ranking, and AI recommendations. Its primary consumer is a Manifest V3 Chrome extension; a separate React web app exposes similar product/deal workflows.
• Extension runtime: extension/manifest.json, extension/content.js, extension/background.js
• Backend API/bootstrap: backend/src/index.js, backend/src/server.ts
• Web app bootstrap: web-app/src/main.tsx, web-app/src/App.tsx
Client capture and API boundary
The extension injects into supported product pages, extracts product details locally, and communicates with the backend REST API using JWT authentication. The background script coordinates extension-side work, while popup/panel UI renders comparison results.
• extension/content.js
• extension/background.js
• backend/src/routes/auth.routes.js, backend/src/middleware/auth.middleware.js
The React application is a separate API client with authenticated routes and product/search/watchlist views.
• web-app/src/services/api/apiClient.ts
• web-app/src/contexts/AuthContext.tsx
• web-app/src/pages/Product.tsx
API orchestration and product workflows
Express routes organize externally visible workflows: product observation/search, cross-store comparison, price history, deals, notifications, chat, and user watchlists. Route handlers delegate to services rather than directly implementing scraping or persistence.
• backend/src/routes/compare.routes.js
• backend/src/routes/observe.routes.js
• backend/src/routes/watchlist.routes.js
Important control flow: observed or requested product input is resolved/normalized, listings are fetched or queued for scraping, prices and offers are assembled into a comparison response, then persisted for history and downstream alerts.
• backend/src/services/product.resolver.js
• backend/src/services/response.assembler.js
• backend/src/services/job.enqueuer.js
Scraping and platform integration layer
Platform-specific scrapers cover the supported Indian retailers. A runner dispatches scraper work; Playwright-based infrastructure handles browser-resistant sites, with parsing/utilities separating common mechanics from retailer implementations.
• backend/src/scrapers/scraper.runner.js
• backend/src/scrapers/playwright.base.js
• backend/src/scrapers/index.ts
Representative platform implementations include backend/src/scrapers/amazon.scraper.js, backend/src/scrapers/flipkart.scraper.js, and backend/src/scrapers/croma.scraper.js. This is the principal boundary to volatile third-party retailer pages; scraper output must be normalized before becoming canonical product/listing data.
Product matching, prices, and decision intelligence
Canonicalization and matching protect against cross-store title and variant differences. Services extract price/offers, aggregate listings, compute analytics, compare specifications, and rank platforms based on user affinity. Deal detection and AI enrichment produce higher-level recommendations.
• backend/src/services/productNormalizer.ts
• backend/src/services/priceAggregator.ts
• backend/src/services/ranker.service.js
• backend/src/services/deal.detector.js
• backend/src/services/spec.comparator.js
• backend/src/services/aiIntelligence.ts
Persistence, jobs, and lifecycle automation
PostgreSQL is the system of record for products, listings, price history, scrape jobs, watchlists, platform affinity, and platform health. Schema/migrations define the durable model; database access is centralized behind DB/store modules.
• backend/src/db/schema.ts
• backend/src/db/pool.ts
• backend/migrations/001_initial_schema.sql
Scheduled jobs refresh watched products, detect stale data, clean up records, and pre-alert on sales. Alert delivery is handled through the alert service and Resend email integration.
• backend/src/cron/watchlist.cron.js
• backend/src/cron/stale.cron.js
• backend/src/services/alert.service.js
Runtime and infrastructure
The backend is Node.js/Express with Playwright/Cheerio scraping, JWT auth, PostgreSQL (documented Neon deployment), Gemini 2.5 Flash AI, and optional Resend email. Docker provisions the backend/database local stack; deployment is documented for Render.
• backend/Dockerfile
• docker-compose.yml
• backend/src/config.js
Main entry points: schema.ts PostgreSQL · compare.routes.js Product workflow routes · job.enqueuer.js Scrape job queueing · watchlist.cron.js Lifecycle schedulers
Components 18
Client runtimes
- Chrome extension · Captures supported retailer product pages and renders comparisons.
extension/manifest.json - Product page capture
extension/content.js - Extension coordinator
extension/background.js - React web app · Authenticated product, search, and watchlist UI.
web-app/src/App.tsx - Web API client
web-app/src/services/api/apiClient.ts
Backend API
- Express backend · REST API bootstrap and application host.
backend/src/server.ts - JWT authentication
backend/src/middleware/auth.middleware.js - Product workflow routes · Comparison, observation, and watchlist endpoints.
backend/src/routes/compare.routes.js
Product intelligence pipeline
- Product resolver · Resolves observed or requested products into scrapeable listings.
backend/src/services/product.resolver.js - Scrape job queueing
backend/src/services/job.enqueuer.js - Scraper runner · Dispatches retailer-specific scraping work.
backend/src/scrapers/scraper.runner.js - Retailer scrapers · Amazon, Flipkart, Croma, and other volatile retailer integrations.
backend/src/scrapers/index.ts - Canonical matching · Normalizes titles and variants across stores.
backend/src/services/productNormalizer.ts - Price and decision intelligence · Aggregates prices and offers; ranks, detects deals, compares specs, and enriches recommendations.
backend/src/services/priceAggregator.ts - Comparison response
backend/src/services/response.assembler.js
Data and automation
- PostgreSQL · Stores products, listings, history, jobs, watchlists, affinity, and platform health.
backend/src/db/schema.ts - Lifecycle schedulers · Refreshes watches, detects stale data, cleans records, and prepares sale alerts.
backend/src/cron/watchlist.cron.js - Alert delivery · Delivers watchlist and sale alerts through email integration.
backend/src/services/alert.service.js
Connections 23
- Chrome extension → Product page capture: injects
- Product page capture → Extension coordinator: product observations
- Extension coordinator → Express backend: authenticated REST
- React web app → Web API client: uses
- Web API client → Express backend: authenticated REST
- Express backend → JWT authentication: protects routes
- JWT authentication → Product workflow routes: authorizes
- Product workflow routes → Product resolver: resolves requests
- Product resolver → Scrape job queueing: queues missing data
- Scrape job queueing → Scraper runner: scrape jobs
- Scraper runner → Retailer scrapers: dispatches
- Retailer scrapers → Canonical matching: raw listings
- Canonical matching → Price and decision intelligence: canonical listings
- Price and decision intelligence → Comparison response: prices, offers, rankings
- Comparison response → Product workflow routes: comparison payload
- Canonical matching → PostgreSQL: products and listings
- Price and decision intelligence → PostgreSQL: price history and insights
- Scrape job queueing → PostgreSQL: job state
- Product workflow routes → PostgreSQL: watchlists and user data
- Lifecycle schedulers → PostgreSQL: reads watched and stale records
- Lifecycle schedulers → Scrape job queueing: refreshes products
- Lifecycle schedulers → Alert delivery: triggers notifications
- Alert delivery → PostgreSQL: uses watch and price state