| .idea | ||
| app | ||
| docs | ||
| price-compare-api | ||
| .gitignore | ||
| README.md | ||
| systemarhitecture.md | ||
Price Comparison PWA Implementation
This repository contains the implementation of a price comparison PWA with NestJS backend and PostgreSQL database, as outlined in the improvement plan.
Implementation Details
The implementation follows the structure outlined in the improvement plan, with the following components:
Backend (NestJS)
The backend is implemented using NestJS and includes the following modules:
-
Product Module
- API endpoints for products
- Search and filtering functionality
- CRUD operations
-
Price Module
- Price history tracking
- Price comparison functionality
- Discount calculations
-
Source Module
- Source metadata management
- Product listing by source
-
Scraper Module
- HTML parsing using cheerio
- Data transformation
- Scheduled scraping jobs
-
User Module
- Watchlist functionality
- Price drop notifications
Database (PostgreSQL)
The database schema includes the following models:
-
Product
- Basic product information
- Category and description
- Availability status
-
Price
- Regular and discounted prices
- Promotion information
- Historical price tracking
-
Source
- Data source information
- Last scraped timestamp
-
User
- User information
- Watchlist and notifications
-
WatchlistItem
- User-product relationship for watchlist
-
Notification
- Price drop notification configuration
API Endpoints
The API provides the following endpoints:
-
Products
GET /products- List all products with paginationGET /products/:id- Get product detailsGET /products/search- Search products by name/category
-
Prices
GET /prices/product/:id- Get all prices for a productGET /prices/compare/:ids- Compare prices for multiple productsGET /prices/history/:id- Get price history for a product
-
Sources
GET /sources- List all data sourcesGET /sources/:id- Get source detailsGET /sources/:id/products- Get products from a specific source
-
User Features
GET /users/:userId/watchlist- Get user's watchlistPOST /users/:userId/watchlist- Add product to watchlistDELETE /users/:userId/watchlist/:productId- Remove product from watchlistGET /users/:userId/notifications- Get user's notificationsPOST /users/:userId/notifications- Configure price drop notificationDELETE /users/:userId/notifications/:productId- Remove notification
Getting Started
- Clone the repository
- Install dependencies:
cd price-compare-api npm install cd ../app npm install - Set up the database:
cd price-compare-api npx prisma migrate dev - Start the backend:
cd price-compare-api npm run start:dev - Start the frontend:
cd app npm run dev
Next Steps
- Implement authentication and authorization
- Add more data sources
- Enhance the frontend with more features
- Implement push notifications for price drops
- Add analytics and reporting