Skip to content

feat: implement automated sentiment analysis for product reviews#329

Open
Mayuresh-1306 wants to merge 1 commit into
Nsanjayboruds:mainfrom
Mayuresh-1306:fix/admin-dashboard-ui
Open

feat: implement automated sentiment analysis for product reviews#329
Mayuresh-1306 wants to merge 1 commit into
Nsanjayboruds:mainfrom
Mayuresh-1306:fix/admin-dashboard-ui

Conversation

@Mayuresh-1306

Copy link
Copy Markdown

Description

Currently, product reviews rely solely on numerical star ratings. This PR introduces a lightweight, native sentiment analysis feature using the dependency-free sentiment npm package to help users visually filter feedback efficiently.

The text analysis is processed synchronously before hitting the database, assigning UI badges to reviews based on the actual context of the user's written feedback.

Changes Made

  • Database: Added sentimentScore (Number) and sentimentLabel (String: Positive/Neutral/Negative) to backend/model/reviewModel.js.
  • Backend Logic: Integrated the sentiment package into backend/controller/reviewController.js. It automatically calculates the text score upon review creation and updates existing reviews seamlessly.
  • UI Integration: Updated frontend/src/pages/ProductDetail.jsx to dynamically render styled "Helpful Positive" (green) and "Critical Review" (red) badges next to the stars for both the logged-in user's review and the general review feed.

Testing & Graceful Fallback

Due to a currently known bug in the local main branch preventing new user signups (Issue #311), UI screenshots could not be captured. However, the data flow has been architected to fail gracefully—if the sentiment score cannot be calculated for any reason, it simply defaults to 'Neutral' and does not interrupt the review submission pipeline.

@Mayuresh-1306

Copy link
Copy Markdown
Author

Hi @Nsanjayboruds! 👋

I've just submitted this PR for the automated sentiment analysis feature. I am actively participating in GirlScript Summer of Code (GSSoC) 2026. Could you please review this, add the gssoc and gssoc 26 labels, and assign this PR to me so it gets officially tracked for the program?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant