This is a full-stack chat application built with Node.js, Express, MongoDB, React, and Socket.IO.
- Real-time messaging with Socket.IO
- RESTful API for message handling
- MongoDB for data storage
- React frontend with Vite for fast development
Backend:
- Node.js
- Express
- MongoDB
- Socket.IO
Frontend:
- React
- Vite
- Socket.IO Client
-
Clone the repository:
git clone https://github.com/yourusername/chat-application.git cd chat-application/backend
-
Install dependencies:
npm install
-
Create a
.env
file:Copy the
.env.example
file to.env
and update the environment variables.cp .env.example .env
Update the
.env
file with your MongoDB URI and client URL:MONGO_URI=your_mongodb_uri CLIENT_URL=http://localhost:5173 PORT=5000
-
Start the backend server:
npm start
The backend server will run on
http://localhost:5000
.
-
Navigate to the frontend directory:
cd ../frontend
-
Install dependencies:
npm install
-
Start the frontend development server:
npm run dev
The frontend server will run on
http://localhost:5173
.
-
Open your browser:
Navigate to
http://localhost:5173
to use the chat application. -
Send messages:
You can send and receive messages in real-time.