This project is a full-stack real-time chat application built with the MERN stack. The frontend is created using React, the backend with Express and Node.js, Socket.IO is used for real-time communication, and MongoDB is the database.
The application is deployed and available at: Chat App
- Real-time messaging with Socket.IO
- User authentication using JWT
- Password hashing with bcryptjs
- Responsive design for mobile and desktop
Follow the steps below to set up the project locally.
Ensure you have the following installed:
- Node.js (https://nodejs.org/)
- MongoDB (https://www.mongodb.com/)
- Git (https://git-scm.com/)
-
Clone the repository:
git clone https://github.com/Sithum-Bimsara/Mern-Chat-App.git cd chat-app-yt
-
Install dependencies:
npm install cd frontend npm install
-
Create a
.env
file in thebackend
directory with the following variables:PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret NODE_ENV = development
-
Start the application:
- Run the backend server:
npm run server
- Run the frontend:
cd frontend npm start
- Run the backend server:
npm run server
: Starts the backend server with Nodemon.npm start
: Starts the backend server.npm run build
: Installs dependencies and builds the frontend.
bcryptjs
: For password hashing.cookie-parser
: To parse cookies in HTTP requests.dotenv
: To manage environment variables.express
: Web framework for Node.js.jsonwebtoken
: To generate and verify JSON Web Tokens.mongoose
: For interacting with MongoDB.socket.io
: For real-time communication.
nodemon
: For hot-reloading the backend server during development.
The application is deployed on Render. To deploy your own version:
- Set up a MongoDB instance (e.g., MongoDB Atlas).
- Push your repository to a platform like GitHub.
- Create a Render account and connect your repository.
- Configure environment variables on Render.
Feel free to fork this repository and submit pull requests. Contributions are welcome!
This project is licensed under the ISC License.