Skip to content

Latest commit

Β 

History

History
137 lines (116 loc) Β· 5.94 KB

File metadata and controls

137 lines (116 loc) Β· 5.94 KB

Chat Message App πŸš€

A feature-rich authentication via Google and GitHub OAuth, real-time chat application built using Node.js, Express, Socket.IO, MongoDB, and EJS for templating. The application supports real-time messaging, typing indicators, and persistent chat history.Additionally, it provides a user private-chat dashboard

🌟 Features

  • πŸ”’ User Registration and Login
    • Traditional email and password authentication using Passport.js.
  • 🌐 OAuth Integration
    • Google and GitHub authentication support.
  • πŸ“§ Forget Password Flow
    • Reset your password securely via email.
  • πŸ› οΈ Protected Private-Chat
    • Accessible only to authenticated users.
  • πŸ”— Real-Time Messaging
    • Send and receive messages instantly using Socket.io.
  • πŸ‘₯ User Management
    • View active users and their count.
  • πŸ“œ Persistent Chat History
    • Retrieve stored messages from the database.
  • ⌨️ Typing Indicators
    • Know when another user is typing.
  • πŸ–ΌοΈ User Profiles
    • Includes user avatars and display names.
  • πŸ“± Responsive Design
    • Built using EJS and Bootstrap for a modern, adaptive interface.

πŸš€ Tech Stack

Technology Description
πŸ“¦ NPM Dependency management
βš›οΈ EJS Templating engine
🟒 Node.js Backend runtime environment
⚑ Express.js Backend web framework
πŸ”‘ Passport.js Authentication middleware
βœ‰οΈ Nodemailer Email Service for password reset
⚑ Socket.IO Real-time communication
πŸ—„οΈ MongoDB NoSQL Database for user data

πŸš€ Installation and Setup

  1. Clone the repository:
    git clone https://github.com/ajaykumar2pp/Chat-APP-NodeJS
  2. Navigate to the project directory:
     cd chat-app-nodejs
  3. Install dependencies:
    npm install
  4. Set up environment variables:
    DATABASE_URL=mongodb+srv://<username>:<password>mongodb.net/USER_AUTH?retryWrites=true&w=majority
    JWT_SECRET=themyscret
    GOOGLE_CLIENT_ID=**6444762183-***************************.apps.googleusercontent.com
    GOOGLE_CLIENT_SECRET=GOCSPX-VGOKmLZdJx2oJ2WxON_***********
    EMAIL_USER=abc@gmail.com
    EMAIL_PASS=tsqp **** **** jeym
    GOOGLE_CALLBACK_URL=https://abc-coder-in.onrender.com/auth/google/callback
    GITHUB_CLIENT_ID=Ov23li8zO2Uw8c7******
    GITHUB_CLIENT_SECRET=ab882befa44617**********56695388fd7d1b07
    GITHUB_CALLBACK_URL=https://abc-coder-in.onrender.com/auth/github/callback
  5. Start the development server:
    npm start

πŸ“ Project Structure

Multi-Authentication/
src/
β”œβ”€β”€ config/                  # Configuration files
β”‚   └── db.config.js         # Database connection configuration
β”‚   └── nodemailer.js        # Email service setup
β”œβ”€β”€ controllers/             # Route controllers
β”‚   └── userController.js    # Controller for authentication-related logic
β”œβ”€β”€ middlewares/             # Custom middleware
β”‚   └── auth.middleware.js   # Middleware for authentication and authorization
β”œβ”€β”€ models/                  # Database models
β”‚   └── user.model.js        # User schema and model definition
β”œβ”€β”€ passport/                # Passport.js strategies
β”‚   └── passport.js          # Passport-Local, Google & GitHub strategies
β”œβ”€β”€ routes/                  # Application routes
β”‚   └── userRoutes.js        # Routes related to authentication
β”œβ”€β”€ views/                   # EJS templates
β”œβ”€β”€ .env.example             # Sample environment file
β”œβ”€β”€ index.js                 # Main entry point for the server
β”œβ”€β”€ package.json             # Project configuration
β”œβ”€β”€ README.md                # Documentation

🚦 API Endpoints

HTTP Method Endpoint Description
GET /register Displays the registration page.
POST /register Registers a new user.
GET /login Displays the login page.
POST /login Logs in the user.
GET /google Initiates Google OAuth.
GET /google/callback Google OAuth callback.
GET /github Initiates GitHub OAuth.
GET /github/callback GitHub OAuth callback.
GET /private-chat Private chat dashboard
GET /forget-password Displays the forget password page.
POST /forget-password Sends reset password email.
GET /check-email Prompts user to check email for reset link.
GET /reset-password/:token Displays the reset password page.
POST /reset-password/:token Resets the user password.
GET /success Displays success page.
GET /logout Logs the user out.

πŸ“· Screenshots

Chat-APP-12

πŸ›‘οΈ Security

  • Encrypted passwords using bcrypt πŸ”’.
  • Secure OAuth flows with Google and GitHub.
  • Environment variables stored securely with dotenv.

πŸ“ž Contact