RealTalk is a secure, real-time chat application built with React, Node.js, WebSockets, and MySQL. It features private messaging, user authentication, friends system, local and persistent message storage, live online user tracking, and advanced features like typing indicators, message deletion, and profile management.
- Secure Authentication with JWT
- 9-digit numeric User ID and 4-digit PIN login system
- Protected Routes with token-based authentication
- Real-Time Private Messaging using WebSocket
- File & Media Sharing with support for images and documents
- Typing Indicators for real-time conversation feedback
- Message History - Previous conversations loaded automatically
- Message Deletion - Delete for yourself or for everyone
- Real-Time Notifications for new messages when not on chat page
- Friends System - Add, remove, and manage friends
- Friend Aliases - Set custom nicknames for friends
- Add Friends from Conversations - Convert chat participants to friends
- Friend Search - Find users by username to add as friends
- Online Status - See which friends are currently online
- Recent Chats - Quick access to recent conversations
- Start Chat by User ID - Direct messaging capability
- User Profiles - View and update profile information
- Profile Picture Upload - Custom profile pictures
- Responsive UI with modern, clean design
- Smart Message Storage - LocalStorage for online users, Database for offline storage
- React 19 with functional components and hooks
- React Router 7 for navigation
- Context API for WebSocket state management
- React Icons for UI icons
- Axios for HTTP requests
- LocalStorage for client-side data persistence
- Node.js with Express.js framework
- WebSocket (ws) for real-time communication
- MySQL database with raw SQL queries
- JWT for authentication
- Multer for file uploads
- Bcrypt for password hashing
- CORS for cross-origin requests
- MySQL with multiple tables:
users- User accounts and profilesfriends- Friends relationships with aliasesprivate_conversations- Chat conversationsprivate_messages- Message history with file support
- Node.js (v14 or higher) & npm
- MySQL (v8.0 or higher)
- Git
git clone https://github.com/hashim-i222478/ChatApp.git
cd ChatApp-
Create MySQL Database:
CREATE DATABASE chatapp; USE chatapp;
-
Run the SQL Scripts:
# Execute the SQL files in DataBase/ folder in this order: # 1. User.sql # 2. Friends.sql # 3. PrivateMessages.sql # 4. ChatMessages.sql (if using group chat features)
cd Backend
npm install
# Create .env file with your configuration:
# JWT_SECRET=your-jwt-secret-key
# DB_HOST=localhost
# DB_USER=root
# DB_PASSWORD=your-mysql-password
# DB_NAME=chatapp
# Start the main server (handles WebSocket + API)
node Server.js
# Start the profile server (handles profile updates)
node ProfileServer.jscd Frontend
npm install
npm start- Frontend: http://localhost:3000
- Main Backend API: http://localhost:8080
- Profile API: http://localhost:8081
/Frontend
/src
/Components # React components
Header.jsx # Navigation header
Home.jsx # Main dashboard
Login.jsx # User authentication
SignUp.jsx # User registration
PrivateChat.jsx # Private messaging interface
RecentChats.jsx # Chat history
FriendsList.jsx # Friends management
UpdateProfile.jsx # Profile editing
ViewProfile.jsx # Profile viewing
/Context # React Context providers
WebSocketContext.js
/Services # API and utility services
api.js # HTTP API calls
friendsStorage.js # Friends local storage
/Style # CSS stylesheets
App.js # Main app component
index.js # React entry point
/Backend
/Controllers # Business logic
ManageUsers.js # User authentication & management
Chats.js # Private messaging
friends.js # Friends system
profile.js # Profile management
/Routes # API routes
userRoutes.js # User-related endpoints
chatRoutes.js # Chat-related endpoints
friendsRoutes.js # Friends-related endpoints
/Middlewares # Express middlewares
authMiddleware.js # JWT authentication
/DataBase # SQL schema files
/uploads # File upload storage
Server.js # Main server + WebSocket
ProfileServer.js # Profile management server
wsServer.js # WebSocket server setup
db.js # MySQL connection pool
/DataBase # SQL scripts for database setup
User.sql
Friends.sql
PrivateMessages.sql
ChatMessages.sql
- User Registration: Users create accounts with unique usernames and 4-digit PINs
- Unique User IDs: System generates secure 9-digit numeric IDs for each user
- JWT Protection: All API routes and WebSocket connections are protected with JWT tokens
- Session Management: 3-hour token expiration with automatic logout on expiry
- WebSocket Connection: Persistent connection for instant message delivery
- Online Users Tracking: Real-time list of connected users
- Message Broadcasting: Instant delivery to online recipients
- Online Recipients: Messages stored in browser's
localStoragefor instant access - Offline Recipients: Messages saved to MySQL database for later delivery
- Message Synchronization: Database messages transferred to
localStorageon user login - Conversation History: Complete chat history preserved across sessions
- Media Upload: Support for images, documents, and other file types
- File Storage: Server-side file storage with secure URL generation
- File Types: Automatic file type detection and appropriate handling
- Add Friends: Search users by username and send friend requests
- Friend Aliases: Set custom nicknames for friends for easier identification
- Friend from Chat: Convert any chat participant into a friend directly from conversation
- Remove Friends: Clean friend removal with database and local storage sync
- Dual Storage: Friends stored in both MySQL database and browser's
localStorage - Fast Access: Local storage provides instant friend list access
- Sync on Login: Database friends synchronized to local storage on user authentication
- Real-time Updates: Friend list updates reflect immediately across all components
- Delete for Me: Removes message from current user's
localStorageonly - Delete for Everyone: Broadcasts deletion command to remove from all participants' storage
- Conversation Clearing: Option to clear entire conversation history
- Local Priority:
localStorageused as primary storage for active conversations - Database Backup: Offline messages and conversation history stored in MySQL
- Smart Loading: Previous conversations loaded automatically when chat is opened
- Message Notifications: Pop-up alerts for new messages when user is not on chat page
- Online Status: Visual indicators for friend online/offline status
- Typing Indicators: Real-time typing status in active conversations
- Unread Counters: Badge counts for unread messages in recent chats
- Profile Pictures: Upload and update custom profile pictures
- Username Updates: Change display names with real-time synchronization
- Profile Viewing: Dedicated profile pages for viewing user information
- Mobile Friendly: Optimized for mobile and tablet devices
- Modern UI: Clean, intuitive interface with React Icons
- Dark/Light Compatible: Flexible styling system
- Interactive Elements: Smooth animations and hover effects
- Register: Create account with username and 4-digit PIN
- Login: Use your generated 9-digit User ID and PIN
- Add Friends: Search for users and build your friend network
- Start Chatting: Begin conversations with friends or any user by ID
- Manage Profile: Upload pictures and customize your profile
- Friend Aliases: Use custom nicknames to easily identify friends
- File Sharing: Drag and drop files directly into chat conversations
- Quick Access: Use Recent Chats for fast access to ongoing conversations
- Notifications: Keep the app open in background for real-time message alerts
authenticate- WebSocket authentication with JWTprivate-message- Send private messagetyping-start- Start typing indicatortyping-stop- Stop typing indicatordelete-message- Delete message for everyone
private-message- Receive private messageonline-users- Updated online users listtyping-start- User started typingtyping-stop- User stopped typingmessage-deleted- Message deleted notificationprofile-updated- User profile updated
-
WebSocket Connection Failed
- Check if Server.js is running on port 8080
- Verify JWT token is valid and not expired
-
Database Connection Error
- Ensure MySQL server is running
- Check database credentials in .env file
- Verify database 'chatapp' exists
-
File Upload Issues
- Check uploads directory permissions
- Ensure multer middleware is configured correctly
- Verify file size limits
-
Friends Not Loading
- Clear browser's localStorage
- Check friends API endpoint connectivity
- Verify authentication token
- Group Chat - Multi-user conversations
- Message Reactions - Emoji reactions to messages
- Voice Messages - Audio message support
- Message Search - Search through chat history
- Theme Customization - Dark/light mode toggle
- Push Notifications - Browser push notifications
- Message Encryption - End-to-end encryption
- Video Calling - WebRTC video calls
- Redis Integration - Improved caching and session management
- Database Migrations - Automated database schema updates
- API Rate Limiting - Prevent API abuse
- Error Logging - Comprehensive error tracking
- Performance Optimization - Query optimization and caching
- Docker Support - Containerized deployment
- Unit Testing - Comprehensive test coverage
We welcome contributions to RealTalk! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow the existing code style and conventions
- Add comments for complex logic
- Test your changes thoroughly
- Update documentation if needed
- Ensure no breaking changes to existing functionality
- π Bug Fixes - Help identify and fix issues
- β¨ New Features - Implement planned enhancements
- π Documentation - Improve README and code documentation
- π¨ UI/UX - Enhance user interface and experience
- β‘ Performance - Optimize database queries and frontend performance
- Repository: GitHub - ChatApp
- Issues: Report Issues
- Developer: @hashim-i222478
For questions, suggestions, or support, please open an issue on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.
Built with β€οΈ using React, Node.js, and MySQL