Skip to content

Simple Node.js server for price tracking, currently specific to the Flipkart website but extendible.

Notifications You must be signed in to change notification settings

studcroc/price-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Price Tracker

This project is a Node.js server for price tracking, currently specific to the Flipkart website.

Node.js Version

This project is tested and works with Node.js v22.12.0.

API Endpoints

Authentication Endpoints

Endpoint Method Description Request Body Response
/auth/register POST Register a new user { "email": "user@example.com", "pass": "password123" } 201 Created: User registered
404 Not Found: User already exists
/auth/login POST Login an existing user { "email": "user@example.com", "pass": "password123" } 200 OK: User logged in
404 Not Found: User not registered

Product Endpoints

Endpoint Method Description Headers Request Body Response
/products/ GET Get all products { "Authorization": "Bearer <JWT_TOKEN>" } None 200 OK: List of products
/products/ POST Add a new product { "Authorization": "Bearer <JWT_TOKEN>" } { "product_url": "https://www.flipkart.com/product-page" } 201 Created: Product added

Cron Job

  • A cron job runs every 2 minutes to scrape product prices and update the database. If the price drops below the minimum price, an email alert is sent to the user.

Environment Variables

The following environment variables are required for the project:

  • DATABASE_URL: Connection string for the PostgreSQL database.
  • JWT_SECRET: Secret key for JWT token generation.
  • MAIL_ID: Email address for sending alerts.
  • MAIL_PASS: Password for the email account.

Refer to the .env.template file for the structure.


Database Schema

Table Name Column Name Data Type Description
users id UUID Primary Key, unique identifier for each user
email VARCHAR Unique email address of the user
pass_hash VARCHAR Hashed password of the user
products id UUID Primary Key, unique identifier for each product
url TEXT URL of the product
initial_price FLOAT Initial price of the product
latest_price FLOAT Latest price of the product
min_price FLOAT Minimum price of the product
user_id UUID Foreign Key, references users.id
prices id UUID Primary Key, unique identifier for each entry
product_id UUID Foreign Key, references products.id
price FLOAT Price of the product at a specific time
created_at TIMESTAMP Timestamp when the price was recorded

Installation and Setup

  1. Clone the repository.

  2. Install dependencies:

    npm install
  3. Create a .env file based on the .env.template file.

  4. Compile TypeScript:

    npm run serve

About

Simple Node.js server for price tracking, currently specific to the Flipkart website but extendible.

Topics

Resources

Stars

Watchers

Forks