{"id":20295639,"url":"https://github.com/sayeed1999/home","last_synced_at":"2025-07-07T19:32:58.651Z","repository":{"id":65587777,"uuid":"592723141","full_name":"sayeed1999/home","owner":"sayeed1999","description":"The monorepo contains unit microservices e.g home-service for sharing posts, chat-service for real-time dual/group chatting, auth-service, email-service, api-gateway for redirecting requests to appropriate services, bullmq as message bus, socket.io used for realtime data.","archived":false,"fork":false,"pushed_at":"2023-02-27T21:32:36.000Z","size":597,"stargazers_count":15,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T12:19:46.793Z","etag":null,"topics":["docker","message-queue","microservice","microservices","modular-architecture","mongodb","mysql","nodejs","onion-architecture","typescript","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/sayeed1999.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2023-01-24T11:50:18.000Z","updated_at":"2024-09-09T08:55:03.000Z","dependencies_parsed_at":"2024-11-14T15:48:43.300Z","dependency_job_id":null,"html_url":"https://github.com/sayeed1999/home","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sayeed1999/home","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayeed1999%2Fhome","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayeed1999%2Fhome/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayeed1999%2Fhome/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayeed1999%2Fhome/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sayeed1999","download_url":"https://codeload.github.com/sayeed1999/home/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayeed1999%2Fhome/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264138863,"owners_count":23563237,"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":["docker","message-queue","microservice","microservices","modular-architecture","mongodb","mysql","nodejs","onion-architecture","typescript","websocket"],"created_at":"2024-11-14T15:35:31.471Z","updated_at":"2025-07-07T19:32:58.568Z","avatar_url":"https://github.com/sayeed1999.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HOME\n\nThe monorepo project 'Home' will contain unit microservices targetting unit purposes e.g `api-gateway` for public access, `home-service` that acts like a facebook newsfeed, `chat-service` for dual or group conversation, `auth-service` for user authorization, ...\n\n## Design Patterns Used\n\n#### Observer Pattern: \nUsed in auth-service for notifying other services about user creation/update/deletion. There are methods named fanout_user_creation, fanout_user_update, fanout_user_deletion but the method itself doesn't know who are its subscribers. When the project is started, message queues are subscribed to the subscription from main program. And the subscriber services just gets notified.\n\n#### Provider Pattern:\nThis is not one of the 23 GoF patterns. But this is very useful when we centralize the access to all db tables or collections in our application. A application can have twenty models. But a single 'Provider' class contains all the database models or tables as its properties. So all the database models are centralized inside a single class. We can access any db models by creating an instance of the Provider class.\n\n#### Singleton Pattern:\nWhen creating the Provider class for accessing all db models, there is a chance that multiple instance of the Provider class may get created. So singleton pattern is used to ensure only one instance of the Provider class gets created and accessed by all end-users.\n\n#### Generic Repository Pattern:\nThis is also not one of the 23 GoF patterns. But this is extremely handy in reducing the number of duplicate methods accross classes since all classes needs common CRUD methods. A single class acting as the generic repository provides common CRUD methods to all other classes, and any service inheriting from the generic class gets access to all of its methods.\n\n## OVERALL STRUCTURE\n\n```\n./api-gateway\n  # the central service that client app will communicate with called the api gateway!!\n  # runs on localhost:4000\n\n./auth-service\n  # microservice for user authentication \u0026 authorization\n  # runs on localhost:4001\n  # server dependency: mysql\n\n./chat-service\n  # microservice for messenger-like chatting\n  # runs on localhost:4005\n  # server dependency: mongodb\n\n./ecom-service\n  # microservice for e-commerce or marketplace\n  # runs on localhost:4004\n  # server dependency: mysql\n\n./email-service\n  # microservice for mailing tasks\n  # runs on localhost:4003\n  # server dependency: nodemailer, mailtrap\n\n./home-service\n  # microservice for the virtual home where people will gather to share emotions \u0026 thoughts..\n  # runs on localhost:4002\n  # server dependency: mongodb\n```\n\n## How to run the project\n\nYou can run each microservice independently by `npm start` command.\n\n## EACH SERVICE FOLDER STRUCTURE\n\n#### Each module inside ./modules dir will follow \"Onion architecture\" which says controller layer shall hold request-response processing, service layer shall hold businesses and repository layer shall hold database queries. This way, one layer will be topped over the other layer like a sandwitch!\n\n```\nsrc\n│ app.js # App entry point\n└─── api # Express route controllers for all the endpoints of the app\n└───── routes\n└───── middlewares\n└─── config # Environment variables and configuration related stuff\n└─── jobs # Jobs definitions for agenda.js\n└─── loaders # Split the startup process into modules\n└─── models # Database models\n└─── modules\n└───── base\n└─────── controller\n└─────── service\n└─────── repository\n└───── \u003cmodule\u003e\n└─────── controller\n└─────── service\n└─────── repository\n└─── subscribers # Event handlers for async task\n└─── types # Type declaration files (d.ts) for Typescript\n└─── utils\n└───── constants\n└───── helpers\n```\n\n## Available endpoints through API Gateway\n\n#### Accessible endpoints to auth-service\n\nRegister an account:-\n\n```\nPOST /auth/register\nbody\n{\n  \"name\": \"Md. Sayeed Rahman\",\n  \"email\": \"test@gmail.com\",\n  \"password\": \"123456Aa$\"\n}\n```\n\nLogin an account:-\n\n```\nPOST /auth/login\nbody\n{\n  \"email\": \"test50@gmail.com\",\n  \"password\": \"123456Aa$\"\n}\n```\n\nGet current user:-\n\n```\nGET /auth/current-user\nheader: Authorization\n```\n\nUpdate current user:-\n\n```\nPATCH /auth/current-user\nheader: Authorization\n```\n\nDelete current user:-\n\n```\nDELETE /auth/current-user\nheader: Authorization\n```\n\n#### Accessible endpoints to home-service\n\nCreates a post:-\n\n```\nPOST /home/posts\nbody\n{\n  \"message\": \"this is a new post\"\n}\nheader: Authorization\n```\n\nUpdates a post:-\n\n```\nPATCH /home/posts/:id\nbody\n{\n  \"message\": \"this is a updated post\"\n}\nheader: Authorization\n```\n\nDeletes a post:-\n\n```\nDELETE /home/posts/:id\nheader: Authorization\n```\n\n\nGets all posts for admin:-\n\n```\ndescription: this will get all posts with comment ids only\nGET /home/posts\nheader: Authorization\n```\n\nGets all posts for user with top 03 comments:-\n\n```\ndescription: this will get all posts with top 03 comments embedded into it\nGET /home/posts/active-posts\nheader: Authorization\n```\n\nGets single post (for admin/user not worked on yet):-\n\n```\nGET /home/posts/:id\nheader: Authorization\n```\n\nCreates a comment:-\n\n```\nPOST /home/posts/:post_id/comments\nbody\n{\n  \"message\": \"this is a comment to a post\"\n}\nheader: Authorization\n```\n\n#### Accessible endpoints to chat-service\n\nGets all users for admin:-\n\n```\nGET /chat/users\nheader: Authorization\n```\n\nGets current user for user:-\n\n```\ndescripton: in microservice arch, every service should have own get current user(), because db different, user model different.\nGET /chat/users/current-user\nheader: Authorization\n```\n\nSends message to user in dual conversation:-\n\n```\nPOST /chat/conversations/dual/:user_id\nheader: Authorization\nbody\n{\n  \"text\": \"Hi ******\"\n}\n```\n\nGets conversation with user in dual conversation:-\n\n```\nGET /chat/conversations/dual/:user_id\nheader: Authorization\n```\n\nGets conversation list of current user:-\n\n```\nGET /chat/conversations/dual/conversation-list\nheader: Authorization\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayeed1999%2Fhome","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayeed1999%2Fhome","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayeed1999%2Fhome/lists"}