Skip to content

This repository contains the backend for a real-time chat application built using Node.js, Express, MongoDB, and JWT-based authentication. It offers secure login, user management, real-time messaging support, and avatar uploads.

Notifications You must be signed in to change notification settings

Priyansu22382/Backend-ChatApplication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ Backend Chat Application

This repository contains the backend for a real-time chat application built using Node.js, Express, MongoDB, and JWT-based authentication. It offers secure login, user management, real-time messaging support, and avatar uploads.

πŸ“ Repository: Backend-ChatApplication


πŸš€ Tech Stack

  • βš™οΈ Node.js + Express – Server and routing
  • πŸ›’ MongoDB + Mongoose – NoSQL database with schema validation
  • πŸ” JWT + httpOnly Cookies – Secure authentication
  • ☁️ Cloudinary – For image/avatar uploads
  • πŸ§ͺ Middleware – For protecting routes and token verification

✨ Features

  • πŸ‘€ User registration, login, and logout
  • 🧾 JWT-based authentication via secure cookies
  • πŸ–ΌοΈ Profile update with avatar image (Cloudinary)
  • πŸ” Protected routes using custom middleware
  • πŸ’¬ Real-time messaging logic (text/image)
  • πŸ“¦ Scalable file structure

πŸ—‚οΈ Folder Structure

backend/ β”‚ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ controllers/ # Request handlers (auth, user, message) β”‚ β”œβ”€β”€ middlewares/ # JWT authentication middleware β”‚ β”œβ”€β”€ models/ # Mongoose schemas (User, Message) β”‚ β”œβ”€β”€ routes/ # API endpoints grouped by feature β”‚ β”œβ”€β”€ lib/ β”‚ β”‚ β”œβ”€β”€ db.js # MongoDB connection setup β”‚ β”‚ β”œβ”€β”€ cloudinary.js # Cloudinary configuration β”‚ β”‚ └── utils.js # Token generation & utilities β”‚ └── index.js # Main Express app entry point β”‚ β”œβ”€β”€ .env # Environment variables (Mongo URI, JWT, Cloudinary keys) β”œβ”€β”€ package.json # Dependencies and scripts └── README.md # Project documentation


πŸ”§ Installation & Setup

To run the server locally:

  1. Clone the repository

    git clone https://github.com/Priyansu22382/Backend-ChatApplication.git
    cd Backend-ChatApplication
    
  2. Install Dependencies npm install

  3. Create a .env file

    PORT=5001 MONGODB_URI=<your_mongo_uri> JWT_SECRET=<your_jwt_secret> CLOUDINARY_CLOUD_NAME=<your_cloud_name> CLOUDINARY_API_KEY=<your_api_key> CLOUDINARY_API_SECRET=<your_api_secret>

  4. Start The Server

    npm run dev

About

This repository contains the backend for a real-time chat application built using Node.js, Express, MongoDB, and JWT-based authentication. It offers secure login, user management, real-time messaging support, and avatar uploads.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published