Real-Time Chat App — MERN + Socket.IO with presence
Actual websockets — typing indicators, online presence, and messages that arrive in order.
Most chat projects poll an API on a timer and call it real-time; they lag, they duplicate messages, and they fall apart the moment two people type at once. This one uses Socket.IO for a genuine push connection — one-to-one and group chats, typing indicators, online and last-seen presence, delivery and read receipts, and history that persists and paginates. It survives the question every panel asks: how do you know a message actually arrived, and in the right order?
- Level
- Intermediate
- Live sessions
- 8
- Seats per college
- 2 / year
What it does
- One-to-one and group chats over a real websocket connection
- Typing indicators and online / last-seen presence
- Delivery and read receipts per message
- Message history persisted in MongoDB and paginated on scroll
- Authentication carried into the socket layer, not just the REST API
- A chat list that reorders as new messages arrive
What the sessions cover
- 01Why websockets, not polling — and what Socket.IO gives you
- 02Rooms, events, and the connection lifecycle
- 03Presence and typing indicators without hammering the server
- 04Message ordering, delivery, and persisting history
- 05Authenticating a socket and mapping users to connections
- 06The React chat UI and keeping state in sync with events
- 07Scaling notes: the Redis adapter and horizontal sockets
- 08Deployment and a full mock viva on the real-time design
Stack
How it works
After login over REST, the React client opens a Socket.IO connection and sends its JWT in the handshake. The server verifies the token in connection middleware and attaches the user id to the socket, so every later event is tied to a real identity and an unauthenticated client never gets a socket at all.
Each conversation is a Socket.IO room. Sending a message emits an event to the server, which saves it to MongoDB first and only then broadcasts it to the room with its database id and server timestamp. The sender's client shows the message immediately as pending and replaces it with the saved version when the acknowledgement returns.
Presence is a map of user id to the set of connected socket ids, because one person can have two tabs open. A user is online while that set is non-empty; on the last disconnect the server records last-seen and tells their contacts. Typing indicators are short-lived events that are never stored.
The data
Users, conversations (participants array, a type of direct or group, and a lastMessage summary for the chat list) and messages (conversation id, sender, body, createdAt, deliveredTo and readBy arrays). A compound index on conversation id and createdAt makes loading history in pages of 30 a cheap range query.
The hard parts examiners ask about
One user, many sockets
Treating a socket as a user breaks presence the moment someone opens a second tab. Tracking a set of sockets per user and marking them offline only when the set empties fixes it.
Message order and duplicates
Clients reconnect and resend. Each outgoing message carries a client-generated id, and the server ignores a repeat of an id it already stored, so a flaky network does not produce double messages.
Paginating while new messages arrive
Offset pagination shifts when new rows are added. History is loaded with a cursor, messages older than the oldest one on screen, so scrolling up never skips or repeats a message.
Viva questions on this project
- Why Socket.IO instead of polling the REST API?
- Polling asks the server every few seconds whether anything changed, which wastes requests and adds delay. A websocket keeps one connection open so the server pushes a message the moment it is saved.
- How is the socket connection authenticated?
- The client passes its JWT in the handshake auth payload, and server middleware verifies it before accepting the connection. A failed check rejects the socket outright.
- How do read receipts work?
- When a message is rendered in an open conversation, the client emits a read event with the message id. The server adds the user to readBy and notifies the sender, whose UI changes the tick.
- What happens to messages sent while a user is offline?
- They are stored in MongoDB regardless. When the user reconnects, the client fetches anything newer than its last message, so nothing depends on the user being online at send time.
- How would this scale to several servers?
- Rooms live in one server's memory, so with more than one instance you add the Socket.IO Redis adapter, which relays broadcasts between servers so users on different instances still reach each other.
Pick what you need
Direct UPI / bank transfer in monthly installments. Sessions start after the first installment; handover is after the final installment. Full terms — including what happens if you stop midway.
Source
₹5,500
single payment
- Full source code
- Local setup guide
- Sample dataset / seed data
- One handover call
Academic
₹10,000
or ₹5,000/month × 2
- Everything in Source
- Project report (synopsis + full document)
- Presentation deck
- ER / DFD / architecture diagrams
- Deployment walkthrough
Mentored
Most picked₹16,000
or ₹5,400/month × 3
- Everything in Academic
- 8 live sessions on Google Meet
- Line-by-line code walkthrough
- Viva question prep + mock viva
- One module varied for you (dataset / domain)
- WhatsApp support until submission
This page has no reviews on it yet. Be the reason it does.
The first 3 students get 40% off in exchange for an honest review and permission to show your finished project here. Same build, same sessions, same handover — the discount is the price of going first, and it is not coming back once those seats are gone.
You are about to send money to a stranger on the internet.
Fair. So here is everything you need to check who I am — all of it public, all of it older than this page.
Two things I hold myself to
- Only 2 students from your college get this project in an academic year. On the Mentored tier one module is varied for you — the dataset, the domain, or a feature — so no two submissions read the same.
- You build nothing. You just have to be able to explain it. The project is delivered finished — code, report, diagrams, deployed. Then daily 60-minute sessions on Google Meet after 8:00 PM IST, walking the code you are submitting, ending in a mock viva. Turn up and you will know it well enough to answer anything the panel asks.
Enquire about this project
Tell me your submission deadline and which tier fits. You get a session schedule and an installment split back — usually within a day.