This is a real-time notification system built using Kafka, Hono.js, Upstash Redis, and WebSockets. It ensures seamless communication between users by providing instant notifications. The system is designed to be scalable, efficient, and optimized for high performance.
- Backend: Hono.js (Fast Edge API framework)
- Message Queue: Apache Kafka (for event-driven notifications)
- Cache & Pub/Sub: Upstash Redis (for fast delivery & scalability)
- Database: MongoDB (for storing notifications history)
- WebSockets: For instant notification updates
- Event Triggered: A user action (e.g., message sent, job update) triggers a notification event.
- Kafka Processing: The event is published to a Kafka topic.
- Redis Caching: The event is temporarily stored in Upstash Redis for fast retrieval.
- WebSockets: The event is pushed to connected clients in real time.
- Database Storage: The Notification can be handle with any Databases.
- User Receives Notification: The frontend displays the notification instantly.
✅ Real-time Notifications via WebSockets
✅ Kafka Integration for handling high-volume events
✅ Upstash Redis for caching and scalability
✅ Efficient Message Delivery using event-driven architecture
✅ Secure Authentication for user access control
📦 scalable-notifications
├── 📂 src
│ ├── 📂 config
│ │ ├── kafka.ts # Kafka producer/consumer setup
│ │ ├── redis.ts # Redis connection using Upstash
│ ├── 📂 utils
│ │ ├── index.ts # Helper functions
│ ├── 📂 services
│ │ ├── notificationService.ts # Handles notification logic
│ ├── 📂 routes
│ │ ├── index.ts # API routes for notifications
│ ├── 📂 events
│ │ ├── kafkaConsumer.ts # Kafka consumer logic
│ ├── index.ts # Hono server entry point
├── 📄 .env # Environment variables
├── 📄 .gitignore # Git ignore file
├── 📄 package.json # Dependencies & scripts
├── 📄 README.md # Project documentation
└── 📄 tsconfig.json # TypeScript configuration
## 🛠️ Setup Instructions
### 1️⃣ Clone the Repository
```sh
git clone https://github.com/mrcoder57/scalable-notifications.git
cd notification-system
cd scalable-notifications
npm installCreate a .env file in the backend directory:
KAFKA_BROKER=your-kafka-broker
UPSTASH_REDIS_URL=Your_url
UPSTASH_REDIS_TOKEN=your_token
KAFKA_PASSWORD=your-password
KAFKA_USER=your-usernpm run dev- Open localhost:3000 (Frontend UI) in the browser.
- Trigger a notification event (e.g., send a message, update a job).
- The notification should appear in real-time.
- Do NOT push
ca.pemor secrets to GitHub. - Use environment variables to store sensitive data.
- Implement authentication & authorization for WebSocket connections.
- Monitor Redis and Kafka performance to handle large-scale notifications.
- ✅ Push Notification Support (Firebase or OneSignal)
- ✅ Mobile App Integration
- ✅ Notification Preferences for Users
Feel free to open issues or contribute to this repository! 😊