This release adds a centralized notification system with real-time WebSocket delivery.
Migration File: database/migrations/014_create_notifications.sql
# Option A: Using psql
psql -h $DB_HOST -U $DB_USER -d $DB_NAME -f database/migrations/014_create_notifications.sql
# Option B: Using Docker
docker-compose exec db psql -U user -d mentorsmind -f /path/to/014_create_notifications.sql
# Option C: Using your migration tool
./database/migrate.sh # Unix/Linux/Mac
database\migrate.bat # Windows-- Check table exists
SELECT * FROM information_schema.tables WHERE table_name = 'notifications';
-- Check structure
\d notifications
-- Test insert
INSERT INTO notifications (user_id, type, title, message)
VALUES (
(SELECT id FROM users LIMIT 1),
'system_alert',
'Test',
'Migration successful'
);The notification cleanup service will initialize automatically on startup.
GET /api/v1/notifications- Get paginated notificationsGET /api/v1/notifications/unread-count- Get unread countPUT /api/v1/notifications/:id/read- Mark as readPUT /api/v1/notifications/read-all- Mark all as readDELETE /api/v1/notifications/:id- Delete notification
- Notification Cleanup: Runs daily at 2:00 AM, deletes notifications older than 90 days
notification:new- Emitted when a notification is created
CREATE TABLE notifications (
id UUID PRIMARY KEY,
user_id UUID NOT NULL REFERENCES users(id),
type notification_type NOT NULL,
title VARCHAR(255) NOT NULL,
message TEXT NOT NULL,
data JSONB DEFAULT '{}'::jsonb,
is_read BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE
);12 notification types including:
- session_booked, session_confirmed, session_cancelled
- payment_received, payment_failed
- review_received, escrow_released
- dispute_opened, meeting_confirmed
- And more...
6 indexes for optimal query performance on user_id, type, is_read, and created_at.
# Get notifications
curl -H "Authorization: Bearer $TOKEN" \
https://your-api.com/api/v1/notifications
# Get unread count
curl -H "Authorization: Bearer $TOKEN" \
https://your-api.com/api/v1/notifications/unread-countconst socket = io('https://your-api.com', {
auth: { token: 'YOUR_JWT_TOKEN' }
});
socket.on('notification:new', (data) => {
console.log('✅ WebSocket working:', data);
});// In your application code
await NotificationService.create('user-id', 'system_alert', {
title: 'Deployment Test',
message: 'Notification system is live!',
data: { test: true }
});Notification cleanup service initialized- Service started successfullyNotification cleanup completed: X notifications deleted- Daily cleanup runningFailed to emit notification:new event- WebSocket issues (non-critical)
- Notification creation rate
- Unread notification count per user
- WebSocket connection success rate
- Cleanup job execution time
If issues occur:
git revert HEAD
git push origin mainDROP TABLE IF EXISTS notifications CASCADE;
DROP TYPE IF EXISTS notification_type CASCADE;- API Docs:
docs/notifications-api.md - Integration Examples:
docs/notification-integration-examples.md - Quick Reference:
NOTIFICATIONS_QUICK_REFERENCE.md - Implementation Summary:
NOTIFICATIONS_IMPLEMENTATION_SUMMARY.md - Migration Instructions:
MIGRATION_INSTRUCTIONS.md
No new environment variables required. The system uses existing:
- Database connection (DATABASE_URL)
- JWT authentication (JWT_SECRET)
- WebSocket configuration (existing)
- ✅ Migration runs without errors
- ✅ Application starts successfully
- ✅ API endpoints return 200 responses
- ✅ WebSocket events are received
- ✅ Cleanup service initializes
- ✅ No errors in application logs
If issues arise:
- Check application logs for errors
- Verify database migration completed
- Test WebSocket connectivity
- Review
MIGRATION_INSTRUCTIONS.mdfor troubleshooting
- Centralized notification system
- 5 new API endpoints
- WebSocket real-time delivery
- Auto-cleanup cron job
- Comprehensive documentation
src/routes/index.ts- Added notifications routessrc/services/notification.service.ts- Added WebSocket integration
- New table:
notifications - New ENUM:
notification_type - 6 new indexes
Deployment Date: To be filled
Deployed By: To be filled
Environment: To be filled
Status: To be filled