Skip to content

Feature: Real-Time Stock Updates using WebSockets #178

Description

@Aamod-Dev

Description
Right now, if two users are looking at the same product and one buys the last item, the other user's screen will still show "In Stock" until they manually refresh the page.

Your task is to implement WebSockets (Socket.io) to push real-time stock updates to all connected clients.

Requirements

  1. Backend: Set up Socket.io alongside our Express server.
  2. Backend: Whenever a product's stock is updated (e.g., through a purchase or admin edit), emit a stockUpdate event containing the productId and newStock.
  3. Frontend: Connect to the WebSocket on the ProductPage and ProductCard components.
  4. Frontend: Listen for stockUpdate events and dynamically update the UI (e.g., changing from "In Stock" to "Out of Stock" instantly without a refresh).

Metadata

Metadata

Assignees

Labels

HardSSoC26backendFor changes related to the Express server, API routes, or MongoDB modelsenhancementNew feature or requestfrontendFor any changes in the React UI, components, or Vite setup

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions