A full-stack real-time chat application built using the MERN stack and Socket.io. This project was developed as part of the Vedaz intern assignment.
🌐 Live Demo (Frontend): (https://real-time-chat-app-three-blond.vercel.app/) ⚙️ Live API (Backend): (https://realtimechatapp-63kq.onrender.com)
- Real-Time Messaging: Instant message delivery without page refresh using Socket.io.
- Persistent Chat History: All messages are saved and fetched from a MongoDB database.
- Timestamps: Each message displays the exact time it was sent.
- Auto-Scroll UX: Chat box automatically scrolls to the latest message.
- Responsive UI: Clean, WhatsApp-style UI built with Tailwind CSS.
- Dummy Authentication: Username-based entry for testing multi-user interactions.
- Frontend: React (Vite), Tailwind CSS, Socket.io-client
- Backend: Node.js, Express.js, Socket.io
- Database: MongoDB Atlas (Mongoose)
Make sure you have Node.js and Git installed on your system.
- Navigate to the backend directory:
cd Backend - Install dependencies:
npm install
- Create a .env file in the backend root directory and add the required environment variables (see below).
- Start the server:
(The server will run on http://localhost:5000)
npm start
- Open a new terminal and navigate to the frontend directory:
cd Frontend - Install dependencies:
npm install
- Start the development server:
(The app will open on http://localhost:5173)
npm run dev
To run this project locally, create a .env file in the Backend folder and add the following variables:
PORT=5000
MONGO_URI=<YOUR_MONGODB_ATLAS_CONNECTION_STRING>(Note: Replace <YOUR_MONGODB_ATLAS_CONNECTION_STRING> with your actual MongoDB connection string. Never commit your actual .env file to GitHub.)
- Vite over CRA: Chose Vite for the React frontend for faster hot-module replacement (HMR) and optimized production builds.
- Separation of Concerns: Kept REST APIs for fetching history/saving messages, and strictly used WebSockets (Socket.io) for real-time broadcasting to keep the architecture clean.
- Tailwind CSS: Used utility-first CSS for rapid UI development and to keep the bundle size small without writing custom CSS files.
- useRef for UX: Implemented a dummy div with
useRefat the bottom of the chat box to ensure smooth auto-scrolling when new messages arrive.
- Authentication: As per the bonus requirements, full JWT auth was skipped in favor of a prompt-based username entry to quickly test real-time Socket communication.
- Database: Assumed MongoDB Atlas is the best fit over SQLite for real-time MERN stack applications due to its seamless JSON-like document integration with Node.js.