Final-year project
Real-Time Chat Application with Node.js and WebSockets
A full-stack chat app with sign-up, private and group chats, messages delivered instantly over WebSockets, online status, typing indicators, read receipts and stored message history.
Node.jsExpressSocket.IO or wsPostgreSQL or SQLiteHTML, CSS, JavaScript or React
The problem
Messaging apps feel instant because the server pushes new messages to you instead of you asking for them again and again. Building a chat app teaches the parts of a modern backend: authentication, a database, real-time connections, and what changes when many people are online at once.
Features to build
- Sign up and log in, with passwords hashed using bcrypt
- One-to-one chats and group rooms that users can create and join
- Messages delivered instantly over WebSockets to everyone in the room
- Messages saved in the database, with older history loaded as you scroll up
- Online and offline status, and a 'typing…' indicator
- Delivered and read receipts for one-to-one chats
- Unread counts for each chat
- Message text shown as plain text, never as HTML, to block script injection
Suggested data model
Add an index on messages (room_id, created_at) so loading a chat's recent history stays fast as the table grows.
Build plan
- 1
Build the REST API
Create Express routes for sign-up, log-in, listing rooms and loading message history, with input validation and error handling.
- 2
Add authentication
Issue a session or JWT on log-in, and check it both on HTTP requests and when a WebSocket connects.
- 3
Real-time messaging
When a client sends a message, validate it, save it to the database, then broadcast it to the room's members. Send back the saved message ID as an acknowledgement.
- 4
Presence and typing
Track connected users in memory, broadcast online and offline changes, and send short-lived typing events that are never stored.
- 5
History and receipts
Load history in pages using the oldest loaded message as a cursor, and update last_read_message_id when a user views a chat.
- 6
Test and deploy
Test with several browser windows, write API tests, and deploy with environment variables for secrets.
Learn these first
Each part of the project is taught in one of these free lessons.
- Express.js Tutorial: Your First Express Server
- Express Routing: Routes, Parameters and express.Router
- Express Middleware Explained: next(), Order and Examples
- Validating Request Data in Express (with Zod)
- Node.js Authentication: Hashing Passwords and JWT Login
- Node.js Database Tutorial: SQLite with Express
- Express API Security Best Practices (Helmet, CORS, Rate Limiting)
- Node.js Events and EventEmitter Explained
- JavaScript async and await: Writing Asynchronous Code That Reads Like Synchronous Code
- SQL CREATE TABLE: Define a New Table Step by Step
- SQL Indexes Explained: Make Queries Fast (and When Not To)
- System Design: Chat App Like WhatsApp
Make it stand out
- Image and file sharing, with size and type checks
- Search messages in a chat
- Browser notifications for new messages
- Run two server instances and connect them with Redis pub/sub so users on different servers can chat
Viva and interview questions
Try to answer each one aloud before you open it.
Why use WebSockets instead of the client asking the server every few seconds?
Polling sends many requests that usually return nothing and still adds delay. A WebSocket keeps one connection open in both directions, so the server can push a message the moment it arrives, with far less overhead.
Why save a message before broadcasting it?
If the server broadcast first and then crashed, people would see a message that was never stored and would disappear later. Saving first means everything shown has a permanent record and a real ID.
How do you stop someone from sending JavaScript inside a message?
Treat message text as plain text: insert it with textContent in the browser, or let React escape it. Never insert it as HTML. Also validate length and type on the server.
How would this work with thousands of users on several servers?
Each server only knows its own connections. A shared pub/sub channel such as Redis lets a server publish a new message, and every server forwards it to its own connected members of that room.
Why load history with a cursor instead of page numbers?
New messages keep arriving, so 'page 2' changes as people chat and messages get skipped or repeated. Asking for messages older than a given message ID always returns the right next set.
What to put in your project report
- Abstract: the problem, your solution and the result in one paragraph.
- Introduction and problem statement: who has the problem and why it matters.
- Requirements: the features (functional) and qualities such as speed and security (non-functional).
- Design: architecture diagram, database tables or data flow, and screen layouts.
- Implementation: the main modules and the most interesting code, explained.
- Testing: the test cases you ran, with inputs, expected and actual results.
- Results: screenshots or numbers that show the project working.
- Conclusion and future scope: what you achieved and what you would add next.
Your college may give its own format. Follow that first, and use this list to check nothing is missing.
More project ideas
- Quiz App with HTML, CSS and JavaScriptMini project
- Snake Game with JavaScript and CanvasMini project
- Student Result Management System in PythonMini project