This project contains two implementations of a simple single-room chat application:
- One using HTTP polling with Express
- One using WebSocket with the
websocketnpm library
The goal of this project is to compare and understand different real-time communication methods in Node.js.
Both implementations are deployed and publicly accessible:
- Frontend: https://pratiamaladen-frontend.hosting.codeyourfuture.io
- Backend: https://pratiamalden-chatapp-websocket.hosting.codeyourfuture.io
- Frontend: https://chatapp-frontend.hosting.codeyourfuture.io
- Backend: https://chatapp-server.hosting.codeyourfuture.io/messages
- Single shared chat room
- Multiple users can join and exchange messages
- Real-time message updates
- Message reactions (like / dislike)
- Basic message history
- Simple browser-based UI
- Node.js
- Express (polling version)
- WebSocket using the
websocketnpm package - HTML, CSS, JavaScript (frontend)
- No database (messages stored in memory)
This project is primarily built for:
- Learning real-time communication concepts
- Understanding the difference between polling and WebSocket communication
- Practicing backend and frontend interaction
Chat-Application/
├── polling/
│ ├── backend/
│ │ ├── index.mjs
│ │ └── utils.mjs
│ └── frontend/
│ ├── index.html
│ ├── css/
│ │ └── style.css
│ └── js/
│ ├── app.mjs
│ └── utils.mjs
│
├── websocket/
│ ├── backend/
│ │ ├── index.mjs
│ │ └── utils.mjs
│ └── frontend/
│ ├── index.html
│ ├── css/
│ │ └── style.css
│ └── js/
│ ├── app.mjs
│ └── utils.mjs
│
├── package.json
├── package-lock.json
└── README.md
- Node.js (v16+ recommended)
- npm
Clone the repository and install dependencies:
git clone https://github.com/PratiAmalden/Chat-Application.git
cd Chat-Application
npm installDependencies are shared across both implementations using the root package.json.
-
Start the server:
node polling/backend/index.mjs
-
Open the frontend:
- Open
polling/frontend/index.htmldirectly in your browser or - Serve it using a simple local server
- Open
-
The app will connect to the polling backend and simulate real-time updates by regularly requesting new messages.
-
Start the backend:
node websocket/backend/index.mjs
-
Open the frontend:
- Open
websocket/frontend/index.htmlin your browser or - Serve it through a local server
- Open
-
This version uses persistent WebSocket connections for true real-time communication.
- Multiple chat rooms
- Proper user accounts (persistent identities stored server-side)
- Authentication and basic authorization
- Message history with database
- UI improvements
- Typing indicators and read receipts