Skip to content

A full-stack real-time chat application built with React and Node.js. Features include email OTP authentication, one-on-one messaging with media sharing, message reactions, online/offline status, WhatsApp-like status updates, and a modern responsive UI with dark/light mode. Real-time updates powered by Socket.io and secure authentication with JWT.

Notifications You must be signed in to change notification settings

Ui-Adiii/chat-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

49 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ Chat App

A full-stack real-time chat application built with React and Node.js, featuring instant messaging, media sharing, status updates, and more.

✨ Features

Authentication & User Management

  • Email-based OTP authentication
  • User profile management with profile pictures
  • Online/offline status tracking
  • Last seen functionality
  • User verification system

Messaging

  • Real-time messaging using Socket.io
  • One-on-one conversations
  • Message status tracking (sent, delivered, read)
  • Image and video sharing
  • Message timestamps

Status Feature

  • WhatsApp-like status updates
  • View and manage status posts

User Experience

  • Modern, responsive UI built with Tailwind CSS
  • Smooth animations with Framer Motion
  • Toast notifications
  • Dark/Light theme support
  • Real-time updates

πŸ› οΈ Tech Stack

Frontend

  • React 19.1.1 - UI library
  • Vite 7.1.7 - Build tool and dev server
  • React Router DOM 7.9.5 - Routing
  • Zustand 5.0.8 - State management
  • Tailwind CSS 4.1.17 - Styling
  • Radix UI - Accessible UI components
  • Framer Motion 12.23.24 - Animations
  • Socket.io Client - Real-time communication
  • Axios 1.13.2 - HTTP client
  • React Toastify 11.0.5 - Notifications

Backend

  • Node.js - Runtime environment
  • Express 5.1.0 - Web framework
  • Socket.io 4.8.1 - Real-time communication
  • MongoDB with Mongoose 8.19.2 - Database
  • JSON Web Token (JWT) 9.0.2 - Authentication
  • Nodemailer 7.0.10 - Email service (OTP)
  • Multer 2.0.2 - File upload handling
  • Cloudinary 2.8.0 - Image/video storage
  • ImageKit 6.0.0 - Image processing
  • Twilio 5.10.4 - SMS services (optional)
  • Express Rate Limit 8.2.1 - Rate limiting
  • CORS 2.8.5 - Cross-origin resource sharing
  • Cookie Parser 1.4.7 - Cookie handling

πŸ“ Project Structure

chat-app/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ config/          # Configuration files (Cloudinary, ImageKit)
β”‚   β”œβ”€β”€ controllers/     # Route controllers
β”‚   β”œβ”€β”€ db/             # Database connection
β”‚   β”œβ”€β”€ middlewares/    # Auth, upload, etc.
β”‚   β”œβ”€β”€ models/         # Mongoose models (User, Message, Conversation, Status)
β”‚   β”œβ”€β”€ routes/         # API routes
β”‚   β”œβ”€β”€ services/       # Socket.io service
β”‚   β”œβ”€β”€ utils/          # Utility functions
β”‚   └── server.js       # Entry point
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/         # Static assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/ # Reusable components
β”‚   β”‚   β”œβ”€β”€ pages/      # Page components
β”‚   β”‚   β”œβ”€β”€ routes/     # Route configuration
β”‚   β”‚   β”œβ”€β”€ services/   # API services
β”‚   β”‚   β”œβ”€β”€ store/      # Zustand stores
β”‚   β”‚   β”œβ”€β”€ utils/      # Utility functions
β”‚   β”œβ”€β”€ index.html
β”‚   └── vite.config.js
β”‚
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (local or cloud instance like MongoDB Atlas)
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd chat-app
  2. Install backend dependencies

    cd backend
    npm install
  3. Install frontend dependencies

    cd ../frontend
    npm install

Configuration

  1. Backend Environment Variables

    Create a .env file in the backend directory:

    PORT=8000
    MONGODB_URI=your_mongodb_connection_string
    JWT_SECRET=your_jwt_secret_key
    FRONTEND_URL=http://localhost:5173
    
    # Email Configuration (for OTP)
    EMAIL_HOST=smtp.gmail.com
    EMAIL_PORT=587
    EMAIL_USER=your_email@gmail.com
    EMAIL_PASS=your_email_password
    
    # Cloudinary Configuration
    CLOUDINARY_CLOUD_NAME=your_cloud_name
    CLOUDINARY_API_KEY=your_api_key
    CLOUDINARY_API_SECRET=your_api_secret
  2. Frontend Environment Variables

    Create a .env file in the frontend directory (if needed):

    VITE_API_URL=http://localhost:8000/api

Running the Application

  1. Start the backend server

    cd backend
    npm start

    The server will start on http://localhost:8000

  2. Start the frontend development server

    cd frontend
    npm run dev

    The frontend will be available at http://localhost:5173

πŸ“ API Endpoints

Authentication

  • POST /api/auth/send-otp - Send OTP to email
  • POST /api/auth/verify-otp - Verify OTP and login
  • PUT /api/auth/update-profile - Update user profile (requires auth)
  • GET /api/auth/logout - Logout user (requires auth)
  • GET /api/auth/check-auth - Check authentication status (requires auth)
  • GET /api/auth/get-all-users - Get all users (requires auth)

Messaging

  • GET /api/chat/conversations - Get all conversations (requires auth)
  • POST /api/chat/send-message - Send a message (requires auth)
  • GET /api/chat/messages/:conversationId - Get messages for a conversation (requires auth)

Status

  • GET /api/status - Get all statuses (requires auth)
  • POST /api/status - Create a new status (requires auth)
  • DELETE /api/status/:statusId - Delete a status (requires auth)

πŸ” Authentication

The app uses JWT (JSON Web Tokens) for authentication. After verifying the OTP, users receive a JWT token that is stored in HTTP-only cookies for security.

🎨 Features in Detail

Real-time Messaging

  • Instant message delivery using Socket.io
  • Message status updates (sent, delivered, read)
  • Typing indicators (if implemented)
  • Online/offline user presence

Media Sharing

  • Upload and share images
  • Upload and share videos
  • Media stored in Cloudinary/ImageKit
  • Optimized delivery

User Profiles

  • Customizable profile pictures
  • About/bio section
  • Online status indicator

πŸ§ͺ Development

Backend Scripts

  • npm start - Start the server with nodemon (auto-reload on changes)

Frontend Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run preview - Preview production build
  • npm run lint - Run ESLint

πŸ”’ Security Features

  • Rate limiting to prevent abuse
  • JWT-based authentication
  • HTTP-only cookies for token storage
  • CORS configuration
  • Input validation
  • Secure file upload handling

🚧 Future Enhancements

  • Group chat functionality
  • Message encryption
  • Push notifications
  • File sharing (documents, PDFs)
  • Message search
  • Chat backups
  • Read receipts

πŸ‘₯ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“§ Support

For support, email beingaditya198@gmail.com or create an issue in the repository.


Built with ❀️ using React and Node.js

About

A full-stack real-time chat application built with React and Node.js. Features include email OTP authentication, one-on-one messaging with media sharing, message reactions, online/offline status, WhatsApp-like status updates, and a modern responsive UI with dark/light mode. Real-time updates powered by Socket.io and secure authentication with JWT.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •