Skip to content

Real-time Activity Feed and In-App Notifications #131

Description

@Benjtalkshow

Feature: Real-Time Notifications with GraphQL Subscriptions

Overview

To improve user engagement and responsiveness, we should implement a real-time notification system using GraphQL Subscriptions (graphql-ws). This will allow users to receive instant updates when:

  • Their application is reviewed
  • A new bounty is posted

Goals

  • Enable real-time updates via GraphQL Subscriptions
  • Notify users of important events (applications, new bounties)
  • Provide a centralized notification UI
  • Improve overall user experience and engagement

Implementation Details

1. Define GraphQL Subscriptions

Modify: lib/graphql/subscriptions.ts

  • Add subscription definitions:
    • ON_BOUNTY_UPDATED (e.g., application reviewed, bounty status changes)
    • ON_NEW_APPLICATION (or new bounty events depending on backend naming)
  • Ensure compatibility with graphql-ws client setup

2. Create Notification Hook

Create: hooks/use-notifications.ts

  • Manage subscription lifecycle:
    • Subscribe on mount
    • Handle incoming events
    • Cleanup on unmount
  • Normalize incoming data into a consistent notification format
  • Optionally integrate with local state or query cache

3. Build Notification UI

Create: components/notifications/notification-center.tsx

  • Implement a popover/dropdown component
  • Display a list of notifications:
    • Message
    • Timestamp
    • Status (read/unread)
  • Handle empty states and loading states
  • Allow marking notifications as read (optional enhancement)

4. Update Global Navbar

Modify: components/global-navbar.tsx

  • Add a notification bell icon
  • Show unread notification count (badge)
  • Toggle the notification center popover on click

Files Affected

Modified

  • lib/graphql/subscriptions.ts
  • components/global-navbar.tsx

Created

  • hooks/use-notifications.ts
  • components/notifications/notification-center.tsx

Acceptance Criteria

  • Users receive real-time notifications for relevant events
  • Subscriptions are correctly initialized and cleaned up
  • Notification bell displays unread count
  • Notification center displays incoming notifications
  • No memory leaks or duplicate subscriptions

Testing Notes

  • Simulate subscription events and verify UI updates
  • Test multiple notifications arriving in sequence
  • Ensure cleanup works when components unmount
  • Validate behavior across page navigation

Additional Notes

  • Consider debouncing or batching notifications if events are frequent
  • Ensure proper authentication for subscription connections
  • Plan for persistence (e.g., storing notifications) if needed in future
  • Keep notification structure extensible for additional event types

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions