From 5490958d6e1eb59ea5ade8b18af7ee2eff78c410 Mon Sep 17 00:00:00 2001 From: David Neuhauss Date: Fri, 30 Jan 2026 11:50:10 +0100 Subject: [PATCH] add README for notification system --- .../java/SuMoC/backend/notification/README.MD | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/main/java/SuMoC/backend/notification/README.MD diff --git a/src/main/java/SuMoC/backend/notification/README.MD b/src/main/java/SuMoC/backend/notification/README.MD new file mode 100644 index 0000000..3f92a34 --- /dev/null +++ b/src/main/java/SuMoC/backend/notification/README.MD @@ -0,0 +1,49 @@ +# Notification System Overview + +This document provides an overview of the notification system for client developers integrating with the backend. It +explains notification types, expected payloads, and device token registration. + +## Notification Types + +Notifications sent to clients are categorized by `NotificationType`: + +- **TREND**: Informs users about changes in their mobility trends (e.g., reduced car usage). See + `TrendNotificationService`. +- **ADHOC_ALTERNATIVE**: Suggests a more sustainable alternative after a recent trip upload. See + `AdHocSuggestionService`. +- **REGULAR_TRIP_ALTERNATIVE**: Suggests an alternative for a detected regular trip (e.g., weekly commute). See + `RegularTripSuggestionService`. +- **FRIENDSHIP_REQUEST_RECEIVED**: Notifies about a new pending friendship request. + +See `NotificationType.java` for the full enum. + +## Notification Payloads + +Each notification type includes a data payload. The main DTOs in the notification body are: + +- **TREND**: Contains a list of `TrendDetectionDTO` objects, each describing a detected trend for the user. The + structure includes fields such as `userId`, `timespan`, `type`, `attribute`, `deltaType`, `changeValue`, and + `trendConnotation`. See `TrendDetectionDTO.java` for details. +- **ADHOC_ALTERNATIVE**: Contains a list of `RouteDTO` objects representing the best alternative(s) for a recent trip ( + see `AdHocSuggestionService`). +- **REGULAR_TRIP_ALTERNATIVE**: Contains a list of 1 or 2 `RouteDTO` objects for the best alternative(s) to a detected + regular trip, depending on user preferences (e.g., if `preferPhysicalActivity` is set, two alternatives may be + included). See `RegularTripSuggestionService` and `RegularTripDetectionService` for details. +- **FRIENDSHIP_REQUEST_RECEIVED**: Contains a `friendshipDTO` where `friend` is the user who sent the request. See + `FriendshipDTO.java`. + +## Device Token Registration + +To receive push notifications, clients must register their device token. Token registration is handled in the +`NotificationController`. The backend stores or updates the token for the authenticated user. + +--- + +## For Backend Developers + +To queue notifications for users, use the `NotificationSchedulerService` as the main entry point. This service provides +methods to schedule notifications with the appropriate type and payload. See `NotificationSchedulerService.java` for +usage details. + +--- +For further details, refer to the respective service and DTO classes in the codebase.