Skip to content

Repository files navigation

Real-Time Chat Application (Backend)

Build Status License

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.

Table of Contents

Features

  • 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

Technologies Used

  • 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

Getting Started

Prerequisites

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

Installation

  1. Clone the backend repository:

    git clone https://github.com/mostafa2113/nodejs-chat.io.git
  2. Navigate to the project directory:

    cd nodejs-chat.io
  3. Install dependencies:

    npm install
  4. Set up environment variables: Create a .env file 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

Usage

  1. Run the backend::

    npm run dev
  2. The server will run on http://localhost:5000

Frontend Repository

To fully run the application, you need to set up the frontend. You can find the frontend repository and instructions here.

Contributing

  1. Fork the repo:

  2. Create a new branch for your feature:

    git checkout -b feature/YourFeatureName
  3. Make your changes and commit them:

    git add .
    git commit -m "Add your message here"
  4. Push to your forked repository:

    git push origin feature/YourFeatureName
  5. Create a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages