Skip to content

dhruv867/Task-maker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Realtime WebSocket Notifications

Production-ready Spring Boot application for real-time, user-targeted notifications over WebSocket/STOMP. Features user-specific queues, simple subscription APIs, and a minimal HTML client for testing.

Overview

  • Real-time server-to-client push using WebSocket/STOMP
  • Per-user delivery via /user/queue/notifications
  • Simple REST endpoints to manage subscriptions and publish channel events
  • MongoDB integration (repositories defined, persistence toggled in code)

Entry point: com.developersuraj.realtimenotifications.RealTimeNotificationsApplication

Architecture

Client UI: src/main/resources/static/index.html
Config: src/main/resources/application.properties
Build: pom.xml

Prerequisites

  • Java 21
  • MongoDB running at localhost:27017 (default DB: test)
  • Port 8080 available

Setup

Build & Run

# Windows (PowerShell / CMD)
./mvnw.cmd spring-boot:run

# macOS/Linux
./mvnw spring-boot:run

Access demo UI: http://localhost:8080/index.html
Or open src/main/resources/static/index.html directly.

How It Works

API

  • Subscribe a user to a channel:

    # POST /api/subscriptions/subscribe
    curl -X POST http://localhost:8080/api/subscriptions/subscribe \
      -H "Content-Type: application/json" \
      -d '{"userId":1,"channelId":42}'

    Payload: com.developersuraj.realtimenotifications.dto.SubscriptionRequest

  • Publish a channel event (broadcast to subscribers):

    # POST /api/notifications/publish
    curl -X POST http://localhost:8080/api/notifications/publish \
      -H "Content-Type: application/json" \
      -d '{"channelId":42,"videoId":"abc123","videoTitle":"Intro to WebSockets"}'

    Payload: com.developersuraj.realtimenotifications.dto.ChannelEvent

End-to-End Demo

  1. Start the server.
  2. Open http://localhost:8080/index.html.
  3. Enter userId 1 and click “Connect.”
  4. Subscribe user 1 to channel 42:
    • Use the subscribe API (see above).
  5. Publish a channel event on 42:
    • Use the publish API.
  6. The UI should display: "[Channel 42] New video: Intro to WebSockets".

Testing

./mvnw test

Implementation Notes

Roadmap

  • Authentication and session management
  • Durable delivery and read receipts
  • Topic-based broadcasting with fine-grained permissions
  • Integration tests for WebSocket messaging

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published