Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDIT: ON HOLD AS PER DISCUSSION: Implement Chat Functionality between Users and Sellers #517

Closed
ShivanshPlays opened this issue Nov 7, 2024 · 1 comment
Labels
gssoc-ext GirlScript Summer of Code Extended 2024 hacktoberfest-accepted Hacktoberfest

Comments

@ShivanshPlays
Copy link
Contributor

Implement Chat Functionality between Users and Sellers

Overview

This feature will allow users and sellers to chat with each other in real-time, enabling discussions related to listings, prices, availability, and other details. The implementation will involve building a real-time chat interface, storing chat data, and ensuring users and sellers can communicate within their respective roles.


Phase 1: Backend Setup

Objective:

  • Set up database models for storing chat data.
  • Create API routes for sending, receiving, and fetching messages.
  • Integrate real-time communication using WebSocket or a similar service (e.g., Socket.io, Pusher).

Tasks:

  • Create Chat Model in Prisma:

    • Define models for Chat, Message, and UserChat.
    • A Chat will have references to the userId (buyer) and sellerId (vendor), and each chat will have multiple messages.
  • API Routes:

    • Create routes to send a message.
    • Create routes to fetch messages of a specific chat between a user and a seller.
  • WebSocket Setup:

    • Set up a WebSocket server or integrate a third-party service like Socket.io for real-time messaging.
    • Allow real-time message updates when one user sends a message.

Expected Outcome:

  • Database schema updated with necessary tables/relations.
  • Working API routes for chat functionality.
  • Real-time chat message delivery is set up between users and sellers.

Phase 2: Frontend Chat Interface

Objective:

  • Build the frontend for the chat interface.
  • Display messages between users and sellers in real time.
  • Design chat components for mobile and desktop views.

Tasks:

  • Chat UI:

    • Build a message list UI that displays messages from both users and sellers.
    • Design a message input field where users can type and send messages.
    • Add a submit button for sending messages.
  • Real-Time Updates:

    • Implement real-time updates using WebSocket (or similar) for receiving new messages.
    • Ensure that new messages appear in the chat window without needing a page refresh.
  • Responsive Design:

    • Make sure the chat interface is responsive and works on both mobile and desktop versions.

Expected Outcome:

  • A fully functioning chat interface.
  • Real-time message sending and receiving.
  • A user-friendly design for both users and sellers.

Phase 3: User Authentication and Permissions

Objective:

  • Ensure that only the appropriate user (either a seller or buyer) can access the correct chat.
  • Secure the chat route so users and sellers can only access their conversations.

Tasks:

  • User Authentication:

    • Ensure that users are authenticated before accessing any chat.
  • Authorization:

    • Check that users can only view their respective chats with sellers and vice versa.
    • Prevent unauthorized users from accessing someone else's chat.

Expected Outcome:

  • Secure chat functionality that restricts access to the right users only.

Phase 4: Notifications & Alerts

Objective:

  • Add notifications or alerts to notify users when they receive new messages.
  • Provide visual cues for unread messages.

Tasks:

  • Message Notification:

    • Implement notifications (using browser notifications, or in-app popups) when a new message is received.
  • Unread Message Indicators:

    • Show visual indicators (e.g., an unread message count or bold text) to highlight unread messages.

Expected Outcome:

  • Real-time notifications for new messages.
  • Clear indication of unread messages.

Phase 5: Testing & Bug Fixing

Objective:

  • Test the entire chat functionality and fix any bugs.
  • Ensure smooth communication and that messages are delivered correctly.

Tasks:

  • Unit Testing:

    • Write unit tests for backend routes (sending, receiving, and fetching messages).
  • UI Testing:

    • Test the frontend chat interface for bugs (UI inconsistencies, broken WebSocket connections).
  • Bug Fixes:

    • Address any bugs or issues that arise during testing.

Expected Outcome:

  • Stable and well-tested chat functionality.
  • No major bugs in the chat experience.

Acceptance Criteria:

  • Users and sellers can initiate a chat from a listing page.
  • Both parties can send and receive messages in real-time.
  • Chat data is stored correctly in the database, with proper relations.
  • Only authorized users can access their chat history.
  • A responsive, user-friendly chat interface that works on all devices.
  • Notifications or alerts for new messages.

Additional Information:

  • Tech Stack: Prisma (for database), Socket.io (for real-time communication), React (for frontend), TailwindCSS (for styling).
  • Backend: API routes built in Next.js, potentially using Next.js API routes or a separate Express server.
  • Frontend: React components for chat UI.
  • Testing: Use Jest for backend testing and React Testing Library for frontend.

Deliverables:

  • Database schema updated.
  • Working backend API routes for chat functionality.
  • Frontend chat interface.
  • Real-time message sending and receiving.
  • Notifications for new messages.
  • Testing and bug fixes.

PRs to Submit:

  1. PR 1: Backend Setup – Add database models, API routes, and WebSocket setup for real-time communication.
  2. PR 2: Frontend Chat Interface – Implement the chat UI and connect it with real-time updates.
  3. PR 3: User Authentication and Permissions – Secure chat functionality and add authorization logic.
  4. PR 4: Notifications & Alerts – Add message notifications and unread message indicators.
  5. PR 5: Testing & Bug Fixing – Write unit tests and fix bugs based on testing feedback.

Labels:

  • feature
  • backend
  • frontend
  • chat
  • real-time
  • enhancement
@github-actions github-actions bot added gssoc-ext GirlScript Summer of Code Extended 2024 hacktoberfest-accepted Hacktoberfest labels Nov 7, 2024
@ShivanshPlays ShivanshPlays changed the title Implement Chat Functionality between Users and Sellers EDIT: ON HOLD AS PER DISCUSSION: Implement Chat Functionality between Users and Sellers Nov 8, 2024
@ShivanshPlays
Copy link
Contributor Author

#532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc-ext GirlScript Summer of Code Extended 2024 hacktoberfest-accepted Hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant