{"id":16222723,"url":"https://github.com/qur786/spyne-chat-backend","last_synced_at":"2025-04-08T01:41:01.761Z","repository":{"id":246620274,"uuid":"821525413","full_name":"qur786/spyne-chat-backend","owner":"qur786","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-29T07:00:34.000Z","size":74,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T12:14:51.389Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/qur786.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-06-28T18:36:29.000Z","updated_at":"2024-06-29T07:00:37.000Z","dependencies_parsed_at":"2024-06-29T06:34:36.585Z","dependency_job_id":"13ff9d57-b3f3-45b3-b1fc-dc07d32715b8","html_url":"https://github.com/qur786/spyne-chat-backend","commit_stats":null,"previous_names":["qur786/spyne-chat-backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qur786%2Fspyne-chat-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qur786%2Fspyne-chat-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qur786%2Fspyne-chat-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qur786%2Fspyne-chat-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qur786","download_url":"https://codeload.github.com/qur786/spyne-chat-backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222916929,"owners_count":17057483,"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":[],"created_at":"2024-10-10T12:15:01.555Z","updated_at":"2024-11-04T00:01:35.875Z","avatar_url":"https://github.com/qur786.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spyne Chat Backend\r\n\r\nThis project is a microservices-based application consisting of the following services:\r\n\r\n- **User Service**: Manages user data and operations.\r\n- **Auth Service**: Handles user authentication.\r\n- **Post Service**: Manages discussion posts and related operations.\r\n- **API Gateway**: Acts as a single entry point to the system.\r\n\r\n## Table of Contents\r\n\r\n1. [Installation and Setup](#installation-and-setup)\r\n2. [Low Level Design Document](#low-level-design-document)\r\n   - [Detailed Description of each Component](#detailed-description-of-each-component)\r\n   - [System Architecture Diagram](#system-architecture-diagram)\r\n3. [Database Schema](#database-schema)\r\n   - [Table/Collection Definitions and Relationships](#tablecollection-definitions-and-relationships)\r\n4. [API Documentation](#api-documentation)\r\n   - [Endpoint Definitions and Request/Response Formats](#endpoint-definitions-and-requestresponse-formats)\r\n\r\n## Installation and Setup\r\n\r\n### Prerequisites\r\n\r\n- Docker\r\n- Docker Compose\r\n\r\n### Steps to Run the Project\r\n\r\n1. **Clone the repository**\r\n\r\n   ```bash\r\n   git clone https://github.com/qur786/spyne-chat-backend.git\r\n   cd spyne-chat-backend\r\n   ```\r\n\r\n2. **Set up environment variables**\r\n   Create a `.env` file for each service (`user/.env`, `auth/.env`, `post/.env`) with the necessary environment variables. Credentials are [uploaded to this file](https://drive.google.com/file/d/1S3cBiuG3p1gpsMZsB9ow98HjAvooatKc/view?usp=drive_link), please download the file and create the necessary `.env` files in the respective folders as specified in the uploaded file and copy the values.\r\n\r\n3. **Build and run the services using Docker Compose**\r\n\r\n   ```bash\r\n   docker-compose up --build\r\n   ```\r\n\r\n4. **Access the services**\r\n   - API Gateway: `http://localhost:3000`\r\n   - User Service: `http://localhost:3001` or `http://localhost:3000/user`\r\n   - Auth Service: `http://localhost:3002` or `http://localhost:3000/auth`\r\n   - Post Service: `http://localhost:3003` or `http://localhost:3000/post`\r\n\r\n## Low Level Design Document\r\n\r\n### Detailed Description of each Component\r\n\r\n1. **API Gateway**\r\n\r\n   - Routes requests to the appropriate microservices.\r\n\r\n2. **Auth Service**\r\n\r\n   - Manages user authentication (signup, login, logout).\r\n   - Issues and validates JSON Web Tokens (JWTs).\r\n\r\n3. **User Service**\r\n\r\n   - Manages user data including creation, updating, deletion, and searching of users.\r\n   - Handles user-specific operations such as following other users.\r\n\r\n4. **Post Service**\r\n   - Manages discussion posts and related operations such as liking, commenting, and viewing posts.\r\n   - Handles post-specific operations such as updating and deleting posts and comments.\r\n\r\n### System Architecture Diagram\r\n\r\n```mermaid\r\ngraph TD\r\n\r\n    User --\u003e|Makes Requests| API[API Gateway]\r\n\r\n    API --\u003e|Forwards to| Auth[Auth Service]\r\n    API --\u003e|Forwards to| UserSvc[User Service]\r\n    API --\u003e|Forwards to| Discussion[Discussion Service]\r\n\r\n    subgraph Auth Service\r\n        Auth1[POST /auth/sign-up]\r\n        Auth2[POST /auth/login]\r\n        Auth3[POST /auth/logout]\r\n        Auth4[GET /auth/check-auth]\r\n        Auth --\u003e Auth1\r\n        Auth --\u003e Auth2\r\n        Auth --\u003e Auth3\r\n        Auth --\u003e Auth4\r\n    end\r\n\r\n    subgraph User Service\r\n        User1[POST /user]\r\n        User2[PATCH /user/:id]\r\n        User3[DELETE /user/:id]\r\n        User4[GET /user/:id]\r\n        User5[GET /user/list]\r\n        User6[GET /user/search]\r\n        User7[POST /user/follow/:id]\r\n        User8[POST /user/verify]\r\n        UserSvc --\u003e User1\r\n        UserSvc --\u003e User2\r\n        UserSvc --\u003e User3\r\n        UserSvc --\u003e User4\r\n        UserSvc --\u003e User5\r\n        UserSvc --\u003e User6\r\n        UserSvc --\u003e User7\r\n        UserSvc --\u003e User8\r\n    end\r\n\r\n    subgraph Discussion Service\r\n        Discussion1[POST /post/discussion]\r\n        Discussion2[PATCH /post/discussion/:id]\r\n        Discussion3[DELETE /post/discussion/:id]\r\n        Discussion4[GET /post/discussion/tags]\r\n        Discussion5[GET /post/discussion/search]\r\n        Discussion6[POST /post/discussion/:id/like]\r\n        Discussion7[POST /post/discussion/:id/comment]\r\n        Discussion8[POST /post/comment/:discussionId/:commentId/replies]\r\n        Discussion9[DELETE /post/comment/:commentId]\r\n        Discussion10[PATCH /post/comment/:commentId]\r\n        Discussion11[POST /post/discussion/:id/view]\r\n        Discussion12[GET /post/discussion/:id/viewCount]\r\n        Discussion13[POST /post/comment/:commentId/like]\r\n        Discussion --\u003e Discussion1\r\n        Discussion --\u003e Discussion2\r\n        Discussion --\u003e Discussion3\r\n        Discussion --\u003e Discussion4\r\n        Discussion --\u003e Discussion5\r\n        Discussion --\u003e Discussion6\r\n        Discussion --\u003e Discussion7\r\n        Discussion --\u003e Discussion8\r\n        Discussion --\u003e Discussion9\r\n        Discussion --\u003e Discussion10\r\n        Discussion --\u003e Discussion11\r\n        Discussion --\u003e Discussion12\r\n        Discussion --\u003e Discussion13\r\n    end\r\n\r\n    Discussion --\u003e|Validates with| Auth\r\n    Discussion --\u003e|Gets User Info from| UserSvc\r\n    UserSvc --\u003e|Validates with| Auth\r\n```\r\n\r\n## Database Schema\r\n\r\n### Table/Collection Definitions and Relationships\r\n\r\n1. **User Collection**\r\n\r\n   - `_id`: ObjectId\r\n   - `name`: String\r\n   - `mobile`: String\r\n   - `email`: String\r\n   - `password`: String\r\n   - `followers`: Array of ObjectId (References User)\r\n   - `createdAt`: Date\r\n   - `updatedAt`: Date\r\n\r\n2. **Discussion Collection**\r\n\r\n   - `_id`: ObjectId\r\n   - `title`: String\r\n   - `text`: String\r\n   - `imageUrl`: String\r\n   - `tags`: Array of Strings\r\n   - `createdBy`: ObjectId (References User)\r\n   - `likes`: Array of ObjectId (References User)\r\n   - `viewCount`: Number\r\n   - `comments`: Array of ObjectId (References Comment)\r\n   - `createdAt`: Date\r\n   - `updatedAt`: Date\r\n\r\n3. **Comment Collection**\r\n\r\n   - `_id`: ObjectId\r\n   - `text`: String\r\n   - `createdBy`: ObjectId (References User)\r\n   - `likes`: Array of ObjectId (References User)\r\n   - `replies`: Array of ObjectId (References Comment)\r\n   - `discussion`: ObjectId (References Discussion)\r\n   - `createdAt`: Date\r\n   - `updatedAt`: Date\r\n\r\n4. **Token Collection**\r\n\r\n   - `_id`: ObjectId\r\n   - `token`: String\r\n   - `createdAt`: Date\r\n   - `updatedAt`: Date\r\n\r\n## API Documentation\r\n\r\n- Postman collection containing all the request endpoint has been created and can be access via this [Public Postman Link](https://web.postman.co/workspace/My-Workspace~c43fc2ca-4773-43f3-8ed3-167a413647dc/collection/32835308-20b7ce1e-6968-40f4-9f93-8c826553440a).\r\n\r\n### Endpoint Definitions and Request/Response Formats\r\n\r\n#### Auth Service\r\n\r\n- **POST /auth/sign-up**\r\n\r\n  - Request: `{ \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"password\", \"followers\": [] }`\r\n  - Response: `{ \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n- **POST /auth/login**\r\n\r\n  - Request: `{ \"email\": \"user@example.com\", \"password\": \"password\" }`\r\n  - Response: `{ \"user\": { \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }, \"token\": \"jwt-token\" }`\r\n\r\n- **POST /auth/logout**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"message\": \"Logged out successfully\" }`\r\n\r\n- **GET /auth/check-auth**\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n#### User Service\r\n\r\n- **POST /user**\r\n\r\n  - Request: `{ \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"password\", \"followers\": [] }`\r\n  - Response: `{ \"user\": { \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" } }`\r\n\r\n- **PATCH /user/:id**\r\n\r\n  - Request: `{ \"username\": \"newuser\" }`\r\n  - Response: `{ \"user\": { \"_id\": \"user-id\", \"name\": \"newuser\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" } }`\r\n\r\n- **DELETE /user/:id**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n- **GET /user/:id**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }s`\r\n\r\n- **GET /user/list**\r\n\r\n  - Request: `{}`\r\n  - Response: `[{ \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }]`\r\n\r\n- **GET /user/search**\r\n\r\n  - Request: `{ \"query\": \"username\" }`\r\n  - Response: `{ \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n- **POST /users/follow/:id**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [\"new-user\"], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n- **POST /user/verify**\r\n  - Request: `{ \"email\": \"user@example.com\", \"token\": \"verification-token\" }`\r\n  - Response: `{ \"user\": { \"_id\": \"user-id\", \"name\": \"user\", \"mobile\": \"1234567890\", \"email\": \"user@example.com\", \"password\": \"hashed-password\", \"followers\": [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" } }`\r\n\r\n#### Discussion Service\r\n\r\n- **POST /post/discussion**\r\n\r\n  - Request: `{ \"title\": \"Discussion title\", \"text\": \"Discussion content\", \"tags\": [\"tag1\", \"tag2\"], \"imageUrl: \"#\" }`\r\n  - Response: `{ \"_id\": \"discussion-id\", \"title\": \"Discussion title\", \"text\": \"Discussion content\", imageUrl: \"#\", \"tags\": [\"tag1\", \"tag2\"], \"createdBy\": \"user-id\", likes: [], viewCount: 0, comments: [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\"  }`\r\n\r\n- **PATCH /post/discussion/:id**\r\n\r\n  - Request: `{ \"title\": \"New title\" }`\r\n  - Response: `{ \"_id\": \"discussion-id\", \"title\": \"New title\", \"text\": \"Discussion content\", imageUrl: \"#\", \"tags\": [\"tag1\", \"tag2\"], \"createdBy\": \"user-id\", likes: [], viewCount: 0, comments: [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\"  }`\r\n\r\n- **DELETE /post/discussion/:id**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"discussion-id\", \"title\": \"Discussion title\", \"text\": \"Discussion content\", imageUrl: \"#\", \"tags\": [\"tag1\", \"tag2\"], \"createdBy\": \"user-id\", likes: [], viewCount: 0, comments: [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\"  }`\r\n\r\n- **GET /post/discussion/tags**\r\n\r\n  - Request: `{ \"query\": { \"tags\": [\"tag1\", \"tag2\"] } }`\r\n  - Response: `{ \"_id\": \"discussion-id\", \"title\": \"Discussion title\", \"text\": \"Discussion content\", imageUrl: \"#\", \"tags\": [\"tag1\", \"tag2\"], \"createdBy\": \"user-id\", likes: [], viewCount: 0, comments: [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\"  }`\r\n\r\n- **GET /post/discussion/search**\r\n\r\n  - Request: `{ \"query\": { \"search\": \"search text\"} }`\r\n  - Response: `{ \"_id\": \"discussion-id\", \"title\": \"Discussion title\", \"text\": \"Discussion content\", imageUrl: \"#\", \"tags\": [\"tag1\", \"tag2\"], \"createdBy\": \"user-id\", likes: [], viewCount: 0, comments: [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\"  }`\r\n\r\n- **POST /post/discussion/:id/like**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"discussion-id\", \"title\": \"Discussion title\", \"text\": \"Discussion content\", imageUrl: \"#\", \"tags\": [\"tag1\", \"tag2\"], \"createdBy\": \"user-id\", likes: [\"user-id\"], viewCount: 0, comments: [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\"  }`\r\n\r\n- **POST /post/discussion/:id/comment**\r\n\r\n  - Request: `{ \"text\": \"Comment content\" }`\r\n  - Response: `{ \"_id\": \"discussion-id\", \"title\": \"Discussion title\", \"text\": \"Discussion content\", imageUrl: \"#\", \"tags\": [\"tag1\", \"tag2\"], \"createdBy\": \"user-id\", likes: [], viewCount: 0, comments: [comment-id], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\"  }`\r\n\r\n- **POST /post/comment/:discussionId/:commentId/replies**\r\n\r\n  - Request: `{ \"text\": \"Reply content\" }`\r\n  - Response: `{ \"_id\": \"comment-id\", \"text\": \"Reply content\", \"createdBy\": \"user-id\", \"likes\": [], \"replies\": [\"user-id\"], \"discussion\": \"discussion-id\", createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n- **DELETE /post/comment/:commentId**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"comment-id\", \"text\": \"Comment\", \"createdBy\": \"user-id\", \"likes\": [], \"replies\": [], \"discussion\": \"discussion-id\", createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n- **PATCH /post/comment/:commentId**\r\n\r\n  - Request: `{ \"text\": \"Updated comment content\" }`\r\n  - Response: `{ \"_id\": \"comment-id\", \"text\": \"Updated comment content\", \"createdBy\": \"user-id\", \"likes\": [], \"replies\": [], \"discussion\": \"discussion-id\", createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n- **POST /post/discussion/:id/view**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"discussion-id\", \"title\": \"Discussion title\", \"text\": \"Discussion content\", imageUrl: \"#\", \"tags\": [\"tag1\", \"tag2\"], \"createdBy\": \"user-id\", likes: [\"user-id\"], viewCount: 1, comments: [], createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\"  }`\r\n\r\n- **GET /post/discussion/:id/viewCount**\r\n\r\n  - Request: `{}`\r\n  - Response: `{ \"viewCount\": 1 }`\r\n\r\n- **POST /post/comment/:commentId/like**\r\n  - Request: `{}`\r\n  - Response: `{ \"_id\": \"comment-id\", \"text\": \"Comment\", \"createdBy\": \"user-id\", \"likes\": [\"user-id\"], \"replies\": [], \"discussion\": \"discussion-id\", createdAt: \"2022-02-26T16:37:48.244Z\", updatedAt: \"2022-02-26T16:37:48.244Z\" }`\r\n\r\n## Conclusion\r\n\r\nThis project demonstrates a microservices architecture with separate services for user management, authentication, and discussion handling. The API Gateway serves as the single entry point for all client requests, routing them to the appropriate microservices. The provided documentation covers installation, setup, design, database schema, and API endpoint definitions.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqur786%2Fspyne-chat-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqur786%2Fspyne-chat-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqur786%2Fspyne-chat-backend/lists"}