Skip to content

Implement real-time notifications with WebSocket#327

Open
fadee26 wants to merge 1 commit into
stemscreatives:mainfrom
fadee26:feature/real-time-notifications
Open

Implement real-time notifications with WebSocket#327
fadee26 wants to merge 1 commit into
stemscreatives:mainfrom
fadee26:feature/real-time-notifications

Conversation

@fadee26

@fadee26 fadee26 commented Jun 21, 2026

Copy link
Copy Markdown

Summary

This PR implements real-time notifications using WebSockets, allowing users to receive instant updates on critical events without refreshing the page.

Changes Made

Backend

  1. Database Model: Added Notification model to persist notifications (user_id, type, title, message, is_read, reference_id, created_at, updated_at)
  2. Schemas: Created Pydantic schemas for notification creation/response
  3. API Endpoints:
    • GET /notifications/ - Fetch user's notifications
    • GET /notifications/unread-count - Get unread notification count
    • PUT /notifications/{id}/read - Mark single notification as read
    • PUT /notifications/mark-all-read - Mark all notifications as read
    • DELETE /notifications/{id} - Delete notification
    • WS /notifications/ws - WebSocket endpoint for real-time updates
  4. WebSocket Manager: Added ConnectionManager to handle active WebSocket connections
  5. Notification Integration:
    • Added notifications on booking status changes (confirmed, canceled, started, completed)
    • Added notifications on payment release and refund

Frontend

  1. NotificationContext: Updated to use WebSocket instead of polling, and added toast alerts
  2. NotificationBell: Updated to handle clicking notifications (mark as read + navigate)
  3. Toast Provider: Already integrated to show real-time alerts

How to Test

  1. Run the backend and apply the migration
  2. Log in as both a client and an artisan (separate browsers)
  3. Create a booking as a client, then accept it as the artisan - both users should receive notifications
  4. Complete the booking and release payment - both users should receive notifications

Next Steps

  • Add more notification types (e.g., new bids, disputes)
  • Add notification preferences (users can choose which events to be notified about)
  • Add email/SMS notifications as fallback

closes #298

@fadee26

fadee26 commented Jun 21, 2026

Copy link
Copy Markdown
Author

@ohamamarachi474-del
@gabito1451
please approve workflow

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.

Real-Time In-App Notifications

1 participant