Welcome to ChatVerse, a modern real-time chat application built with React.js and Socket.IO. Experience seamless group chatting with advanced features and a beautiful, responsive interface.
- Environment Configuration: Flexible environment variable handling with fallbacks
- CORS Support: Comprehensive CORS configuration for both Express and Socket.IO
- Error Handling: Robust error handling with global exception management
- User Management: Efficient user storage using Map for optimal performance
- Memory Management: Automatic cleanup of user data on disconnect
- Input Validation: Server-side validation for usernames and messages
- Sanitization: XSS protection through input sanitization
- Rate Limiting: Message length limits (500 characters) and username constraints
- Type Safety: Strict type checking for all inputs
- Health Check Endpoint: Status endpoint with connection metrics
- Comprehensive Logging: Detailed logging for connections, disconnections, and errors
- Connection Tracking: Real-time user count and connection monitoring
- Connection Status: Real-time connection indicator (π’ Connected / π΄ Disconnected)
- Error Handling: User-friendly error messages and connection alerts
- Loading States: Visual feedback during message sending and connection establishment
- Input Validation: Client-side validation with real-time feedback
- Responsive Design: Mobile-friendly interface with responsive breakpoints
- Socket Management: Proper socket cleanup and reconnection handling
- State Management: React state and sessionStorage for data persistence
- Memory Optimization: Optimized React hooks and socket listeners
- Efficient Rendering: Optimized message rendering with proper keys and timestamps
- ARIA Labels: Comprehensive screen reader support
- Semantic HTML: Proper semantic structure for better navigation
- Keyboard Navigation: Full keyboard accessibility support
- Focus Management: Proper focus indicators and management
- Message Timestamps: Display send time for all messages
- System Messages: Styled system notifications for user join/leave events
- Message Types: Distinguished styling for user messages vs system messages
- Auto-reconnection: Automatic reconnection with user state restoration
- Session Persistence: Username persistence across page refreshes
- React Best Practices: Proper use of hooks, useCallback, useRef
- Error Boundaries: Comprehensive error handling throughout the application
- Type Safety: Robust prop validation and type checking
- Code Organization: Clean component structure and separation of concerns
- Efficient Re-renders: Optimized React rendering with proper dependencies
- Socket Optimization: Advanced socket connection management
- CSS Architecture: Modern styling with responsive design principles
- Bundle Optimization: Clean imports and optimized code structure
- Node.js (v14 or higher)
- npm or yarn
cd backend
npm installCreate a .env file in the backend directory:
PORT=4501
FRONTEND_URL=https://chatverxe.netlify.appStart the backend server:
npm startcd frontend
npm installCreate a .env file in the frontend directory:
REACT_APP_BACKEND_URL=https://chatverse-xl8a.onrender.comStart the frontend application:
npm startFrontend: https://chatverxe.netlify.app
- Set environment variables:
PORT(will be set automatically by hosting provider)FRONTEND_URL=https://chatverxe.netlify.app
- Set environment variables:
REACT_APP_BACKEND_URL(your backend domain)
PORT: Server port (default: 4501)FRONTEND_URL: Frontend URL for CORS (default: https://chatverxe.netlify.app)TOXICITY_API_URL: Optional toxicity detection API endpoint
REACT_APP_BACKEND_URL: Backend API URL (default: https://chatverse-xl8a.onrender.com)
- β Real-time messaging with Socket.IO
- β User join/leave notifications
- β Connection status indicators
- β Message timestamps
- β Auto-reconnection on connection loss
- β Mobile-responsive design
- β Input validation and sanitization
- β Error handling and user feedback
- β Accessibility compliance
- β System message differentiation
- β Session persistence
- β Connection health monitoring
- π Toxicity detection integration
- π Message history persistence
- π User avatars
- π Private messaging
- π Room-based chat
Run tests for both frontend and backend:
# Backend
cd backend
npm test
# Frontend
cd frontend
npm testjoined: User joins the chatmessage: Send a messagedisconnect: User leaves the chat
welcome: Welcome message for new usersuserJoined: Notification when user joinsleave: Notification when user leavessendMessage: Broadcast message to all userserror: Error notifications
- Fork the repository
- Create a feature branch
- Make your changes with proper testing
- Submit a pull request with detailed description
This project is open source and available under the MIT License.
If you encounter any issues:
- Check the browser console for error messages
- Verify environment variables are set correctly
- Ensure both backend and frontend are running
- Check network connectivity for real-time features
ChatVerse is a powerful real-time chat application that combines the best of modern web technologies. Built with React.js for a dynamic frontend experience and Socket.IO for real-time communication, it offers a seamless and engaging chat environment.
The application features comprehensive error handling, input validation, accessibility compliance, and mobile responsiveness, making it suitable for users across all devices and platforms. Whether you're connecting with friends, family, or colleagues, ChatVerse provides a reliable and feature-rich chatting experience.