SocketTalk is a modern, full-stack real-time chat application built with React, Node.js, Socket.IO, and MongoDB. It features a beautiful, responsive UI with multiple themes, real-time messaging, image sharing, and comprehensive user management.
- Frontend: https://sockettalk.vercel.app
- Backend: Deployed on Azure App Service (API endpoints available through frontend)
- Secure Signup/Login - JWT-based authentication with bcrypt password hashing
- Cross-Domain Authentication - Secure cookie handling for production deployment
- Input Validation - Comprehensive form validation using Zod schema
- Profile Management - Update profile pictures with Cloudinary integration
- Test Account - Quick demo access with predefined test credentials (
zoropy / zoro@123) - Protected Routes - Secure navigation with authentication middleware
- Session Management - Persistent login with HTTP-only cookies
- Instant Messaging - Real-time bidirectional communication using Socket.IO
- Online Status - Live user presence indicators
- Message History - Persistent chat history with MongoDB
- Real-time Updates - Messages appear instantly for both sender and receiver
- Auto-scroll - Smooth scrolling to latest messages
- Connection Management - Robust socket connection handling
- Image Upload - Share images directly in chat (up to 10MB)
- Image Preview - Preview images before sending
- Profile Pictures - Custom avatar upload with Cloudinary
- Base64 Processing - Optimized image handling
- 32+ Themes - Extensive theme collection powered by DaisyUI
- Theme Preview - Live theme switching with preview
- Responsive Design - Mobile-first, adaptive layout
- Modern UI - Clean, intuitive interface with Tailwind CSS
- Dark/Light Modes - Multiple color schemes
- User Discovery - Browse all registered users
- Online Filter - Show only online users
- Contact List - Organized sidebar with user status
- User Profiles - Detailed profile information
- Real-time Updates - Socket.IO for instant communication
- State Management - Zustand for efficient state handling
- Error Handling - Comprehensive error management with toast notifications
- Loading States - Skeleton loaders for better UX
- Form Validation - Client and server-side validation
- Secure Cookies - HTTP-only JWT cookies
- Frontend Deployment - Vercel with SPA routing configuration
- Backend Deployment - Azure App Service with Node.js runtime
- Environment Management - Separate development and production configurations
- Cross-Domain Setup - Proper CORS and cookie settings for production
- Static File Serving - Optimized asset delivery
- React 19 - Modern UI library with hooks
- Zustand - Lightweight state management
- React Router DOM - Client-side routing
- Socket.IO Client - Real-time communication
- Axios - HTTP client for API calls
- Tailwind CSS - Utility-first CSS framework
- DaisyUI - Beautiful component library
- Lucide React - Modern icon library
- React Hot Toast - Elegant notifications
- Vite - Fast build tool and dev server
- Node.js - JavaScript runtime environment
- Express.js - Fast, minimalist web framework
- Socket.IO - Real-time bidirectional communication
- MongoDB - NoSQL database with Mongoose ODM
- JWT - JSON Web Tokens for authentication
- bcryptjs - Password hashing
- Zod - TypeScript-first schema validation
- Cloudinary - Cloud-based image management
- Cookie Parser - Parse HTTP cookies
- CORS - Cross-origin resource sharing
- ESLint - Code linting and formatting
- Nodemon - Development server auto-restart
- dotenv - Environment variable management
- Vercel - Frontend hosting with SPA routing
- Azure App Service - Backend hosting with Node.js runtime
- Function-based CORS - Robust cross-origin handling
- Production Optimized - Environment-specific configurations
- Node.js 18+ and npm
- MongoDB database
- Cloudinary account (for image uploads)
-
Clone the repository
git clone https://github.com/yourusername/sockettalk.git cd sockettalk -
Install dependencies
# Install root dependencies npm install # Install backend dependencies cd backend && npm install # Install frontend dependencies cd ../frontend && npm install
-
Environment Setup
Create
.envfile in the backend directory:# Database MONGODB_URL=your_mongodb_connection_string # JWT JWT_SECRET=your_super_secret_jwt_key # Cloudinary (for image uploads) CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret # Server NODE_ENV=development PORT=5001
Create
.env.localfile in the frontend directory:# For development VITE_API_URL=http://localhost:5001 # For production, this will be automatically configured # to point to your deployed backend
-
Start Development Servers
Backend:
cd backend npm run devFrontend (in new terminal):
cd frontend npm run dev -
Access the Application
- Frontend: http://localhost:5173
- Backend API: http://localhost:5001
-
Create
vercel.jsonin frontend directory:{ "rewrites": [ { "source": "/(.*)", "destination": "/index.html" } ] } -
Deploy to Vercel:
cd frontend vercel --prod
-
Prepare for deployment:
cd backend # Remove problematic dependencies if any npm install --production
-
Configure CORS for production:
// In src/index.js and src/lib/socket.js app.use(cors({ origin: function (origin, callback) { const allowedOrigins = [ "http://localhost:5173", "https://your-frontend-app.vercel.app" ]; // Function-based validation for robust CORS }, credentials: true }))
-
Deploy to Azure:
- Connect your GitHub repository to Azure App Service
- Configure Node.js runtime in Azure portal
- Set environment variables in Azure Application Settings
- Update frontend environment to point to your Azure backend URL
- Development: Frontend connects to
http://localhost:5001 - Production: Frontend connects to your deployed Azure backend
- Cookies:
sameSite: "none", secure: truefor cross-domain authentication - CORS: Function-based origin validation for multiple domains
- Security: Environment variables and API URLs should be kept private
sockettalk/
βββ backend/
β βββ src/
β β βββ controllers/ # Route controllers
β β β βββ auth.controller.js
β β β βββ message.controller.js
β β β βββ user.controller.js
β β βββ lib/ # Utilities and configs
β β β βββ cloudinary.js
β β β βββ db.js
β β β βββ socket.js
β β β βββ utils/
β β βββ middleware/ # Express middleware
β β β βββ protectedRoute.middleware.js
β β β βββ validate.middleware.js
β β βββ models/ # MongoDB models
β β β βββ User.model.js
β β β βββ message.model.js
β β β βββ notification.model.js
β β βββ routes/ # API routes
β β β βββ auth.route.js
β β β βββ message.route.js
β β βββ zodSchema/ # Validation schemas
β β β βββ auth.zodSchema.js
β β βββ index.js # Server entry point
β βββ .env.example
β βββ package.json
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β β βββ skeletons/ # Loading components
β β β βββ ChatContainer.jsx
β β β βββ ChatHeader.jsx
β β β βββ MessageInput.jsx
β β β βββ Navbar.jsx
β β β βββ NoChatContent.jsx
β β β βββ SideBar.jsx
β β βββ constants/ # App constants
β β β βββ index.js
β β βββ lib/ # Utilities
β β β βββ axios.js
β β β βββ utils.js
β β βββ pages/ # Route pages
β β β βββ HomePage.jsx
β β β βββ ProfilePage.jsx
β β β βββ SettingPage.jsx
β β β βββ SignInPage.jsx
β β β βββ SignUpPage.jsx
β β β βββ NotFoundPage.jsx
β β βββ store/ # State management
β β β βββ useAuthStore.js
β β β βββ useChatStore.js
β β β βββ useThemeStore.js
β β βββ App.jsx
β β βββ main.jsx
β β βββ index.css
β βββ vercel.json # Vercel SPA routing config
β βββ package.json
β βββ vite.config.js
βββ package.json
βββ README.md
POST /api/auth/signup- User registrationPOST /api/auth/signin- User loginPOST /api/auth/logout- User logoutGET /api/auth/check- Check authentication statusPUT /api/auth/update-profile- Update user profileGET /api/auth/testaccount- Test account login
GET /api/message/users- Get all users for sidebarGET /api/message/:id- Get messages with specific userPOST /api/message/send/:id- Send message to user
SocketTalk includes 32+ beautiful themes:
- Light, Dark, Cupcake, Bumblebee
- Emerald, Corporate, Synthwave, Retro
- Cyberpunk, Valentine, Halloween, Garden
- Forest, Aqua, Lofi, Pastel, Fantasy
- Wireframe, Black, Luxury, Dracula
- CMYK, Autumn, Business, Acid
- Lemonade, Night, Coffee, Winter
- Dim, Nord, Sunset
- Instant message delivery using WebSocket connections
- Live user presence and online status
- Real-time typing indicators
- Persistent connection handling
- JWT authentication with HTTP-only cookies
- bcrypt password hashing with salt rounds
- Input validation and sanitization
- Protected API routes with middleware
- CORS configuration for cross-origin requests
- Responsive design for all device sizes
- Smooth animations and transitions
- Loading states and error handling
- Toast notifications for user feedback
- Intuitive navigation and routing
- Optimized image handling with Cloudinary
- Efficient state management with Zustand
- Code splitting and lazy loading
- Production-ready build optimization
- Socket connection management
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License.
Kartik Sharma - github
- React team for the amazing framework
- Socket.IO for real-time communication
- DaisyUI for beautiful UI components
- Cloudinary for image management
- MongoDB for reliable data storage
β Star this repo if you found it helpful!
π Found a bug? Open an issue!
π‘ Have a feature idea? Let's discuss it!
