{"id":14957041,"url":"https://github.com/learnwithfair/simple-chat-app-with-mern","last_synced_at":"2026-03-02T14:41:40.084Z","repository":{"id":236753772,"uuid":"793089995","full_name":"learnwithfair/simple-chat-app-with-mern","owner":"learnwithfair","description":"simple-chat-app-with-mern [learnwithfair, Learn with fair, Rahatul Rabbi, Md Rahatul Rabbi ,rahatulrabbi]","archived":false,"fork":false,"pushed_at":"2024-04-30T17:15:11.000Z","size":645,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T21:28:53.055Z","etag":null,"topics":["chat-app","chat-app-with-mern","chat-app-with-socket","learnwithfair","mern","mern-stack","node-js","rahatul-rabbi","rahatulrabbi","react-js","real-time-chat-app","socket-io"],"latest_commit_sha":null,"homepage":"","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/learnwithfair.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}},"created_at":"2024-04-28T11:54:28.000Z","updated_at":"2024-06-05T12:38:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"9774beaa-d01a-4e8c-b7ba-3752b35857cf","html_url":"https://github.com/learnwithfair/simple-chat-app-with-mern","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"6dccd3fda62ae3ba29607513d1a14a65f3a92815"},"previous_names":["learnwithfair/simple-chat-app-with-mern"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/learnwithfair/simple-chat-app-with-mern","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsimple-chat-app-with-mern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsimple-chat-app-with-mern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsimple-chat-app-with-mern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsimple-chat-app-with-mern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/learnwithfair","download_url":"https://codeload.github.com/learnwithfair/simple-chat-app-with-mern/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsimple-chat-app-with-mern/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265623294,"owners_count":23800137,"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":["chat-app","chat-app-with-mern","chat-app-with-socket","learnwithfair","mern","mern-stack","node-js","rahatul-rabbi","rahatulrabbi","react-js","real-time-chat-app","socket-io"],"created_at":"2024-09-24T13:13:59.839Z","updated_at":"2026-03-02T14:41:35.045Z","avatar_url":"https://github.com/learnwithfair.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## SIMPLE-REAL-TIME-CHAT-APP-WITH-MERN\n\nThanks for visiting my GitHub account!\n\n## Source Code (Download)\n\n[Click Here]()\n\n## Required Software (Download)\n\n- VS Code, Download -\u003ehttps://code.visualstudio.com/download\n- Node, Download-\u003e https://nodejs.org/en/download\n- MongoDB Shell(msi) , Download-\u003e https://www.mongodb.com/try/download/shell\n- MongoDB community (msi), download-\u003e(https://www.mongodb.com/try/download/community)\n- Postman (Optional), Download-\u003e https://www.postman.com/downloads/\n\n**Or Online Database (MongoDB Atlas)**\n\n- Register -\u003e https://www.mongodb.com/cloud/atlas/register\n\n## ========== Environment Setup ==========\n\n1. Install Node.js\n2. To verify installation into command form by node -v\n3. For initialization npm write the query in the command window as npm init -y\n4. Setup the opening file into the package.json and change the file with main:'server.js'\n5. To create a server using the express package then write a query into the command window as npm install express.\n   Write code in the server file for initialization\n   const express = require(\"express\");\n   const app = express();\n   app.listen(3000, () =\u003e {\n   console.log(\"Server is running at http://localhost:3000\");\n   });\n\n6. Install the nodemon package for automatically running the server as- npm i --save-dev nodemon (For Developing purpose)\n7. setup the package.json file in the scripts key, write\n\n```js\n \"scripts\": {\n \"start\": \"node ./resources/backend/server.js\",\n \"dev\": \"nodemon ./resources/backend/server.js\",\n \"test\": \"echo \\\"Error: no test specified\\\" \u0026\u0026 exit 1\"\n },\n```\n\n\\*\\* Run both server with one command,\n\n1. Run the command in the server directory\n\n```bash\n npm i concurrently\n```\n\n2. Setup the package.json file as-\u003e\n\n```js\n\"scripts\": {\n    \"server\": \"nodemon app.js\",\n    \"client\": \"npm start --prefix ../client\",\n    \"client-fix\": \"npm audit fix --force --prefix ./client\",\n    \"dev\": \"concurrently \\\" npm run server \\\" \\\" npm run client \\\"\"\n\n  },\n```\n\n8. use the Morgan package for automatic restart. Hence install the morgan package as npm install --save-dev morgan (Development purpose)\n   Write code in the server file for initialization\n   const morgan = require(\"morgan\");\n   app.use(morgan(\"dev\")); --\u003e Middlewire.\n9. Install Postman software for API testing by the URL endpoint.\n10. Install Mongobd + MongobdCompass and Mongoshell (For Database)\n\n## ========== Connect MongoDB Database ==========\n\n1. Install Mondodb + Mongodb Compass and Mongodb Shell download from the google.\n2. Set up Environment Variable in drive:c/program file\n3. Create a directory in the base path of the c drive named data. Inside the data directory create another folder db.\n4. Write the command in the CMD window as Mongod. And write the other command in the other CMD window as mongosh.\n5. Then Check the version as mongod --version and mongosh --version.\n6. Install mongoose package as npm i mongoose\n7. Create an atlas account. In the atlas account create a cluster that have a user(as atlas admin) and network access with any access IP address.\n8. Connect the database using URL from the atlas cluster or local Mongodb compass using the mongoose package as mongoose. connect('mongodb://localhost:27017/database-name);\n\n# Following tools are used to develop the application\n\n## Frontend Tools\n\n- React Js\n- socket.io-client\n\n## Backend Tools\n\n- Programming languages : JavaScript\n- Node Js\n- Frameworks : Express Js\n- Databases : MongoDB\n- Socket.io\n\n## How to run this project\n\n## Backend install\n\n### Run this command in root folder\n\n```js\ncd server\nnpm install --force\n\n```\n\n## Frontend install\n\n### Run this command in root folder\n\n```js\ncd client\nnpm install --force\n\n```\n\n## Run project\n\nStep-1: Run this command in server folder\n\n    ```js\n    npm run dev\n    ```\n\n**If application doesn't run**\n\nStep-2:\n\n1. Again run this command in client folder\n\n   ```js\n    npm audit fix --force\n   ```\n\n2. And run this command in server folder\n\n   ```js\n   npm audit fix --force\n   ```\n\n## Again Run project\n\n**Run this command in server folder**\n\n```js\n npm run dev\n```\n\n## How to create the react template?\n\n- clone to your local machine\n- npm install\n- npm start\n- Or, create and run react app with npx\n\n```js\n// create react app command\nnpx create-react-app appName\n\n// If any error occurs\nnpm install npm -g\n\n// run react app command\ncd appName\nnpm start\n```\n\n## Template Includes\n\n- React-js\n- Node-js\n- Express-js\n- MongoDB\n- Socket\n- axios\n\n## Project Overview\n\n\n|                                                                                                        |                                                                                                        |\n| :----------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------: |\n|                                                Sign-in                                                 |                                                Sign-Up                                                 |\n| ![singin](https://github.com/learnwithfair/simple-chat-app-with-mern/blob/main/screenshot/sign-in.png) | ![signup](https://github.com/learnwithfair/simple-chat-app-with-mern/blob/main/screenshot/sign-up.png) |\n\n|                                                                                                             |\n| :---------------------------------------------------------------------------------------------------------: |\n|                                                  Dashboard                                                  |\n| ![dashboard](https://github.com/learnwithfair/simple-chat-app-with-mern/blob/main/screenshot/dashboard.png) |\n\n## Necessary Code\n\n```bash\nconst express = require(\"express\"); // Create Express server\nconst morgan = require(\"morgan\"); // For automatically run server\nconst cookieParser = require(\"cookie-parser\"); // For set Cookie\nconst createError = require(\"http-errors\"); // For create HTTP Error\nconst xssClean = require(\"xss-clean\"); // For  Secure API\nconst bodyParser = require(\"body-parser\"); // For Get/ Set data into body\nconst cors = require(\"cors\"); // To set access for client-side URL\n```\n\n/_\n|--------------------------------------------------------------------------\n| Initialize Middleware\n|--------------------------------------------------------------------------\n_/\n\n```bash\napp.use(cookieParser()); // For set Cookie\napp.use(morgan(\"dev\")); // For automatically run server\napp.use(xssClean()); // For  Secure api\napp.use(bodyParser.json()); // For Set, Read data into the body and display JSON Format Text\napp.use(bodyParser.urlencoded({ extended: true })); // Get HTML Form Data\napp.use(setRefreshToken); // For set Refresh Token [Automatically call this middleware for all route]\n// To get access to Client side URL\napp.use(cors(\n {\n   origin: BASE_URL, // Frontend Base URL\n   credentials: true\n }\n));\napp.use(express.static(\"public\")); // To Display Server site image\n```\n\n/_\n|--------------------------------------------------------------------------\n| Socket IO\n|--------------------------------------------------------------------------\n_/\n\n```bash\nconst io = require(\"socket.io\")(8080, {\n cors: {\n   origin: BASE_URL\n },\n});\nio.on(\"connection\", (socket) =\u003e {\n console.log(\"User connected\", socket.id);\n\n setInterval(() =\u003e {\n   io.emit(\"refresh\", {});\n }, 500)\n\n // socket.on(\"disconnect\", function () {\n //   console.log(\"Disconnect\");\n\n // })\n\n});\n```\n\n## Follow Me\n\n\u003cimg src =\"https://www.edigitalagency.com.au/wp-content/uploads/Facebook-logo-blue-circle-large-transparent-png.png\" height=\"15px\" width=\"15px\"/\u003e [Facebook](http://facebook.com/learnwithfair), \u003cimg src =\"https://image.similarpng.com/very-thumbnail/2021/10/Youtube-icon-design-on-transparent-background-PNG.png\" height=\"20px\" width=\"20px\"/\u003e [Youtube](http://youtube.com/@learnwithfair), \u003cimg src =\"https://i.pinimg.com/originals/fa/ea/02/faea02f412415becfb4939d2b6431c28.jpg\" height=\"15px\" width=\"15px\"/\u003e [Instagram](http://instagram.com/learnwithfair)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearnwithfair%2Fsimple-chat-app-with-mern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flearnwithfair%2Fsimple-chat-app-with-mern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearnwithfair%2Fsimple-chat-app-with-mern/lists"}