This is a real-time chat application built using Socket.io, Node.js, Express, and TypeScript. It allows users to join chat rooms, send messages, and see messages from other connected users in real-time.
- Real-time messaging: Messages are instantly sent and received without the need for page refresh.
- Multiple chat rooms: Users can join different chat rooms to have separate conversations.
- User typing indicator: Shows when a user is typing a message.
- User join/leave notifications: Notifies users when someone joins or leaves the chat room.
- Socket.io: Enables real-time bidirectional event-based communication between the server and clients.
- Node.js: A JavaScript runtime environment that allows running JavaScript code on the server.
- Express: A web application framework for Node.js that simplifies building web applications and APIs.
- TypeScript: A typed superset of JavaScript that compiles to plain JavaScript for better development experience and code maintainability.
-
Clone the repository:
git clone https://github.com/SanskarModi22/Chatopia.git
-
Navigate to the project directory:
cd chat-application
-
Install the dependencies:
npm install
-
Build the TypeScript code:
npm run build
-
Start the server:
npm start
-
Access the chat application in your web browser at
http://localhost:3000
.
- The default port for the server is
3000
. You can change it by modifying thePORT
variable in the.env
file.
- Open the chat application in your web browser.
- Enter your desired username and choose a chat room.
- Start sending messages in the chat room.
- You can see other users' messages in real-time and receive notifications when someone joins or leaves the chat room.
The main functionalities of the chat application are implemented as follows:
-
Server:
- The server code is written in Node.js using Express and TypeScript.
- The server handles incoming client connections and manages the chat rooms and messages.
- The server uses Socket.io to enable real-time communication between the clients and the server.
- The server listens for events such as "send chat message," "start," "set nick," "typing," and "not typing" to handle different user actions and emit corresponding events to all connected clients.
-
Client:
- The client-side code is responsible for rendering the chat interface and interacting with the server.
- The client-side code connects to the server using Socket.io and listens for events such as "chat message," "users list," "typing signal," and "info" to update the chat interface in real-time.
- The client-side code sends events such as "send chat message," "start," "set nick," "typing," and "not typing" to the server based on user actions.
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to submit a pull request or open an issue in the repository.
This project is licensed under the MIT License.
Feel free to customize and expand upon this README file to provide more specific instructions or additional information about your chat application based on your specific implementation.