{"id":26880572,"url":"https://github.com/mohit-nagaraj/wechat","last_synced_at":"2025-05-07T22:22:48.807Z","repository":{"id":252988436,"uuid":"842096122","full_name":"mohit-nagaraj/WeChat","owner":"mohit-nagaraj","description":"A real-time chat application (better features :D) using Socket.IO, Express, and MongoDB with HTTPS support. It manages user connections and messages securely.","archived":false,"fork":false,"pushed_at":"2024-12-20T07:52:58.000Z","size":305,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T14:52:26.790Z","etag":null,"topics":["aws","context-api","expressjs","github-actions","mongodb","nodejs","rest-api","socket-io","tailwindcss","vitejs"],"latest_commit_sha":null,"homepage":"https://we-chat-rho.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohit-nagaraj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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}},"created_at":"2024-08-13T17:00:17.000Z","updated_at":"2024-12-28T08:47:11.000Z","dependencies_parsed_at":"2024-08-13T21:17:48.881Z","dependency_job_id":"d2452ee4-77e7-4ee9-bedd-a0d0390af7e1","html_url":"https://github.com/mohit-nagaraj/WeChat","commit_stats":null,"previous_names":["mohit-nagaraj/wechat"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohit-nagaraj%2FWeChat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohit-nagaraj%2FWeChat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohit-nagaraj%2FWeChat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohit-nagaraj%2FWeChat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohit-nagaraj","download_url":"https://codeload.github.com/mohit-nagaraj/WeChat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252962860,"owners_count":21832411,"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","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":["aws","context-api","expressjs","github-actions","mongodb","nodejs","rest-api","socket-io","tailwindcss","vitejs"],"created_at":"2025-03-31T14:37:21.083Z","updated_at":"2025-05-07T22:22:48.780Z","avatar_url":"https://github.com/mohit-nagaraj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WeChat\nThis project is a real-time chat application built using Socket.IO, Express, and MongoDB with HTTPS support. It manages user connections and messages securely.\n\n## Features\n- Real-Time Communication: Utilizes Socket.IO for real-time, bidirectional communication between clients and server.\n- Secure Connections: HTTPS support with SSL certificates ensures secure data transmission.\n- User Management: Connects to MongoDB to store and manage online users.\n- Message Handling: Sends and receives messages between users in real-time.\n- CORS Support: Configured to allow cross-origin requests from a specified domain.\n\n\n### How It Works\n1. Server Initialization:\n    - An Express app is initialized.\n    - SSL certificates are read from the file system.\n    - An HTTPS server is created using the SSL certificates and the Express app.\n\n2. Socket.IO Setup:\n    - Socket.IO is initialized with CORS settings and attached to the HTTPS server.\n\n3. MongoDB Connection:\n    - Connects to a MongoDB database to store user information.\n    - Defines a schema and model for online users.\n\n4. Event Handling:\n    - Connection: When a new user connects, their socket ID is logged.\n    - Add New User: Adds a new user to the MongoDB database if they don't already exist and emits the list of online users.\n    - Disconnect: Removes the user from the MongoDB database when they disconnect and emits the updated list of online users.\n    - Message: Sends a message to the specified recipient if they are online.\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js\n- MongoDB\n- SSL certificates\n\n### Installation\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/mohit-nagaraj/WeChat.git\n    ```\n\n2. Install dependencies:\n    ```bash\n    npm install\n    ```\n\n3. Configure MongoDB connection in the code if necessary. Add the env variables as you can see from .env.example and put the `PORT`, `MONGO_URI`, `JWT_KEY` values\n\n4. Place your SSL certificates in the /ssl directory.\n\n### Running the Server\nStart the server:\nHere both the socket server \u0026 the express server should be started, they run as 2 separate servers.\n```bash\nnode index.js\n```\n\nThe server will start listening on port specified with HTTPS.\n\nLicense\nThis project is licensed under the MIT License. See the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohit-nagaraj%2Fwechat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohit-nagaraj%2Fwechat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohit-nagaraj%2Fwechat/lists"}