A real-time chat application built with the MERN stack (MongoDB, Express.js, React, Node.js) featuring Socket.io for real-time messaging, JWT authentication, and a responsive UI with TailwindCSS and DaisyUI.
Check out the deployed application: MERN Chat App
- 🔐 User Authentication with JWT (JSON Web Tokens)
- 💬 Real-time messaging with Socket.io
- 👥 Online user status indicators
- 🎨 Responsive UI with TailwindCSS and DaisyUI
- 🔍 Search functionality for conversations
- 🚀 Global state management with Zustand
- ⚡ Error handling on both client and server
- 🛡️ Protected routes and authorization
- Frontend: React, TailwindCSS, DaisyUI, Socket.io-client
- Backend: Node.js, Express.js, Socket.io
- Database: MongoDB with Mongoose ODM
- Authentication: JSON Web Tokens (JWT)
- Deployment: Render
- Clone the repository:
git clone https://github.com/leontoys/mern-chat-app.git
cd mern-chat-app- Install dependencies for both server and client:
npm run build- Set up environment variables:
- Create a
.envfile in the backend directory - Add your MongoDB connection string and JWT secret:
- Create a
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
- Start the development server:
npm run serverThe app will be running on http://localhost:5000 (backend) and the frontend will be served on http://localhost:3000 (if running React dev server separately).
npm run server- Start the backend server with nodemonnpm start- Start the backend server in production modenpm run build- Install all dependencies and build the frontend
mern-chat-app/
├── backend/
│ ├── controllers/ # Route controllers
│ ├── middleware/ # Custom middleware (auth, error handling)
│ ├── models/ # MongoDB models
│ ├── routes/ # API routes
│ ├── server.js # Express server setup
│ └── .env # Environment variables
└── frontend/
├── public/ # Static files
└── src/
├── components/ # React components
├── context/ # React context providers
├── hooks/ # Custom React hooks
├── store/ # Zustand store
└── App.js # Main React component
POST /api/auth/signup- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/messages/:id- Get messages for a conversationPOST /api/messages/send/:id- Send a messageGET /api/users- Get users for sidebar
This project was built following the tutorial by Codesistency: Build and Deploy a Complete Chat App with MERN Stack
The tutorial covers:
- Project setup and configuration
- Authentication system with JWT
- Real-time messaging with Socket.io
- Frontend UI development with React
- Deployment process
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License.
- Burak Orkmez for the original tutorial and codebase
- Socket.io for real-time communication
- TailwindCSS and DaisyUI for styling
If you found this project helpful, please give it a ⭐ on GitHub!