How srikar-reddy-85/pupptracker works
Project type and purpose
• This is a monolithic Node.js backend service (“pupptracker”) that exposes a RESTful API to scrape product data from Amazon and Flipkart, let users search and select products to track, and send email notifications on price drops.
File structure
• Top-level files:
• server.js – entry point (Express server, routes, controller logic)
• package.json / package-lock.json – dependencies (Puppeteer, Express, nodemailer)
• data.txt – flat‐file storage for scraped product records
• selectedItems.json – flat‐file storage for user‐selected tracking entries
• Dockerfile / .dockerignore – containerization setup
• There is no separate “frontend” directory; this is purely a backend service.
README for architectural insights
• Uses Puppeteer (headless Chrome) to scrape
• Exposes REST endpoints for scraping, searching, selecting, checking price drops, listing/removing items
• Sends emails via Gmail SMTP
Main components
a. Client (HTTP consumer or Postman/browser)
b. Express API Layer (server.js)
– Route handlers: /api/scrape, /api/search, /api/select-products, /api/check-price, etc.
c. Scraper Service (Puppeteer + Chrome)
d. Data Store (flat files: data.txt for raw data; selectedItems.json for tracking data)
e. Notification Service (SMTP via nodemailer to Gmail)
f. External Targets
– Amazon website
– Flipkart website
Relationships and data flow
1. Client → HTTP POST /api/scrape → Express API → Scraper Module
2. Scraper → headless Chrome → fetch product pages → return JSON → store in data.txt
3. Client → HTTP POST /api/search → Express API → read data.txt → respond with filtered results
4. Client → HTTP POST /api/select-products → Express API → append to selectedItems.json
5. Client or scheduler → HTTP GET /api/check-price → Express API →
• Read selectedItems.json →
• For each item invoke Scraper → compare current price vs stored price →
• If price drop: Notification Service → Gmail SMTP → send email
6. Client → HTTP GET /api/selected-items or POST /api/remove-products → Express API → read/update selectedItems.json
Architectural patterns and principles
• Single-process monolithic service with clear module separation:
• Routing / Controllers
• Scraping (side‐effect module)
• Persistence (file‐system storage)
• Notifier (email dispatch)
• Stateless HTTP handlers; state persisted in files
• External‐facing REST API boundary
Technologies and frameworks
• Node.js + Express.js (HTTP server, routing)
• Puppeteer (headless Chrome)
• nodemailer (SMTP email)
• File system (data.txt, selectedItems.json)
• Docker (containerization)
• Blue for internal modules
• Green for storage
• Orange for external systems
• Capture:
• API endpoints and controllers
• Scraper & headless browser
• File storage
• Notification service
• External websites and SMTP endpoint