This project is a Node.js server for price tracking, currently specific to the Flipkart website.
This project is tested and works with Node.js v22.12.0.
Endpoint | Method | Description | Request Body | Response |
---|---|---|---|---|
/auth/register |
POST | Register a new user | { "email": "user@example.com", "pass": "password123" } |
201 Created : User registered404 Not Found : User already exists |
/auth/login |
POST | Login an existing user | { "email": "user@example.com", "pass": "password123" } |
200 OK : User logged in404 Not Found : User not registered |
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 |
- 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.
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.
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 |
-
Clone the repository.
-
Install dependencies:
npm install
-
Create a
.env
file based on the.env.template
file. -
Compile TypeScript:
npm run serve