An open API service indexing awesome lists of open source software.

https://github.com/jayakrishnan-mk/real-time-notification-system

Real-Time-Chat-Application - built on Redis, which internally works on a Queue model for rate limiting. This system handles 500+ plus notifications per second.
https://github.com/jayakrishnan-mk/real-time-notification-system

authentication-middleware bullmq clean-architecture docker hashmap heartbeat microservice prisma pubsub queue-workers rate-limiting receipts reconnection redis retry-strategies rooms swagger websocket

Last synced: 2 months ago
JSON representation

Real-Time-Chat-Application - built on Redis, which internally works on a Queue model for rate limiting. This system handles 500+ plus notifications per second.

Awesome Lists containing this project

README

          

# ๐Ÿ”” Real-Time Notification System.

A production-ready backend system to send real-time push notifications using **Node.js**, **Socket.IO**, **Redis**, **BullMQ**, and **PostgreSQL**. It supports JWT-based authentication, device-wise refresh token management, and secure token rotation.

---

## ๐Ÿ“ฆ Tech Stack-

- **Node.js** (Express)
- **TypeScript**
- **Socket.IO** for real-time communication
- **Redis** for Pub/Sub
- **BullMQ** for job queues
- **MySQL** with Prisma ORM
- **Swagger** for API docs
- **JWT** with Refresh Token Rotation
- **Docker** for containerization

---

## ๐Ÿง  Features

- โœ… Real-time notification delivery using WebSocket
- โœ… BullMQ + Redis for background job processing
- โœ… Refresh token rotation with device session tracking
- โœ… Secure and scalable architecture
- โœ… Swagger UI for API testing
- โœ… PostgreSQL-based DB design
- โœ… Admin queue dashboard with authentication
- โœ… Socket room-based architecture for user isolation

---

## ๐Ÿ“‚ Project structure

- dist
- node_modules
- prisma
- src
- -> assets
- -> config
- -> controllers
- -> dtos
- -> middleware
- -> public
- -> queues
- -> routes
- -> scripts
- -> services
- -> types
- -> utils
- -> workers
- -> ws
- -> index.ts
- -> loadEnv.ts
- .dockerignore
- .env
- .env.development
- .env.production
- .gitignore
- Dockerfile
- package-lock.json
- package.json
- readme.md
- tsconfig.json

---

## ๐Ÿ–ผ๏ธ High-Level Architecture

![HLD Diagram](./src/assets/HLD-noti.png)

---

## ๐Ÿ–ผ๏ธ HLD - 2

![HLD Diagram](./src/assets/HLD-2-notification-system.png)

---

## ๐Ÿงฑ Database Schema

![DB Diagram](./src/assets/db_diagram-realtime-chatApp.png)

---

## ๐Ÿ” Token Lifecycle Flow (JWT + Refresh Token)

![Token Flow](./src/assets/flowchart_diagram_illustrates_the_JSON_Web_Token.png.png)

---

## ๐Ÿ”Œ API Documentation

Swagger UI available at:

```
https://real-time-notification-system-production.up.railway.app/api-docs/
```

![Swagger](./src/assets/openApi-SWAGGER.png)

---

## ๐Ÿ” Bull Dashboard (For analyzing message queue)

Dashboard available at:

```
https://real-time-notification-system-production.up.railway.app/admin/queues/
```

![Queue](./src/assets/bullMQ-Dashboard.png)

---

## ๐Ÿš€ Local Development Setup

```bash
# 1. Clone repo
git clone https://github.com/Jayakrishnan-mk/real-time-notification-system

# 2. Install dependencies
npm install

# 3. Start Redis & Postgres via Docker (if not already running)

# 4. Setup env
cp .env.development .env

# 5. Run migrations
npx prisma migrate dev

# 6. Start dev server
npm run dev
```

---

## ๐Ÿณ Running with Docker (Production Build)

Build and run using Docker:

```bash
# 1. Build Docker image
docker build -t realtime-notify .

# 2. Run container
docker run -d -p 3000:3000 --env-file .env.production realtime-notify
Or if you're using Docker Compose:

bash
Copy
Edit
docker-compose up --build
Make sure your .env.production is properly set up with:

DATABASE_URL

REDIS_URL

JWT_SECRET

other required variables...
```

---

## ๐Ÿงช Testing the Notification Flow

```bash
# You can test real-time notifications by:
- Logging in to get access/refresh tokens
- Opening WebSocket connection with userId
- Hitting /api/notifications to simulate push
```

---

## ๐ŸŒ Deployment

Deployed on:
- Railway (Production)

---

## ๐Ÿค Contributing

PRs and suggestions welcome! ๐Ÿ™Œ

---

## ๐Ÿ“„ License

MIT