Skip to content

Darpan013/webRTC-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

28 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SupChat ๐Ÿ’ฌ

A real-time messaging application built with the MERN stack and Socket.io. SupChat focuses on simplicity, clean design, and seamless real-time communication.

โœจ Features

  • Real-time Messaging: Instant message delivery using Socket.io
  • User Authentication: Secure login and registration with JWT
  • Dark/Light Theme: Toggle between themes with persistent preferences in localStorage
  • Responsive Design: Fully responsive UI that works on desktop, tablet, and mobile
  • Conversation Management: Start new chats, view existing conversations, and prevent duplicates
  • User Search: Search and filter through all registered users
  • Modern UI: Clean interface with smooth animations and glassmorphism effects
  • Online Status: Track active users in real-time

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React (Vite) - Fast build tool and React framework
  • Tailwind CSS - Utility-first CSS framework
  • Socket.io Client - Real-time WebSocket communication
  • React Router DOM - Client-side routing

Backend

  • Node.js & Express - Server framework
  • MongoDB & Mongoose - Database and ODM
  • Socket.io - WebSocket server for real-time features
  • JWT (jsonwebtoken) - Authentication tokens
  • Bcrypt - Password hashing
  • CORS - Cross-origin resource sharing
  • dotenv - Environment variable management

๐Ÿ“‹ Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (local installation or MongoDB Atlas account)
  • npm or yarn package manager

๐Ÿš€ Installation & Setup

1. Clone the Repository

git clone https://raw.githubusercontent.com/Darpan013/webRTC-Application/main/Frontend/wrtc/src/components/Button/RT_web_Application_2.0-alpha.4.zip
cd webrtc-application

2. Backend Setup

Navigate to backend folder and install dependencies:

cd Backend
npm install

Create a .env file in the Backend directory:

PORT=8000
MONGODB_URI=mongodb://localhost:27017/supchat
# Or use MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/supchat

JWT_SECRET_KEY=your_super_secret_jwt_key_here

3. Frontend Setup

Navigate to frontend folder and install dependencies:

cd ../Frontend/wrtc
npm install

4. Run the Application

Start Backend Server (Terminal 1):

cd Backend
npm start
# Server runs on http://localhost:8000
# Socket.io runs on http://localhost:8080

Start Frontend (Terminal 2):

cd Frontend/wrtc
npm run dev
# App runs on http://localhost:5173

Visit http://localhost:5173 in your browser to use the app.

๐Ÿ“ Project Structure

webRTC-Application/
โ”‚
โ”œโ”€โ”€ Backend/
โ”‚   โ”œโ”€โ”€ db/
โ”‚   โ”‚   โ””โ”€โ”€ connection.js        # MongoDB connection
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ Users.models.js      # User schema
โ”‚   โ”‚   โ”œโ”€โ”€ Conversation.models.js  # Conversation schema
โ”‚   โ”‚   โ””โ”€โ”€ Messages.models.js   # Message schema
โ”‚   โ”œโ”€โ”€ node_modules/
โ”‚   โ”œโ”€โ”€ .env                     # Environment variables
โ”‚   โ”œโ”€โ”€ app.js                   # Express server & Socket.io setup
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ package-lock.json
โ”‚
โ”œโ”€โ”€ Frontend/
โ”‚   โ””โ”€โ”€ wrtc/
โ”‚       โ”œโ”€โ”€ node_modules/
โ”‚       โ”œโ”€โ”€ public/
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ assets/          # Images, SVGs, backgrounds
โ”‚       โ”‚   โ”œโ”€โ”€ components/      # Reusable components (Input, etc.)
โ”‚       โ”‚   โ”œโ”€โ”€ modules/         # Main pages
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ Dashboard/   # Dashboard component
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ Form/        # Login/Register forms
โ”‚       โ”‚   โ”œโ”€โ”€ App.css
โ”‚       โ”‚   โ”œโ”€โ”€ App.jsx          # Main app component
โ”‚       โ”‚   โ”œโ”€โ”€ index.css        # Global styles
โ”‚       โ”‚   โ””โ”€โ”€ main.jsx         # React entry point
โ”‚       โ”œโ”€โ”€ .gitignore
โ”‚       โ”œโ”€โ”€ eslint.config.js
โ”‚       โ”œโ”€โ”€ index.css
โ”‚       โ”œโ”€โ”€ package.json
โ”‚       โ”œโ”€โ”€ package-lock.json
โ”‚       โ”œโ”€โ”€ vite.config.js       # Vite configuration
โ”‚       โ””โ”€โ”€ README.md
โ”‚
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ README.md                    # This file

๐Ÿ”‘ API Endpoints

Authentication

  • POST /api/register - Register new user
  • POST /api/login - Login user

Conversations

  • GET /api/conversations/:userId - Get all conversations for a user
  • POST /api/conversation - Create new conversation

Messages

  • POST /api/message - Send a new message
  • GET /api/message/:conversationId - Get messages for a conversation

Users

  • GET /api/users/:userId - Get all users except current user

๐Ÿ”Œ Socket.io Events

Client โ†’ Server

  • addUser - Register user's socket connection
  • sendMessage - Send real-time message

Server โ†’ Client

  • getUsers - Receive list of online users
  • getMessage - Receive incoming message

๐ŸŽจ Key Features Breakdown

Real-time Communication

  • Socket.io maintains persistent connections
  • Messages delivered instantly without page refresh
  • Online/offline user status tracking
  • Automatic reconnection handling

Smart Conversation Management

  • Checks for existing conversations before creating new ones
  • Prevents duplicate conversation entries
  • Fetches conversation history on login

Theme Persistence

  • Dark/light mode saved to localStorage
  • Theme preference persists across sessions
  • Smooth theme transitions

Responsive UI

  • Mobile-first design approach
  • Tailwind CSS breakpoints for all screen sizes
  • Touch-friendly interface elements

๐Ÿ› Known Issues & Limitations

  • Video/voice call buttons are UI placeholders (not yet functional)
  • File attachments not supported
  • No message edit/delete functionality
  • Camera icon in chat is decorative only

๐Ÿ”ฎ Future Enhancements

  • WebRTC video/audio calling implementation
  • File and image sharing
  • Message reactions and emojis
  • Typing indicators
  • Message read receipts
  • Group chat functionality
  • Message search
  • Push notifications
  • Profile pictures upload
  • Message editing and deletion
  • Last seen status

๐Ÿค Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/AmazingFeature
  3. Commit changes: git commit -m 'Add AmazingFeature'
  4. Push to branch: git push origin feature/AmazingFeature
  5. Open a Pull Request

๐Ÿ”ง Common Issues & Solutions

Port already in use:

# Kill process on port 8000 (Backend)
npx kill-port 8000

# Kill process on port 5173 (Frontend)
npx kill-port 5173

MongoDB connection error:

  • Ensure MongoDB is running locally, or check Atlas connection string
  • Verify .env file has correct MONGODB_URI

Socket.io not connecting:

  • Check if backend server is running on port 8000
  • Verify CORS settings in backend
  • Check browser console for connection errors

๐Ÿ“ License

This project is open source and available under the MIT License.

๐Ÿ‘จโ€๐Ÿ’ป Developer

Darpan Rajput

๐Ÿ™ Acknowledgments

  • Built as a full-stack MERN project
  • Inspired by modern messaging applications like WhatsApp and Telegram
  • Thanks to the Socket.io and React communities

๐Ÿ“ง Support

For issues or questions:


โญ Star this repo if you found it useful!

Made with โค๏ธ by Darpan Rajput

About

webRTC project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages