A Node.js/Express backend for a real-time chat application. This backend handles user authentication, chat rooms, message storage, file uploads, and real-time communication using Socket.io.
- Features
- Technologies Used
- Getting Started
- Installation
- Usage
- Frontend Repository
- Contributing
- License
- JWT-based user authentication
- Real-time messaging with Socket.io
- Group and private chats
- File uploads (avatars, PDFs)
- Password reset and email verification
- User and message management
- MongoDB database integration
- Node.js & Express: Backend framework
- Mongoose: MongoDB ODM
- Socket.io: Real-time communication
- JWT: Authentication
- Bcryptjs: Password hashing
- Nodemailer: Email sending
- Express-validator: Input validation
Ensure you have the following installed:
- Node.js (version 14 or higher)
- npm (Node package manager, comes with Node.js)
- MongoDB (local or cloud)
- Git
-
Clone the backend repository:
git clone https://github.com/mostafa2113/nodejs-chat.io.git
-
Navigate to the project directory:
cd nodejs-chat.io -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root directory and configure the following:
MONGO_URI=your_mongodb_connection_string
PORT=5000
NODE_ENV=development
SALT=your_salt_value
JWT_SECRET=your_jwt_secret
JWT_EXPIRE=30d
COOKIE_EXPIRE=30*24*60*60*1000
EMAIL_USER=your_email
EMAIL_PASS=your_email_password
RESET_TOKEN_EXPIRE=3600
CLIENT_URL=http://127.0.0.1:5173-
Run the backend::
npm run dev
-
The server will run on http://localhost:5000
To fully run the application, you need to set up the frontend. You can find the frontend repository and instructions here.
-
Fork the repo:
-
Create a new branch for your feature:
git checkout -b feature/YourFeatureName
-
Make your changes and commit them:
git add . git commit -m "Add your message here"
-
Push to your forked repository:
git push origin feature/YourFeatureName
-
Create a pull request
This project is licensed under the MIT License. See the LICENSE file for details.