This is a web-based chat application built using Node.js and Socket.io for real-time communication between users. The app supports both public and private messaging, with features like dark mode, search functionality within chats, and a user list for private messaging. The interface is responsive and intuitive, designed for seamless user interaction.
- Real-time Communication: Messages are sent and received instantly.
- Public and Private Messaging: Choose between group chats or one-on-one private messages.
- Search Functionality: Search through messages in private chats.
- Dark Mode: Toggle between light and dark themes.
- User List: View a list of online users for initiating private chats.
- Persistent Chat History: Chat history is stored locally per user during the session.
- Responsive UI: Clean and user-friendly interface.
- HTML5, CSS3: For structuring and styling the application.
- JavaScript: For dynamic behavior and user interactions.
- Node.js: Handles server-side operations.
- Socket.io: Manages WebSocket connections for real-time data transmission.
Ensure you have the following installed on your system:
- Node.js: Download Node.js
- npm: Comes with Node.js installation.
-
Clone the repository:
git clone <repository_url>
-
Navigate to the project directory:
cd Web-Based-Chat-Application -
Navigate to the server directory:
cd nodeserver -
Install the required dependencies:
npm install
-
Start the server:
npx nodemon index.js
-
Open the project in your browser:
- Use a live server in your code editor to run the
index.htmlfile. - Alternatively, open the HTML file directly in your browser after starting the server.
- Use a live server in your code editor to run the
- Open the application in your browser.
- Enter your name in the prompt to join the chat.
- Use the Users Online section to:
- View the list of active users.
- Click a user's name to start a private chat.
- Use the search bar to search through messages in private chats.
- Switch between dark mode and light mode using the toggle button.
- Send a message using the input field and send button.
Realtime-Chat-Application
├── index.html # Main HTML file for the client
├── style.css # Styling for the client
├── js
│ └── client.js # Frontend logic for interacting with the server
├── nodeserver
│ └── index.js # Backend logic using Node.js and Socket.io
└── README.md # Project documentation
- User Management:
- Tracks users and their respective sockets.
- Updates and broadcasts the user list.
- Message Handling:
- Broadcasts public messages to all users.
- Directs private messages to specific users based on their socket ID.
- Disconnection Management:
- Notifies other users when someone leaves.
- Chat Management:
- Sends and receives messages in real-time.
- Appends messages to the chat container.
- Maintains chat history for private chats.
- Search Functionality:
- Highlights and scrolls to matching messages within the chat.
- UI Enhancements:
- Switch between themes using local storage for persistence.
- Responsive design for an optimal user experience.
- Start the server and open the application in multiple browser tabs or devices.
- Join with different usernames to test real-time messaging.
- Experiment with public and private messaging, the search feature, and dark mode.
- Notification Sound:
Replace the
notification.mp3file to use a custom sound. - Styling:
Modify the
style.cssfile to customize the appearance. - Port Configuration:
Change the port number in
index.jsto run the server on a different port.