Database Source and Description:
We have used the Flipkart Product database from Kaggle. Flipkart is an Indian E-commerce company headquatered in Bengaluru, India. Source - https://www.kaggle.com/datasets/PromptCloudHQ/flipkart-products
The above dataset consists of 20000 products. We did the following operations on the database to get it ready for MongoDB project -
- Trim the database to have only 3000 products. (We selected first 3000 products)
- Add latitude and longitude values of the store locations in India. (To run the geospatial queries)
- The dataset had links to images, not the actual images. Hence, we wrote a python script to fetch and download those images.
- We numbered the images from 0 to 2999, with each image co-relating to every product. Further we added "product_number" to the CSV file where the products are numbered from 0 to 2999. This allows co-relation between products and the associated images.
- We also added a default images to display for products whose images are missing.
Technology Stack:
- MongoDB for Backend
- HTML, CSS, JavaScript
- Python (Flask Framework) - Rendered HTML templates with flask using Jinja.
Steps to run application:
- Run flipkart.py to start the server for web application.
- Open a browser to visit http://localhost:5000/ (This is the default Flask server)
Tech Stack Justification and Use:
Flask with HTML made frontend easier, this allowed us to focus on MongoDB queries for backend to complete the given tasks.
Folder Structure -
- flipkart.py - Web app server for searching flipkart products.
- templates -
- index.html
- search.html
- product_details.html
- UpdateLocationField.js - update location using latitude and longitude (lecture code)
To Create index - db.Products.createIndex({location: '2dsphere'}) Field to store user comments - db.Products.updateMany({}, { $set: { comment: [] } })
Note -
- We have kept the search limit to be 20. This can be increased if needed in flipkart.py
- Since the location is India, suggested values of latitude and longitude are of places in India eg, [73,16], [81,15], [94,36], etc The search area is 100000
- We have implemented regex to capture partial words in the description. for eg. 'cot' will show products whose description has word 'cotton' but not 'boycot' or 'boycott'.