Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔔 Notification System

📌 Overview

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.

🛠️ Tech Stack

  • 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

🔄 How It Works

  1. Event Triggered: A user action (e.g., message sent, job update) triggers a notification event.
  2. Kafka Processing: The event is published to a Kafka topic.
  3. Redis Caching: The event is temporarily stored in Upstash Redis for fast retrieval.
  4. WebSockets: The event is pushed to connected clients in real time.
  5. Database Storage: The Notification can be handle with any Databases.
  6. User Receives Notification: The frontend displays the notification instantly.

🚀 Features

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

📂 Project Structure

📦 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

2️⃣ Install Dependencies

cd scalable-notifications
npm install

3️⃣ Configure Environment Variables

Create 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-user

4️⃣ Start the Backend Server

npm run dev

6️⃣ Test the System

  • 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.

🔒 Security Best Practices

  • Do NOT push ca.pem or 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.

📝 Future Enhancements

  • ✅ Push Notification Support (Firebase or OneSignal)
  • ✅ Mobile App Integration
  • ✅ Notification Preferences for Users

📞 Support & Contributions

Feel free to open issues or contribute to this repository! 😊

🔗 GitHub Repository

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages