This repository contains the source code for a real-time chat application built with Node.js, Express, Socket.IO, and MongoDB. The application allows users to send and receive messages in real-time and stores messages in a MongoDB database.
Before you begin, ensure you have met the following requirements:
- Node.js and npm installed on your machine.
- MongoDB database accessible or a MongoDB Atlas account (update the
dburlvariable inserver.jswith your MongoDB connection string). - Git installed for version control (optional but recommended).
To install the project and its dependencies, follow these steps:
-
Clone this repository to your local machine:
git clone https://github.com/yourusername/real-time-chat-app.git
-
Change your current directory to the project folder:
cd real-time-chat-app -
Install the project dependencies listed in
package.jsonusing npm:npm install
This will install the following dependencies:
body-parser: Middleware for parsing request bodies.bootstrap: CSS framework for styling.express: Web application framework for Node.js.mongoose: ODM (Object Data Modeling) library for MongoDB.socket.io: Library for real-time communication.
To run the chat application locally, follow these steps:
-
Ensure you have MongoDB running or your MongoDB Atlas credentials correctly configured in
server.js. -
Start the server:
npm start
The server will start, and you can access the application in your web browser at http://localhost:3000.
This is a working demo for the same
Retrieves all stored messages from MongoDB.
GET /messages:Adds a new message to the database and broadcasts it.
POST /messages:We welcome contributions from the community. To contribute to this project, follow these steps:
-
Fork the repository.
-
Create a new branch for your feature or bug fix.
-
Make your changes and test them thoroughly.
-
Submit a pull request.
Feel free to customize this README to match your specific project details and provide links, badges, and any additional information that's relevant to your project.