A scalable Notification System built using Node.js, TypeScript, PostgreSQL, Redis, and BullMQ.
This project demonstrates real-world backend architecture with asynchronous job processing, idempotency, and worker-based design.
Client → API → Database (PostgreSQL)
↓
Redis (Queue)
↓
Worker (BullMQ)
- API stores notification in DB
- Pushes job to Redis queue
- Worker processes job asynchronously
- ✅ Asynchronous job processing using BullMQ
- ✅ Redis-based queue system
- ✅ Worker architecture (background processing)
- ✅ Idempotency support (prevents duplicate requests)
- ✅ Retry-ready schema (
retry_count,max_retries) - ✅ Clean layered architecture (Controller → Service → Repository)
- ✅ Type-safe backend with TypeScript
- ✅ PostgreSQL integration using raw queries
- Backend: Node.js, TypeScript, Express
- Database: PostgreSQL
- Queue: Redis + BullMQ
- Tooling: tsx, nodemon
## 📂 Project Structure
```bash
src/
├── config/ # DB, Redis, env configs
├── controllers/ # Request handlers
├── service/ # Business logic
├── repository/ # DB queries
├── queues/ # BullMQ queue setup
├── workers/ # Background job processors
├── types/ # TypeScript types
├── dto/ # Data transfer objects
├── middlewares/ # Error handling
---``
git clone <your-repo-url>
cd notification-systemnpm installPORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=yourpassword
DB_NAME=notification-system
REDIS_HOST=127.0.0.1
REDIS_PORT=6379docker run -d -p 6379:6379 redisnpm run devnpx tsx src/workers/notification.worker.tsCreate Notification
POST /api/v1/notifications{
"user_id": "user_123",
"type": "EMAIL",
"message": "Hello",
"email": "user@email.com"
}idempotency_key: unique-key-123PENDING → PROCESSING → SENT
↘ FAILED
🔹 Idempotency Prevents duplicate requests using unique keys Ensures safe retries
🔹 Queue-based Processing API remains fast Heavy tasks handled in background
🔹 Worker System Decouples processing from request lifecycle Enables scalability
This project helped in understanding:
- Distributed system basics
- Async processing patterns
- Queue-based architectures
- Backend scalability concepts
Kushal Chavan