This is a real-time chat application consisting of a frontend (chat-frontend) built with Next.js and a backend (chat-backend) powered by Node.js, Express, and Socket.io. The backend also integrates a MongoDB database for storing chat history.
- Built with HTML, CSS, JavaScript, and Next.js
- Uses Socket.io client to communicate with the backend
- Displays real-time chat messages
- Provides a responsive UI with message input, display, and logout functionality
- Built using Node.js and Express.js
- Uses Socket.io for real-time bidirectional communication
- Stores chat messages in a JSON file (for quick access) and a MongoDB database (for persistence)
- Fetches chat history from a local file if available, otherwise queries the database
- MongoDB is used for long-term message storage
- Chat messages are stored with
username,userid,message content, andtimestamp
- Chosen for its efficiency in handling WebSocket-based real-time updates
- Ensures seamless message exchange between clients
- JSON file caching: For quick retrieval of recent chat history
- MongoDB database: For long-term message persistence
- If the JSON file exists, messages are retrieved from it; otherwise, the database is queried
- The frontend styles are optimized for responsiveness and maintainability
- Uses Flexbox for layout and CSS transitions for smooth interactions
- Uses try-catch blocks to handle file read errors in the backend
- Ensures the application does not crash if the JSON file is missing or corrupted
- Efficiently handles database errors
git clone https://github.com/MuhammadAsad878/realtime-group-chat-application-frontend.gitgit clone https://github.com/MuhammadAsad878/realtime-group-chat-application-backend.gitcd chat-backend
npm install # Install dependencies
npm start # Start the backend server
# OR
node / nodemon server.jsBy default, the backend runs on http://localhost:5000.
cd chat-frontend
git checkout group-chat-app
npm install
npm run devEnsure the frontend correctly connects to the backend WebSocket server.
- Real-time messaging with Socket.io
- Basic authentication (username-based chat)
- Chat history persistence using JSON & MongoDB
- Optimized UI with responsive chat messages
- Efficient data handling & database integration
- Add user authentication with JWT
- Implement message reactions & typing indicators
- Deploy the app on Vercel (frontend) and Heroku/AWS (backend)
Below are screenshots showcasing the application's functionality:
In first Muhammad Asad username is written in center on that specific user profile who is sending message Hi , What's going on
**
In Second Arslan Ahmad is seeing this message on realtime message come from Muhammad Asad and above in green showing that user own messages

MIT License. Feel free to use and modify the project!

