ChatTea is a real-time chat application built using Node.js, Express.js, Socket.IO, and MongoDB. It allows users to join different chat rooms, send messages, and see who's online. This project is designed to demonstrate real-time communication with a focus on clarity and maintainability.
- Real-Time Chat: Instant message delivery using WebSockets.
- Multiple Chat Rooms: Users can join and switch between rooms.
- Usernames: Users can set a username to be displayed with messages.
- Announcements: System messages for users joining/leaving rooms.
- Persistent Messages: Stores all messages using MongoDB database.
- Admin Functionality
- Users can be promoted to admins, and admins can remove other users
- User Functionality
- Shows a list of all admins and users
- Displays a username in header
- User can delete their own messages
- Node.js: JavaScript runtime environment for server-side development.
- Express.js: A minimal and flexible Node.js web application framework.
- Socket.IO: Real-time, bidirectional, event-based communication library.
- MongoDB: NoSQL document database for storing messages, rooms, and users.
- JavaScript: For client-side logic and interactivity.
To run ChatTea locally, follow these steps:
-
Clone the Repository:
git clone https://github.com/OmarKHDR/ChatTea.git cd ChatTea -
Install Dependencies: Navigate to both the
clientandserverfolders and install dependencies using npm.cd backend npm install -
Set Up MongoDB:
-
Make sure you have MongoDB installed and running.
-
if not the local default uri for mongodb Create a
.envfile inside thebackendfolder and add the following, filling with your database URI:MONGO_URI=your_mongodb_connection_string
-
-
Start the Server: Navigate to the
backendfolder and start the server:npm run dev
This will start the server on port 5000 (default),
-
Start the Client: Navigate to the
backendfolder and start the client:npm run dev
-
Open in Browser: Open your web browser and go to
http://localhost:5000to view the application.
/api/user/username- returns a username if one is present in session
/api/room/list-rooms- returns a list of all rooms/api/room/list-members- returns a list of all members in a room/api/room/list-admins- returns a list of all admins in a room/api/room/room-session?roomName={roomName}- set the session's room name/api/room/add-member- adds current user to the room's list of members/api/room/remove-member?roomName={roomName}- removes the current user from the room's list of members
/api/message/all-messages- returns all messages from the current room in the session/api/message/add-message- adds a message to the database/api/message/delete-messages/- removes all messages from the current room in the session
username: Used to set the username of the current socketjoinRoom: Sent when a user joins a room (or switches rooms).message: Used to send message data between users.announcement: Sent when a user joins or leaves a room.rejoin: Sent to inform client that username was not present when a client requested to join a roommessage-failed: Informs client that the message they sent failed to send to server
Contributions are always welcome! If you have suggestions, bug reports, or want to contribute code, please:
- Fork the repository.
- Create a new branch for your feature or fix.
- Commit your changes.
- Push your branch to your forked repository.
- Submit a pull request.
This project is licensed under the MIT License.