Welcome to ChatApp, a real-time chat application built with modern technologies including Socket.io, JWT, React, Node.js, and DaisyUI. This documentation will guide you through the setup, features, and usage of the ChatApp.
- Features
- Technologies Used
- Prerequisites
- Installation
- Configuration
- Running the Application
- API Endpoints
- Client-Side Usage
- License
- Real-Time Messaging: Instant messaging using Socket.io.
- JWT Authentication: Secure user authentication with JSON Web Tokens.
- User Online Status: Display online users in real-time.
- Notifications: In-built notifications for new messages.
- Responsive UI: Built with React and styled with DaisyUI.
- Backend:
- Node.js
- Express.js
- Socket.io
- MongoDB
- Mongoose
- JSON Web Token (JWT)
- Frontend:
- React
- DaisyUI
- Zustand (state management)
- Others:
- Webpack
- Babel
Before you begin, ensure you have met the following requirements:
- Node.js installed
- MongoDB installed and running
Follow these steps to set up the project locally:
-
Clone the repository:
git clone https://github.com/yourusername/chatapp.git cd chatapp
-
Install backend dependencies:
cd backend npm install
-
Install frontend dependencies:
cd ../fronted npm install
-
Backend Configuration:
- Create a
.env
file in theserver
directory and add the following:PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret
- Create a
-
Frontend Configuration:
- Update the API base URL in the frontend configuration file if necessary.
-
Start the backend server:
cd backend npm start
-
Start the frontend development server:
cd ../frontend npm start
-
Open your browser and navigate to
http://localhost:3000
.
- POST /api/auth/register: Register a new user.
- POST /api/auth/login: Login a user and receive a JWT.
- POST /api/messages/:id: Send a message to a specific user.
- GET /api/messages/:id: Retrieve messages for a conversation as an array.
- GET /api/users/online: Get a list of online users.
- useListenMessage: Custom hook to listen for incoming messages.
- useGetMessages: Custom hook to fetch messages for a conversation.
- Messages: Displays the list of messages in a conversation.
- Message: Individual message component.
- MessageSkeleton: Loading skeleton for messages.
- AuthContext: Provides authentication state and methods.
- SocketContext: Manages the socket server accross the users.
- DaisyUI: Used for responsive and modern UI components.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to reach out if you have any questions or need further assistance. Enjoy using ChatApp!