Skip to content

vanshaj2023/Deals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PriceIQ - Price Tracking & Deal Alert System

Automated price tracking system with Telegram bot integration, email alerts, and trending products showcase.

๐Ÿš€ Features..

Core Features

  • ๐Ÿค– Telegram Bot Integration - Automatically scrapes product URLs shared in Telegram groups...
  • ๐Ÿ“Š Price Tracking - Monitors price changes for Amazon products
  • ๐Ÿ“ง Email Alerts - Notifies users when prices drop
  • โญ Trending Section - Promotes featured products from verified users
  • ๐Ÿ’ Wishlist - Save favorite products for quick access
  • ๐Ÿ”’ Authentication - Secure user authentication with Clerk.js

Technical Features

  • โšก Next.js 14 with App Router
  • ๐Ÿ—„๏ธ MongoDB for all data storage (users, products, wishlist)
  • ๐Ÿ” BrightData web scraping with proxy support
  • ๐Ÿ“ฎ Nodemailer email notifications
  • ๐Ÿ”„ Automated cron jobs for price updates
  • ๐ŸŽจ Tailwind CSS for styling

๐Ÿ“ฆ Tech Stack

  • Frontend: Next.js 14, React, TypeScript, Tailwind CSS
  • Backend: Next.js API Routes
  • Database: MongoDB (via Mongoose)
  • Authentication: Clerk.js
  • Web Scraping: Cheerio + Axios with BrightData proxies
  • Bot: Telegram Bot API
  • Email: Nodemailer

๐Ÿ—„๏ธ Database Structure

MongoDB Collections

Users

  • Stores user information and roles
  • Supports authentication

Products

  • Product details with price history
  • Tracking subscribers
  • Promotion status for trending section

Wishlist

  • Links users to their favorite products

View detailed schema โ†’

๐Ÿ› ๏ธ Setup

Prerequisites

  • Node.js 18+ installed
  • MongoDB database (local or Atlas)
  • Telegram Bot Token
  • BrightData account (for web scraping)
  • Email account for notifications

Installation

  1. Clone the repository
git clone <repository-url>
cd Deals-1
  1. Install dependencies
npm install
  1. Configure environment variables

Create a .env file:

# MongoDB
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/database

# Telegram Bot
BOT_TOKEN=your_telegram_bot_token

# Web Scraper (BrightData)
BRIGHT_DATA_USERNAME=your_username
BRIGHT_DATA_PASSWORD=your_password

# Email
EMAIL_PASSWORD=your_email_app_password

# Authentication (Clerk)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_key
CLERK_SECRET_KEY=your_clerk_secret
  1. Verify migration (optional)
npx ts-node verify-migration.ts
  1. Run development server
npm run dev
  1. Run Telegram bot (separate terminal)
npm run start-bot

๐Ÿ“‹ Usage

For Users

  1. Track a Product

    • Share Amazon product URL in Telegram group
    • Or manually add via web interface
  2. Set Price Alerts

    • Click "Track" on any product
    • Enter email to receive alerts
    • Get notified when price drops
  3. Browse Trending

    • View promoted products from verified sellers
    • Add to wishlist
    • Quick access to deals

For Promoters

  1. Add Promoted Product
POST /api/trending
  1. View Your Products
GET /api/trending?email=your@email.com

๐Ÿ”„ How It Works

Telegram Bot โ†’ Detects URL โ†’ Scrapes Product โ†’ Saves to MongoDB
                                    โ†“
                          Updates Price History
                                    โ†“
                            Checks Price Drop
                                    โ†“
                         Sends Email Alerts

Automated Price Updates

A cron job runs periodically to:

  1. Fetch all tracked products
  2. Re-scrape current prices
  3. Update price history
  4. Send alerts if prices dropped
// Triggered via /api/cron
GET /api/cron  // Scheduled via external service

๐Ÿ“ Project Structure

โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ (auth)/          # Auth pages (sign-in, sign-up)
โ”‚   โ”œโ”€โ”€ (route)/         # Protected routes
โ”‚   โ”œโ”€โ”€ api/             # API endpoints
โ”‚   โ””โ”€โ”€ products/        # Product detail pages
โ”œโ”€โ”€ components/          # React components
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ models/          # MongoDB models
โ”‚   โ”œโ”€โ”€ actions/         # Server actions
โ”‚   โ”œโ”€โ”€ scraper/         # Web scraping logic
โ”‚   โ””โ”€โ”€ nodemailer/      # Email templates
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ bot.ts           # Telegram bot
โ””โ”€โ”€ types/               # TypeScript types

๐Ÿ”ง API Endpoints

Products

  • POST /api/trending - Add promoted product
  • GET /api/trending - Get trending products
  • GET /api/trending?email=x - Get user's promoted products

Wishlist

  • POST /api/wishlist - Add to wishlist
  • GET /api/wishlist?userId=email - Get user wishlist
  • DELETE /api/wishlist?useremail=x&productId=y - Remove from wishlist

Users

  • POST /api/user - Create/get user
  • GET /api/user?email=x - Get user by email

Cron

  • GET /api/cron - Update all product prices

๐Ÿ“š Documentation

๐Ÿ› Known Issues

  • Scraper only supports Amazon currently
  • Email sender is hardcoded (needs env variable)
  • Rate limiting not implemented

๐Ÿ”ฎ Future Enhancements

Planned Features

  • Migrate to NextAuth (replace Clerk)
  • Support multiple e-commerce sites
  • User dashboard with analytics
  • Price prediction ML model
  • Browser extension
  • Mobile app with push notifications
  • Admin panel for promoters
  • Email queue system

Improvements

  • Add Redis caching
  • Implement rate limiting
  • Better error handling
  • Comprehensive test coverage
  • Performance optimization

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License.

๐Ÿ‘จโ€๐Ÿ’ป Author

Vanshaj

๐Ÿ™ Acknowledgments

  • BrightData for web scraping infrastructure
  • MongoDB for database solution
  • Clerk for authentication
  • Next.js team for the amazing framework

Made with โค๏ธ for deal hunters and smart shoppers!

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors