How steffenwt/nodejs-pub-sub-chat-demo works
Project type and purpose
• This is a lightweight, real‐time chat demo built on Node.js that illustrates two modes:
a) A pure Socket.io version (app.js)
b) A Redis Pub/Sub + Socket.io version (app_redis.js)
• Its goal is to show how messages can be broadcast in‐process or distributed across multiple Node instances via Redis.
File structure
• Top‐level files only—no frontend/backend folder split:
• app.js → HTTP + Socket.io server (no Redis)
• app_redis.js → HTTP + Socket.io server wired to Redis Pub/Sub
• index.html → Static client UI for chat
• package.json → Defines dependencies: socket.io, redis, express (or http)
• There are no separate build scripts or microservices—everything runs in one Node process.
README for additional insights
• Emphasizes two run modes (“npm run sockets” or “npm run redis”)
• Mentions Redis must be installed/running for the Pub/Sub demo
– HTTP/WebSocket (socket.io)
– Redis Pub/Sub client (in app_redis.js only)
• From Browsers → Node.js: “WebSocket: chat message”
• From Node.js → Redis (Pub): “PUBLISH chat”
• From Redis → Node.js (Sub): “SUBSCRIBE chat”
• From Node.js → Browsers: “WebSocket: broadcast”
5. A second path directly from Server → Clients for the non‐Redis mode.