A full-stack chat application built with the MERN stack (MongoDB, Express, React, Node.js) featuring real-time messaging, user authentication, and image sharing.
- ✅ User Authentication - Signup, login, and profile management
- ✅ Real-time Messaging - Instant messaging with Socket.io
- ✅ Online Status - See who's online in real-time
- ✅ Image Sharing - Send and receive images with Cloudinary integration
- ✅ Responsive Design - Works seamlessly on desktop and mobile
- ✅ Message History - Persistent message storage
- ✅ Search Users - Find users quickly with search functionality
- ✅ Profile Management - Update profile information and avatar
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database with Mongoose ODM
- Socket.io - Real-time communication
- JWT - Authentication tokens
- Cloudinary - Image storage and processing
- bcryptjs - Password hashing
- React 19 - UI library
- Vite - Build tool and dev server
- React Router - Client-side routing
- TailwindCSS - Utility-first CSS framework
- Axios - HTTP client
- Socket.io-client - Real-time client
- React Hot Toast - Notification system
- Node.js (v16 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn
git clone <repository-url>
cd Chat-appcd server
npm installcd client
npm installCreate a .env file in the server directory:
PORT=5000
MONGO_URI=mongodb://localhost:27017/chat_app_db
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
CLOUDINARY_API_KEY=your-cloudinary-api-key
CLOUDINARY_API_SECRET=your-cloudinary-api-secretThe .env file in the client directory is already configured:
VITE_API_URL=http://localhost:5000Make sure MongoDB is running on your machine:
# Start MongoDB service (varies by OS)
mongod- Create a free account at MongoDB Atlas
- Create a new cluster
- Get your connection string
- Update
MONGO_URIin your backend.envfile
- Create a free account at Cloudinary
- Get your Cloud Name, API Key, and API Secret from the dashboard
- Update the environment variables in your backend
.envfile
cd server
npm run serverThe backend will run on http://localhost:5000
cd client
npm run devThe frontend will run on http://localhost:5173
From the root directory, run both servers concurrently:
# Terminal 1 - Backend
cd server && npm run server
# Terminal 2 - Frontend
cd client && npm run dev-
Open the Application
- Navigate to
http://localhost:5173in your browser
- Navigate to
-
Create an Account
- Click "Create Account" on the login page
- Fill in your details (name, email, password, bio)
- Submit the form
-
Login
- Use your email and password to login
- You'll be redirected to the chat interface
-
Start Chatting
- Select a user from the sidebar to start chatting
- Type messages and press Enter or click send
- Share images using the gallery icon
- See online status indicators for active users
-
Manage Profile
- Click the menu icon and select "Edit Profile"
- Update your name, bio, and profile picture
- Changes are saved automatically
POST /api/auth/signup- Create a new user accountPOST /api/auth/login- Login with email and passwordGET /api/auth/check- Verify authentication statusPOST /api/auth/update-profile- Update user profile
GET /api/messages/users- Get all users for sidebarGET /api/messages/:id- Get messages with a specific userPOST /api/messages/send/:id- Send a message to a userPUT /api/messages/mark/:id- Mark message as seen
Chat-app/
├── server/
│ ├── controllers/ # Route controllers
│ ├── lib/ # Utility functions
│ ├── middleware/ # Custom middleware
│ ├── models/ # Database models
│ ├── routes/ # API routes
│ ├── server.js # Server entry point
│ └── package.json
├── client/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── context/ # React context providers
│ │ ├── lib/ # Utility functions
│ │ ├── pages/ # Page components
│ │ └── main.jsx # App entry point
│ ├── public/ # Static assets
│ └── package.json
└── README.md
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Ensure MongoDB is running on the specified port
- Check your MONGO_URI environment variable
- Verify network connectivity if using MongoDB Atlas
- Make sure both frontend and backend are running
- Check CORS configuration in the backend
- Verify the API_URL in frontend environment variables
- Verify Cloudinary credentials are correct
- Check image file size limits
- Ensure proper image format (PNG, JPEG)
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please:
- Check the common issues section above
- Review the code comments for additional context
- Create an issue in the repository with detailed information
Happy Chatting! 🚀