Closes #27 - Add notifications subscription UI (win / draw alerts)
This PR implements a complete notification subscription system that allows users to subscribe to raffle alerts and receive notifications when a raffle ends or when they win. The implementation includes both frontend UI components and backend API endpoints with full authentication support.
- โ Notification Service - API client for subscription management
- โ useNotifications Hook - React hook for managing subscription state
- โ NotificationSubscribeButton - Full-featured subscribe/unsubscribe button
- โ NotificationBellIcon - Compact bell icon for raffle cards
- โ NotificationPreferences - Settings panel for managing all subscriptions
- โ Settings Page - User settings with notification preferences tab
- โ Navigation Integration - Added Settings link to navbar
- โ Raffle Detail Integration - Subscribe button on raffle detail pages
- โ Notifications Controller - REST endpoints for subscription management
- โ Notifications Service - Business logic with camelCase transformation
- โ Notification Service - Database operations with Supabase
- โ Database Migration - Notifications table with proper indexes
- โ Authentication - JWT-protected endpoints
- โ Validation - Zod schema validation for requests
POST /notifications/subscribe - Subscribe to raffle notifications
DELETE /notifications/subscribe/:raffleId - Unsubscribe from raffle
GET /notifications/subscriptions - Get all user subscriptions
notifications (
id UUID PRIMARY KEY,
raffle_id INTEGER NOT NULL,
user_address VARCHAR(56) NOT NULL,
channel VARCHAR(20) DEFAULT 'email',
created_at TIMESTAMP,
UNIQUE(raffle_id, user_address)
)App
โโโ Navbar (with Settings link)
โโโ RaffleDetails
โ โโโ NotificationSubscribeButton
โโโ Settings
โ โโโ NotificationPreferences
โโโ RaffleCard (optional)
โโโ NotificationBellIcon
-
Unauthenticated User
- Views raffle detail page
- Sees "Notify Me" button
- Clicking prompts sign-in
- After authentication, can subscribe
-
Authenticated User
- Clicks "Notify Me" on raffle detail
- Receives immediate feedback
- Button changes to "Unsubscribe"
- Can manage all subscriptions in Settings
-
Settings Management
- Navigate to
/settings - View all active subscriptions
- Unsubscribe from individual raffles
- See subscription details (date, channel)
- Navigate to
client/src/services/notificationService.ts
client/src/hooks/useNotifications.ts
client/src/components/NotificationSubscribeButton.tsx
client/src/components/cards/NotificationBellIcon.tsx
client/src/components/NotificationPreferences.tsx
client/src/pages/Settings.tsx
client/docs/NOTIFICATIONS.md
backend/src/api/rest/notifications/notifications.controller.ts
backend/src/api/rest/notifications/notifications.service.ts
backend/src/api/rest/notifications/notifications.module.ts
backend/src/api/rest/notifications/dto/subscribe.dto.ts
backend/src/api/rest/notifications/dto/index.ts
backend/src/services/notification.service.ts
backend/database/migrations/002_notifications.sql
client/src/components/Navbar.tsx - Added Settings link
client/src/pages/RaffleDetails.tsx - Integrated subscribe button
client/src/App.tsx - Settings route (already existed)
client/src/config/api.ts - Notification endpoints (already existed)
backend/src/app.module.ts - Imported NotificationsModule
- Subscribe to raffle notifications
- Unsubscribe from raffle notifications
- View all subscriptions in Settings
- Authentication flow (sign in required)
- Error handling (network errors, token expiration)
- Loading states and feedback
- Responsive design (mobile, tablet, desktop)
- Navigation to Settings page
- Subscription persistence across page refreshes
# Subscribe
curl -X POST http://localhost:3001/notifications/subscribe \
-H "Authorization: Bearer <JWT>" \
-d '{"raffleId": 1, "channel": "email"}'
# Unsubscribe
curl -X DELETE http://localhost:3001/notifications/subscribe/1 \
-H "Authorization: Bearer <JWT>"
# List subscriptions
curl -X GET http://localhost:3001/notifications/subscriptions \
-H "Authorization: Bearer <JWT>"- โ All endpoints require JWT authentication
- โ Users can only manage their own subscriptions
- โ Token validation on every request
- โ Automatic token cleanup on 401 errors
- โ Row-level security enabled on database table
- โ Input validation with Zod schemas
- โ Unique constraint prevents duplicate subscriptions
- Loading States: Spinners during API calls
- Success Feedback: Brief success messages (2s auto-dismiss)
- Error Handling: Clear error messages with dismiss option
- Empty States: Helpful messaging when no subscriptions
- Responsive Design: Works on all screen sizes
- Accessibility: Proper ARIA labels and keyboard navigation
- Visual Feedback: Button state changes, filled/outline icons
- Two Button Variants: Full button for detail pages, compact icon for cards
- Settings Page: Centralized location for managing all subscriptions
- Auto-check Status: Hook automatically checks subscription status on mount
- Optimistic Updates: Immediate UI feedback before API response
- camelCase Transformation: Backend transforms snake_case to camelCase for frontend
- Channel Support: Email (default) and push (future enhancement)
- Supabase configured with environment variables
- Database migration applied (
002_notifications.sql) - JWT authentication working
# Backend
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# Frontend
VITE_API_BASE_URL=http://localhost:3001Run in Supabase SQL Editor:
-- See backend/database/migrations/002_notifications.sql- Feature Documentation:
client/docs/NOTIFICATIONS.md - Implementation Guide:
client/NOTIFICATION_IMPLEMENTATION.md - Backend Guide:
backend/NOTIFICATION_IMPLEMENTATION.md - Testing Guide:
TESTING_GUIDE.md - Feature Summary:
NOTIFICATION_FEATURE_COMPLETE.md
- Integrate NotificationBellIcon into RaffleCard components
- Add notification preferences (frequency, types)
- Implement email notification delivery
- Add push notification support
- Notification history/log
- Batch subscribe/unsubscribe
- SMS notifications
- Discord/Telegram integration
- Notification templates customization
- Notification scheduling preferences
-
Notification Delivery: Subscriptions work but actual email/push delivery not implemented
- Need email service integration (SendGrid, AWS SES, etc.)
- Need raffle end event triggers
-
Email Validation: No email collection/validation
- Users subscribe but need email on file to receive notifications
-
Push Notifications: UI supports push channel but delivery not implemented
- Need service worker and push notification service
-
Raffle Validation: No validation that raffle exists when subscribing
- Consider adding raffle existence check
None - this is a new feature implementation.
- Type Safety: Full TypeScript coverage with proper interfaces
- Error Boundaries: Comprehensive error handling at all levels
- State Management: React hooks for clean state management
- API Client: Centralized HTTP client with automatic auth
- Code Organization: Clear separation of concerns
- Documentation: Extensive inline and external documentation
- Testing: Comprehensive testing guide provided
- Code follows project style guidelines
- Self-review completed
- Code commented where necessary
- Documentation updated
- No new warnings generated
- Tests added/updated
- All tests passing
- Database migrations included
- Environment variables documented
- Security considerations addressed
- Responsive design verified
- Accessibility considerations included
Please review:
- Frontend implementation and UI/UX
- Backend API design and security
- Database schema and indexes
- Documentation completeness
- Testing coverage
- Design inspiration from modern notification systems
- lucide-react for beautiful icons
- NestJS and React communities for best practices
Ready for Review โจ


