Project Overview
Relevant source files
The following files were used as context for generating this wiki page:
- README.md
- backend/app.js
- backend/controller/product.js
- backend/middleware/validator.js
- backend/package.json
- frontend/package.json
- frontend/src/components/Layout/Header.jsx
- frontend/src/components/Products/ProductDetails.jsx
- frontend/src/components/Shop/CreateProduct.jsx
- frontend/src/components/UserOrderDetails.jsx
- frontend/src/static/data.js
This project is a complete e-commerce platform that integrates an intelligent sentiment analysis feature for user-submitted product reviews. The system is designed to provide a full-featured online shopping experience for customers, along with powerful dashboard tools for sellers and administrators. The core innovation lies in its use of AI to analyze and understand customer feedback, enabling sellers and admins to gain deeper insights into the shopping experience and effectively improve product and service quality.
The platform supports multiple user roles (customer, seller, admin), comprehensive product and order management, secure payment integrations, and real-time communication. The sentiment analysis capability distinguishes it from standard e-commerce sites by transforming qualitative review data into actionable insights.
Sources: README.md
System Architecture
The project is architecturally divided into three distinct, independently running services: a backend API server, a frontend web application, and a dedicated real-time socket server for chat functionality. This separation of concerns allows for modular development, deployment, and scaling.
Sources: README.md:52-95
The diagram below illustrates the high-level architecture of the system.
Sources: README.md:52-95
Technology Stack
The project utilizes the MERN stack (MongoDB, Express.js, React, Node.js) at its core, supplemented by a variety of libraries and services to deliver its features.
Sources: README.md:97-142, backend/package.json, frontend/package.json
Backend
| Technology | Purpose |
|---|---|
| Node.js | JavaScript runtime environment |
| Express.js | Web application framework for Node.js |
| MongoDB (Mongoose) | Primary NoSQL database for users, products, orders, etc. |
| MySQL (Sequelize) | Relational database for specific features |
| JWT | User authentication and authorization |
| Cloudinary | Cloud-based image and video management |
| Stripe API | Payment processing for credit cards |
| OpenAI API | AI-powered sentiment analysis of reviews |
| Google Cloud Translate | Language translation for sentiment analysis |
| Socket.io | Enables real-time, bidirectional communication |
| Nodemailer | Email sending service (e.g., for account activation) |
| Bcrypt | Password hashing |
Sources: README.md:100-116, backend/package.json:15-40
Frontend
| Technology | Purpose |
|---|---|
| React | JavaScript library for building user interfaces |
| Redux Toolkit | State management for the application |
| React Router DOM | Client-side routing |
| TailwindCSS | Utility-first CSS framework for styling |
| Material-UI (MUI) | React UI component library |
| Chart.js | For rendering charts in dashboards |
| Stripe React | Stripe integration for React |
| PayPal React | PayPal integration for React |
| Socket.io-client | Client-side library for the real-time chat |
| Axios | Promise-based HTTP client for API requests |
| React Toastify | For displaying notifications |
Sources: README.md:118-137, frontend/package.json:5-42
Socket Server
| Technology | Purpose |
|---|---|
| Node.js | JavaScript runtime environment |
| Express.js | Web application framework |
| Socket.io | Core library for real-time communication |
Sources: README.md:139-142
Key Features
The platform is equipped with a comprehensive set of features catering to all user roles.
| Feature | Description |
|---|---|
| User Management | Handles registration, login, email activation, profile management, and role-based access control (Admin, Seller, User) using JWT. |
| Product Management | Allows sellers to create, edit, and delete products, manage inventory, and upload images via Cloudinary. |
| Order Management | Customers can place and track orders. Sellers and admins can manage order statuses (processing, shipped, delivered, etc.). |
| Payments | Secure payment processing is integrated using Stripe and PayPal. |
| Events & Coupons | Sellers can create promotional events and coupon codes to drive sales. |
| Real-time Chat | A dedicated Socket.io server facilitates live chat between customers and sellers. |
| Sentiment Analysis | Product reviews are automatically analyzed using OpenAI to determine sentiment, providing valuable feedback to sellers. |
| Admin Dashboard | A central dashboard for administrators to manage all users, sellers, products, orders, and withdrawal requests. |
| Seller Dashboard | A dashboard for sellers to manage their own products, orders, revenue, and request fund withdrawals. |
Sources: README.md:11-50
Backend System
The backend is a Node.js application built with Express.js, responsible for all business logic, data persistence, and serving the API.
API Routing and Middleware
API routes are modularized by feature and aggregated in app.js. The system employs several middleware layers to handle security, data parsing, and error handling for incoming requests.
Sources: backend/app.js
The following diagram shows the flow of a typical API request through the middleware stack.
Sources: backend/app.js:12-89
Key API routes are defined with the /api/v2/ prefix:
/api/v2/user/api/v2/shop/api/v2/product/api/v2/order/api/v2/payment/api/v2/conversation&/api/v2/message
Sources: backend/app.js:60-70
Input Validation
The backend uses express-validator to enforce validation rules on incoming request bodies, ensuring data integrity before it reaches the controllers. This prevents common errors and adds a layer of security.
Example validation rules for user registration:
name: Must not be empty, 2-50 characters, letters and spaces only.email: Must be a valid email format.password: Must be at least 8 characters and contain uppercase, lowercase, number, and special characters.
Sources: backend/middleware/validator.js:18-36
Sentiment Analysis on Reviews
A standout feature is the sentiment analysis performed on product reviews. When a user submits a review, the backend processes it to determine the sentiment.
The create-new-review endpoint in the product controller handles this process:
- A user submits a review (rating, comment) for a product they purchased.
- The backend receives the review data via a
PUTrequest to/api/v2/product/create-new-review. - The review is added to the product's
reviewsarray in the database. - The product's average
ratingsare recalculated. - When seller-specific products are fetched (
/get-all-products-shop/:id), the backend iterates through reviews and calls theanalyzeSentimentfunction on each comment, adding asentimentfield (e.g., "Positive", "Negative") to the review object before sending it to the frontend.
Sources: backend/controller/product.js:16-20, 100-128, 203-246, frontend/src/components/UserOrderDetails.jsx:29-48
Frontend System
The frontend is a single-page application built with React, providing a dynamic and responsive user experience.
Component-Based Architecture
The UI is built using a hierarchy of reusable React components. The structure is organized logically into directories for shared components (Layout), feature-specific components (Products, Shop), and page-level components (pages).
Header.jsx: Manages top-level navigation, search bar, and links to cart, wishlist, and user profile.Footer.jsx: Contains contact information, site links, and a newsletter subscription form.ProductCard.jsx: A reusable card to display a product summary in lists.ProductDetails.jsx: A detailed view of a single product, including images, description, reviews, and shop information.CreateProduct.jsx: A form for sellers to add new products to their shop.
Sources: README.md:69-83, frontend/src/components/Layout/Header.jsx, frontend/src/components/Shop/CreateProduct.jsx, frontend/src/components/Products/ProductDetails.jsx
State Management with Redux
Global application state is managed using Redux Toolkit. This provides a centralized store for data that needs to be accessed by multiple components, such as user authentication status, shopping cart contents, and wishlist items.
The diagram below shows how a component interacts with the Redux store to manage the wishlist.
Real-time Chat System
The application includes a real-time chat feature, allowing direct communication between customers and sellers. This is powered by a separate Node.js server using Socket.io.
The flow is as follows:
- A customer on a product page clicks "Send a message".
- The frontend (
ProductDetails.jsx) sends a request to the backend to create a new conversation if one doesn't exist. - The user is navigated to their inbox.
- The frontend establishes a WebSocket connection with the dedicated Socket Server.
- When a message is sent, the client emits a
sendMessageevent to the Socket Server. - The Socket Server receives the message and broadcasts it to the other user in the conversation.
Sources: README.md:40-44, frontend/src/components/Products/ProductDetails.jsx:62-74