amkr6207/chat-application

A modern, real-time chat app with **group chat** and **private messaging** built with React, Node.js, Express, MongoDB, and Socket.IO.

โ˜… 0Forks 0JavaScriptGitHub โ†—Compare

Project website โ†—

README

ChatHub ๐Ÿ’ฌ

A modern real-time chat application with group chat and private messaging.

๐Ÿš€ Live Links

Features

  • ๐Ÿ” JWT Authentication
  • ๐Ÿ’ฌ Real-time Group & Private Messaging
  • ๐Ÿ‘ฅ User List for Private Chats
  • ๐Ÿ“จ Message Persistence
  • ๐ŸŽจ Modern Responsive UI

Tech Stack

Backend: Node.js, Express, MongoDB, Socket.IO, JWT
Frontend: React 19, Vite, Socket.IO Client, Tailwind CSS

Quick Start

Prerequisites

  • Node.js (v14+)
  • MongoDB (local or Atlas)

Installation

  1. Clone and Install
# Backend
cd chat-app-backend
npm install
cp .env.example .env
# Edit .env with your MongoDB URI and JWT secret
npm start

# Frontend (in new terminal)
cd chat-app-frontend
npm install
npm run dev
  1. Environment Variables

Backend .env:

MONGO_URI=mongodb://localhost:27017/chatdb
JWT_SECRET=your_secret_key_here
PORT=5000

Frontend .env:

VITE_API_URL=http://localhost:5000
  1. Access

Usage

  1. Register a new account
  2. Login with your credentials
  3. Group Chat - Click "# Group Chat" in sidebar
  4. Private Chat - Click any username to start a private conversation
  5. Logout - Click the logout button

Project Structure

chat-app/
โ”œโ”€โ”€ chat-app-backend/       # Node.js + Express + Socket.IO
โ”‚   โ”œโ”€โ”€ models/             # MongoDB schemas (User, Message)
โ”‚   โ”œโ”€โ”€ routes/             # API routes (auth, chat)
โ”‚   โ”œโ”€โ”€ middleware/         # JWT authentication
โ”‚   โ””โ”€โ”€ index.js            # Server entry point
โ””โ”€โ”€ chat-app-frontend/      # React + Vite
    โ”œโ”€โ”€ src/components/     # UI components
    โ”œโ”€โ”€ src/api/            # API client
    โ””โ”€โ”€ src/App.jsx         # Main app component

API Endpoints

Method Endpoint Description
POST /api/auth/register Register user
POST /api/auth/login Login & get token
GET /api/auth/users Get all users
GET /api/chat/messages Fetch messages

License

MIT

Contributors

amkr6207

Issues