{"id":30174078,"url":"https://github.com/natnaelbanjaw/chatapp","last_synced_at":"2026-05-18T15:05:46.732Z","repository":{"id":290623972,"uuid":"971226221","full_name":"natnaelbanjaw/chatApp","owner":"natnaelbanjaw","description":"Chat app","archived":false,"fork":false,"pushed_at":"2025-08-08T15:53:37.000Z","size":46,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-08T17:47:13.526Z","etag":null,"topics":["backend","chatapp","frontend","fullstack","nodejs"],"latest_commit_sha":null,"homepage":"https://chatapp-8hpb.onrender.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/natnaelbanjaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-23T07:46:43.000Z","updated_at":"2025-08-08T15:53:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"f72ea67a-cd92-4e08-b930-b58fbd4027d6","html_url":"https://github.com/natnaelbanjaw/chatApp","commit_stats":null,"previous_names":["natnaelbanjaw/chatapp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/natnaelbanjaw/chatApp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natnaelbanjaw%2FchatApp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natnaelbanjaw%2FchatApp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natnaelbanjaw%2FchatApp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natnaelbanjaw%2FchatApp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/natnaelbanjaw","download_url":"https://codeload.github.com/natnaelbanjaw/chatApp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natnaelbanjaw%2FchatApp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269977273,"owners_count":24506553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","chatapp","frontend","fullstack","nodejs"],"created_at":"2025-08-12T00:15:36.663Z","updated_at":"2026-05-18T15:05:46.680Z","avatar_url":"https://github.com/natnaelbanjaw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chat Application with WebSockets\n\nThis is a real-time chat application built using **Node.js**, **Express**, and **Socket.IO**. The application allows multiple users to connect, send messages, and see real-time updates such as typing feedback and the total number of connected clients.\n\n---\n\n## Features\n\n- **Real-Time Messaging**: Users can send and receive messages instantly.\n- **Typing Feedback**: Displays a \"user is typing\" message when someone is typing.\n- **Client Count**: Shows the total number of connected clients in real-time.\n- **Audio Notification**: Plays a sound when a new message is received.\n- **Responsive UI**: Messages are displayed in a chat-like interface with proper alignment for sent and received messages.\n\n---\n\n## Technologies Used\n\n- **Backend**:\n  - [Node.js](https://nodejs.org/): JavaScript runtime for the server.\n  - [Express](https://expressjs.com/): Web framework for serving static files and handling HTTP requests.\n  - [Socket.IO](https://socket.io/): Library for real-time, bidirectional communication between the server and clients.\n\n- **Frontend**:\n  - HTML, CSS, and JavaScript for the user interface.\n  - [Moment.js](https://momentjs.com/) (optional): For formatting timestamps.\n\n---\n\n## Project Structure\n\n```\nc:\\web-docs\\web development\\chat websocket\\\n├── app.js                  # Server-side code\n├── public\\                 # Static files served to the client\n│   ├── index.html          # Main HTML file\n│   ├── main.js             # Client-side JavaScript\n│   ├── styles.css          # Optional CSS for styling\n│   └── messageTone.mp3     # Audio file for message notifications\n```\n\n---\n\n## Installation and Setup\n\n### Prerequisites\n- [Node.js](https://nodejs.org/) installed on your machine.\n- A code editor like [Visual Studio Code](https://code.visualstudio.com/).\n\n### Steps\n1. Clone the repository or download the project files.\n2. Navigate to the project directory:\n   ```bash\n   cd \"c:\\web-docs\\web development\\chat websocket\"\n   ```\n3. Install the required dependencies:\n   ```bash\n   npm install\n   ```\n4. Start the server:\n   ```bash\n   node app.js\n   ```\n5. Open your browser and navigate to:\n   ```\n   http://localhost:4000\n   ```\n\n---\n\n## How It Works\n\n### Server-Side (`app.js`)\n1. The server uses **Express** to serve static files from the public directory.\n2. **Socket.IO** is initialized to handle WebSocket connections.\n3. When a client connects:\n   - The server logs the connection and updates the total client count.\n   - The server listens for events like `message` and `feedback` from the client.\n   - Messages are broadcast to all other connected clients.\n\n### Client-Side (`public/main.js`)\n1. The client connects to the server using **Socket.IO**.\n2. Users can type messages and send them via a form.\n3. The client listens for events like `chat-Message` and `feedback` to update the UI in real-time.\n4. Feedback messages are displayed when a user is typing.\n\n---\n\n## Key Files\n\n### app.js (Server-Side)\n- Handles WebSocket connections and events.\n- Emits real-time updates to all connected clients.\n- Example:\n  ```javascript\n  io.on('connection', (socket) =\u003e {\n      console.log('Client connected:', socket.id);\n      io.emit(\"clients-total\", socketsConnected.size);\n\n      socket.on(\"message\", (data) =\u003e {\n          socket.broadcast.emit(\"chat-Message\", data);\n      });\n\n      socket.on(\"feedback\", (data) =\u003e {\n          socket.broadcast.emit(\"feedback\", data);\n      });\n  });\n  ```\n\n### main.js (Client-Side)\n- Manages the UI and WebSocket communication.\n- Sends and receives events like `message` and `feedback`.\n- Example:\n  ```javascript\n  socket.on(\"chat-Message\", (data) =\u003e {\n      addMessagetoUI(false, data);\n  });\n\n  messageInput.addEventListener(\"focus\", () =\u003e {\n      socket.emit(\"feedback\", { feedback: `✍️ ${nameInput.value} is typing a message` });\n  });\n  ```\n\n---\n\n## Features in Detail\n\n### 1. Real-Time Messaging\n- Messages are sent using the `message` event.\n- The server broadcasts the message to all other clients.\n\n### 2. Typing Feedback\n- When a user types, a \"user is typing\" message is displayed to other clients.\n- This is handled using the `feedback` event.\n\n### 3. Client Count\n- The total number of connected clients is displayed in real-time.\n- This is updated whenever a client connects or disconnects.\n\n---\n\n## Future Improvements\n- Add user authentication for personalized chat sessions.\n- Store chat history in a database (e.g., MongoDB).\n- Enhance the UI with better styling and responsiveness.\n- Add support for private messaging between users.\n\n---\n\n## Troubleshooting\n\n### Common Issues\n1. **Socket.IO Not Connecting**:\n   - Ensure the server is running and accessible at `http://localhost:4000`.\n   - Check the browser console for WebSocket connection errors.\n\n2. **Feedback Not Displaying**:\n   - Verify that the `message-feedback` class is correctly applied to feedback messages.\n   - Ensure the `clearFeedback()` function is working as expected.\n\n3. **Moment.js Errors**:\n   - Include the Moment.js library in your `index.html` file if you're using it for date formatting.\n\n---\n\n## License\nThis project is open-source and available under the [MIT License](https://opensource.org/licenses/MIT).\n\n---\n\n## Acknowledgments\n- [Socket.IO Documentation](https://socket.io/docs/)\n- [Express Documentation](https://expressjs.com/)\n- [Moment.js Documentation](https://momentjs.com/docs/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatnaelbanjaw%2Fchatapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatnaelbanjaw%2Fchatapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatnaelbanjaw%2Fchatapp/lists"}