Connect instantly with friends and communities through our feature-rich real-time messaging platform
A modern, scalable real-time chat application built with the MERN stack, featuring instant messaging, file sharing, group chats, and advanced communication features for seamless user interactions.
- Real-time Messaging - Instant message delivery using Socket.IO
- Group Chats - Create and manage group conversations
- Private Messages - Secure one-on-one conversations
- Message History - Persistent chat history with pagination
- Typing Indicators - See when others are typing
- Online Status - Real-time user presence indicators
- File Sharing - Share images, documents, and media files
- Message Reactions - React to messages with emojis
- Message Search - Find messages across all conversations
- Push Notifications - Stay updated with desktop and mobile notifications
- Message Encryption - End-to-end encryption for secure communications
- Dark/Light Theme - Customizable UI themes
- User Authentication - Secure login/register with JWT
- Profile Management - Customizable user profiles with avatars
- Friend System - Add, remove, and manage contacts
- User Search - Find and connect with other users
- Blocking System - Block unwanted users
- React 18 - Modern React with hooks and concurrent features
- TypeScript - Type-safe JavaScript development
- Vite - Lightning-fast build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- Socket.IO Client - Real-time bidirectional communication
- React Router - Client-side routing
- Zustand - Lightweight state management
- React Hook Form - Performant forms with validation
- Framer Motion - Smooth animations and transitions
- Node.js - JavaScript runtime environment
- Express.js - Fast, unopinionated web framework
- MongoDB - NoSQL database for scalable data storage
- Mongoose - MongoDB object modeling for Node.js
- Socket.IO - Real-time engine for WebSocket connections
- JWT - JSON Web Tokens for authentication
- Bcrypt - Password hashing
- Multer - File upload handling
- Cloudinary - Cloud-based image and video management
- Node.js (v18 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/nrbnayon/talktalk.git cd talktalk -
Install backend dependencies
cd backend npm install -
Set up environment variables
cp .env.example .env
Configure your
.envfile:# Server Configuration PORT=5000 NODE_ENV=development # Database MONGODB_URI=mongodb://localhost:27017/chatapp # or MongoDB Atlas: mongodb+srv://username:password@cluster.mongodb.net/chatapp # JWT Secret JWT_SECRET=your-super-secret-jwt-key JWT_EXPIRES_IN=7d # Cloudinary (for file uploads) CLOUDINARY_CLOUD_NAME=your-cloud-name CLOUDINARY_API_KEY=your-api-key CLOUDINARY_API_SECRET=your-api-secret # CORS Origin (Frontend URL) CORS_ORIGIN=http://localhost:3000
-
Start the backend server
npm run dev # Server will run on http://localhost:5000
-
Install frontend dependencies
cd ../frontend npm install -
Set up environment variables
cp .env.example .env
Configure your
.envfile:VITE_API_URL=http://localhost:5000 VITE_SOCKET_URL=http://localhost:5000 VITE_APP_NAME=ChatApp
-
Start the frontend development server
npm run dev # Frontend will run on http://localhost:3000
realtime-chat-app/
βββ backend/ # Node.js/Express backend
β βββ controllers/ # Route controllers
β β βββ authController.js
β β βββ chatController.js
β β βββ messageController.js
β β βββ userController.js
β βββ middleware/ # Custom middleware
β β βββ auth.js
β β βββ upload.js
β β βββ validation.js
β βββ models/ # MongoDB models
β β βββ User.js
β β βββ Chat.js
β β βββ Message.js
β βββ routes/ # API routes
β β βββ auth.js
β β βββ chats.js
β β βββ messages.js
β β βββ users.js
β βββ socket/ # Socket.IO configuration
β β βββ socketHandler.js
β βββ utils/ # Utility functions
β β βββ cloudinary.js
β β βββ generateToken.js
β β βββ encryption.js
β βββ config/ # Configuration files
β β βββ database.js
β βββ server.js # Entry point
β
βββ frontend/ # React frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β β βββ Chat/
β β β β βββ ChatList.tsx
β β β β βββ ChatWindow.tsx
β β β β βββ MessageInput.tsx
β β β β βββ MessageBubble.tsx
β β β βββ Auth/
β β β β βββ LoginForm.tsx
β β β β βββ RegisterForm.tsx
β β β βββ Layout/
β β β β βββ Sidebar.tsx
β β β β βββ Header.tsx
β β β β βββ Layout.tsx
β β β βββ UI/ # Common UI components
β β β βββ Button.tsx
β β β βββ Modal.tsx
β β β βββ Avatar.tsx
β β βββ pages/ # Page components
β β β βββ Dashboard.tsx
β β β βββ Login.tsx
β β β βββ Register.tsx
β β β βββ Profile.tsx
β β βββ hooks/ # Custom React hooks
β β β βββ useSocket.ts
β β β βββ useAuth.ts
β β β βββ useChat.ts
β β βββ store/ # State management
β β β βββ authStore.ts
β β β βββ chatStore.ts
β β β βββ uiStore.ts
β β βββ services/ # API services
β β β βββ api.ts
β β β βββ authService.ts
β β β βββ chatService.ts
β β βββ types/ # TypeScript definitions
β β β βββ auth.ts
β β β βββ chat.ts
β β β βββ user.ts
β β βββ utils/ # Utility functions
β β β βββ formatTime.ts
β β β βββ encryption.ts
β β β βββ constants.ts
β β βββ styles/ # Global styles
β β βββ globals.css
β βββ public/ # Static assets
β βββ package.json
β
βββ README.md
βββ docker-compose.yml # Docker configuration
βββ .gitignore
POST /api/auth/register # User registration
POST /api/auth/login # User login
POST /api/auth/logout # User logout
GET /api/auth/me # Get current user
PUT /api/auth/profile # Update profile
GET /api/users # Get all users
GET /api/users/search # Search users
POST /api/users/friend # Send friend request
PUT /api/users/friend # Accept/decline friend request
DELETE /api/users/friend/:id # Remove friend
GET /api/chats # Get user's chats
POST /api/chats # Create new chat
GET /api/chats/:id # Get chat details
PUT /api/chats/:id # Update chat
DELETE /api/chats/:id # Delete chat
GET /api/messages/:chatId # Get chat messages
POST /api/messages # Send message
PUT /api/messages/:id # Edit message
DELETE /api/messages/:id # Delete message
POST /api/messages/upload # Upload file
// Connection
'join-room' // Join a chat room
'leave-room' // Leave a chat room
// Messaging
'send-message' // Send a new message
'edit-message' // Edit existing message
'delete-message' // Delete a message
'typing-start' // Start typing indicator
'typing-stop' // Stop typing indicator
// Status
'user-online' // User comes online
'user-offline' // User goes offline// Messaging
'new-message' // Receive new message
'message-edited' // Message was edited
'message-deleted' // Message was deleted
// Typing
'user-typing' // Someone is typing
'user-stopped-typing' // Someone stopped typing
// Status
'user-status' // User status update
'message-delivered' // Message delivery confirmation
'message-read' // Message read confirmationinterface ChatWindowProps {
chatId: string;
messages: Message[];
onSendMessage: (content: string) => void;
}interface MessageBubbleProps {
message: Message;
isOwnMessage: boolean;
onEdit?: (messageId: string, content: string) => void;
onDelete?: (messageId: string) => void;
}- JWT Authentication - Secure token-based authentication
- Password Hashing - Bcrypt for secure password storage
- Input Validation - Comprehensive request validation
- Rate Limiting - Prevent spam and abuse
- CORS Configuration - Secure cross-origin requests
- File Upload Security - Safe file handling and validation
- XSS Protection - Input sanitization and output encoding
npm run dev # Start development server with nodemon
npm run start # Start production server
npm run test # Run test suite
npm run lint # Run ESLint
npm run build # Build for productionnpm run dev # Start Vite development server
npm run build # Build for production
npm run preview # Preview production build
npm run test # Run Vitest tests
npm run lint # Run ESLint
npm run type-check # Run TypeScript compiler check-
Build and run with Docker Compose
docker-compose up --build
-
Environment variables for production
NODE_ENV=production MONGODB_URI=your-production-mongodb-uri CORS_ORIGIN=https://your-frontend-domain.com
-
Build the application
cd backend npm run build -
Deploy to platforms like:
- Heroku:
git push heroku main - Railway: Connect GitHub repository
- DigitalOcean: Use App Platform
- AWS: EC2 or Elastic Beanstalk
- Heroku:
-
Build the application
cd frontend npm run build -
Deploy to platforms like:
- Vercel:
vercel --prod - Netlify: Drag and drop
distfolder - AWS S3: Upload build files to S3 bucket
- GitHub Pages: Use GitHub Actions
- Vercel:
NODE_ENV=production
PORT=5000
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/chatapp
JWT_SECRET=your-super-secure-jwt-secret-for-production
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
CORS_ORIGIN=https://your-frontend-domain.comVITE_API_URL=https://your-backend-domain.com
VITE_SOCKET_URL=https://your-backend-domain.com
VITE_APP_NAME=ChatAppcd backend
npm run test
# Run specific test files
npm run test -- --grep "Auth"
npm run test -- --grep "Chat"cd frontend
npm run test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch- Database Indexing - Optimized MongoDB queries
- Connection Pooling - Efficient database connections
- Caching - Redis for session and data caching
- Compression - Gzip compression for responses
- Rate Limiting - Prevent excessive requests
- Code Splitting - Lazy loading of components
- Bundle Optimization - Tree shaking and minification
- Image Optimization - WebP format and lazy loading
- Memoization - React.memo for expensive components
- Virtual Scrolling - Efficient rendering of large lists
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Follow the existing code style
- Add tests for new features
- Update documentation as needed
- Commit your changes
git commit -m 'Add some amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- Use TypeScript for type safety
- Follow ESLint rules
- Write meaningful commit messages
- Add tests for new functionality
- Update README for significant changes
- API Documentation - Detailed API endpoint documentation
- Socket Events - Complete socket event reference
- Database Schema - MongoDB collection schemas
- Deployment Guide - Step-by-step deployment instructions
- MongoDB Connection: Ensure MongoDB is running and connection string is correct
- Port Conflicts: Change PORT in .env if 5000 is occupied
- JWT Errors: Check JWT_SECRET is set correctly
- API Connection: Verify VITE_API_URL matches backend URL
- Socket Connection: Check VITE_SOCKET_URL configuration
- Build Errors: Clear node_modules and reinstall dependencies
- Connection Failures: Check CORS configuration
- Message Delays: Verify WebSocket support
- Room Joining: Ensure proper authentication
This project is licensed under the MIT License - see the LICENSE file for details.
- Socket.IO for real-time communication
- MongoDB for flexible data storage
- React team for the amazing frontend library
- Express.js for the robust backend framework
- Tailwind CSS for utility-first styling
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Discord: Join our Discord community
- Email: support@chatapp.com
- Mobile Apps - React Native iOS and Android apps
- Video Calls - WebRTC integration for video chat
- Voice Messages - Audio message support
- Message Translation - Multi-language support
- Bot Integration - Chatbot and automation features
- Screen Sharing - Share screen during conversations
- Advanced Moderation - Admin tools and content filtering
- Custom Themes - User-customizable chat themes
Built with β€οΈ using the MERN Stack
β Star us on GitHub | π¦ Follow us on Twitter | π Visit our website