{"id":15714521,"url":"https://github.com/ritulbhatnagar/multi-level-comment-system","last_synced_at":"2026-04-08T20:02:48.083Z","repository":{"id":253389249,"uuid":"843092712","full_name":"RitulBhatnagar/Multi-Level-Comment-System","owner":"RitulBhatnagar","description":"Multi-Level Comment System -\u003e The objective is to design and implement a set of API endpoints for a social media platform that handles multi-level comments on posts. ","archived":false,"fork":false,"pushed_at":"2024-08-17T04:18:47.000Z","size":133,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-24T13:49:44.423Z","etag":null,"topics":["aws-elastic-beanstalk","docker","expressjs","integration-testing","jest","neondb","nodejs","postgresql","prisma","typescript"],"latest_commit_sha":null,"homepage":"http://comment.us-east-1.elasticbeanstalk.com","language":"TypeScript","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/RitulBhatnagar.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-08-15T19:06:28.000Z","updated_at":"2024-08-17T05:14:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"21149952-1f67-4cb8-8084-a5a864f0e027","html_url":"https://github.com/RitulBhatnagar/Multi-Level-Comment-System","commit_stats":null,"previous_names":["ritulbhatnagar/multi-level-comment-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RitulBhatnagar/Multi-Level-Comment-System","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitulBhatnagar%2FMulti-Level-Comment-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitulBhatnagar%2FMulti-Level-Comment-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitulBhatnagar%2FMulti-Level-Comment-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitulBhatnagar%2FMulti-Level-Comment-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RitulBhatnagar","download_url":"https://codeload.github.com/RitulBhatnagar/Multi-Level-Comment-System/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitulBhatnagar%2FMulti-Level-Comment-System/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31571601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["aws-elastic-beanstalk","docker","expressjs","integration-testing","jest","neondb","nodejs","postgresql","prisma","typescript"],"created_at":"2024-10-03T21:37:47.290Z","updated_at":"2026-04-08T20:02:48.055Z","avatar_url":"https://github.com/RitulBhatnagar.png","language":"TypeScript","readme":"# Multi-Level Comment System API\r\n\r\nThis project implements a RESTful API for a social media platform that handles multi-level comments on posts. It allows users to create comments, reply to existing comments, and retrieve comments with pagination.\r\n\r\n## BASE URL FOR THIS PROJECT\r\n\r\n### The base URL for the API is:\r\n\r\n```\r\nhttp://comment.us-east-1.elasticbeanstalk.com\r\n```\r\n\r\n## Features\r\n\r\n- User authentication (registration and login)\r\n- Create post\r\n- Create comments on posts\r\n- Reply to existing comments\r\n- Retrieve comments with pagination and sorting\r\n- Rate limiting to prevent abuse\r\n\r\n## Setup\r\n\r\n1. Clone the repository:\r\n\r\n   ```\r\n   git clone https://github.com/your-username/multi-level-comment-system.git\r\n   cd multi-level-comment-system\r\n   ```\r\n\r\n2. Install dependencies:\r\n\r\n   ```\r\n   npm install\r\n   ```\r\n\r\n3. Set up environment variables:\r\n\r\n   - Copy `.env.example` to `.env` and update the variables:\r\n     ```\r\n     cp .env.example .env\r\n     ```\r\n   - Update the `DATABASE_URL` and other variables in `.env`\r\n\r\n4. Set up the database:\r\n\r\n   ```\r\n   npx prisma migrate dev\r\n   ```\r\n\r\n5. Start the server:\r\n   ```\r\n   npm run dev\r\n   ```\r\n\r\n## API Endpoints\r\n\r\n### Authentication\r\n\r\n- **Register a new user**\r\n\r\n  - **URL:** `POST /api/register`\r\n  - **Body:**\r\n\r\n    ```json\r\n    {\r\n      \"name\": \"string\",\r\n      \"email\": \"string\",\r\n      \"password\": \"string\"\r\n    }\r\n    ```\r\n\r\n  - **Success Response:**\r\n\r\n    - **Code:** 201 CREATED\r\n    - **Content:**\r\n\r\n      ```json\r\n      {\r\n        \"message\": \"User created successfully\",\r\n       \"registerUser\": {\r\n        \"id\": 74,\r\n        \"email\": \"ritul15@gmail.com\",\r\n        \"password\": \"$argon2id$v=19$m=65536,t=3,p=4$rOVB2oz2TWAWf/7Nhm2zlg$zIQxYbUX9KWSMHg14BO1rTAz6pvqIBFnbRR4PClFPLc\",\r\n        \"name\": \"Ritul\"\r\n        }\r\n      }\r\n      ```\r\n\r\n- **Login a user**\r\n\r\n  - **URL:** `POST /api/login`\r\n  - **Body:**\r\n\r\n    ```json\r\n    {\r\n      \"email\": \"string\",\r\n      \"password\": \"string\"\r\n    }\r\n    ```\r\n\r\n  - **Success Response:**\r\n\r\n    - **Code:** 200 OK\r\n    - **Content:**\r\n\r\n      ```json\r\n      {\r\n        \"message\": \"User logged in successfully\",\r\n        \"loginUser\": {\r\n           \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NzQsImlhdCI6MTcyMzg2NjUyMywiZXhwIjoxNzIzOTUyOTIzfQ.pCajvINQ5wXLsogRZxGVGbi2nbdGICNyJXYQz1tV6MQ\"\r\n        }\r\n      }\r\n      ```\r\n\r\n### Posts\r\n\r\n- **Create a new post**\r\n\r\n  - **URL:** `POST /api/post`\r\n  - **Headers:**\r\n\r\n    ```http\r\n    Authorization: Bearer [token]\r\n    ```\r\n\r\n  - **Body:**\r\n\r\n    ```json\r\n    {\r\n      \"content\": \"string\",\r\n      \"title\": \"string\"\r\n    }\r\n    ```\r\n\r\n  - **Success Response:**\r\n\r\n    - **Code:** 201 CREATED\r\n    - **Content:**\r\n\r\n      ```json\r\n      {\r\n        \"message\": \"Post created successfully\",\r\n        \"post\": {\r\n         \"id\": 42,\r\n        \"title\": \"Nothing\",\r\n        \"content\": \"there has to be some content\",\r\n        \"authorId\": 74\r\n        }\r\n      }\r\n      ```\r\n\r\n### Comments\r\n\r\n- **Create a new comment on a post**\r\n\r\n  - **URL:** `POST /api/posts/:postId/comments`\r\n  - **Headers:**\r\n\r\n    ```http\r\n    Authorization: Bearer [token]\r\n    ```\r\n\r\n  - **Body:**\r\n\r\n    ```json\r\n    {\r\n      \"text\": \"string\"\r\n    }\r\n    ```\r\n\r\n  - **Success Response:**\r\n\r\n    - **Code:** 201 CREATED\r\n    - **Content:**\r\n\r\n      ```json\r\n      {\r\n        \"message\": \"Comment created successfully\",\r\n        \"comment\": {\r\n          \"id\": 59,\r\n        \"text\": \"doing the comments and more comments and more\",\r\n        \"createdAt\": \"2024-08-17T04:17:39.813Z\",\r\n        \"postId\": 42,\r\n        \"authorId\": 75,\r\n        \"parentCommentId\": null\r\n        }\r\n      }\r\n      ```\r\n\r\n- **Reply to an existing comment**\r\n\r\n  - **URL:** `POST /api/posts/:postId/comments/:commentId/reply`\r\n  - **Headers:**\r\n\r\n    ```http\r\n    Authorization: Bearer [token]\r\n    ```\r\n\r\n  - **Body:**\r\n\r\n    ```json\r\n    {\r\n      \"text\": \"string\"\r\n    }\r\n    ```\r\n\r\n  - **Success Response:**\r\n\r\n    - **Code:** 201 CREATED\r\n    - **Content:**\r\n\r\n      ```json\r\n      {\r\n        \"message\": \"Reply created successfully\",\r\n        \"reply\": {\r\n          \"id\": 60,\r\n        \"text\": \"doing the replies\",\r\n        \"createdAt\": \"2024-08-17T04:17:52.308Z\",\r\n        \"postId\": 42,\r\n        \"authorId\": 74,\r\n        \"parentCommentId\": 50\r\n        }\r\n      }\r\n      ```\r\n\r\n- **Get comments for a post**\r\n\r\n  - **URL:** `GET /api/posts/:postId/comments`\r\n  - **Query Parameters:**\r\n\r\n    - `sortBy`: string (optional)\r\n    - `sortOrder`: \"asc\" | \"desc\" (optional)\r\n\r\n  - **Success Response:**\r\n\r\n    - **Code:** 200 OK\r\n    - **Content:**\r\n\r\n      ```json\r\n      {\r\n        \"message\": \"Comments retrieved successfully\",\r\n        \"comments\": [\r\n            {\r\n            \"id\": 50,\r\n            \"text\": \"doing the comments\",\r\n            \"createdAt\": \"2024-08-17T03:50:16.374Z\",\r\n            \"postId\": 42,\r\n            \"parentCommentId\": null,\r\n            \"replies\": [\r\n                {\r\n                    \"id\": 58,\r\n                    \"text\": \"doing the replies\",\r\n                    \"createdAt\": \"2024-08-17T03:53:19.651Z\"\r\n                },\r\n                {\r\n                    \"id\": 57,\r\n                    \"text\": \"doing the replies\",\r\n                    \"createdAt\": \"2024-08-17T03:53:17.980Z\"\r\n                }\r\n            ],\r\n            \"totalReplies\": 7\r\n        },\r\n        {\r\n            \"id\": 51,\r\n            \"text\": \"doing the comments and more comments\",\r\n            \"createdAt\": \"2024-08-17T03:50:30.663Z\",\r\n            \"postId\": 42,\r\n            \"parentCommentId\": null,\r\n            \"replies\": [],\r\n            \"totalReplies\": 0\r\n        }\r\n        ]\r\n      }\r\n      ```\r\n\r\n- **Expand parent-level comments**\r\n\r\n  - **URL:** `GET /api/posts/:postId/comments/:commentId/expand`\r\n  - **Query Parameters:**\r\n\r\n    - `page`: number\r\n    - `pageSize`: number\r\n\r\n  - **Success Response:**\r\n\r\n    - **Code:** 200 OK\r\n    - **Content:**\r\n\r\n      ```json\r\n      {\r\n        \"message\": \"Comments expanded successfully\",\r\n        \"comments\": [\r\n          {\r\n            \"id\": 58,\r\n            \"text\": \"doing the replies\",\r\n            \"createdAt\": \"2024-08-17T03:53:19.651Z\",\r\n            \"postId\": 42,\r\n            \"parentCommentId\": 50,\r\n            \"replies\": [],\r\n            \"totalReplies\": 0\r\n        },\r\n        {\r\n            \"id\": 57,\r\n            \"text\": \"doing the replies\",\r\n            \"createdAt\": \"2024-08-17T03:53:17.980Z\",\r\n            \"postId\": 42,\r\n            \"parentCommentId\": 50,\r\n            \"replies\": [],\r\n            \"totalReplies\": 0\r\n        },\r\n        {\r\n            \"id\": 56,\r\n            \"text\": \"doing the replies\",\r\n            \"createdAt\": \"2024-08-17T03:53:16.197Z\",\r\n            \"postId\": 42,\r\n            \"parentCommentId\": 50,\r\n            \"replies\": [],\r\n            \"totalReplies\": 0\r\n        }\r\n        ],\r\n         \"total\": 7,\r\n         \"page\": 1,\r\n         \"pageSize\": 3\r\n      }\r\n      ```\r\n\r\n## Error Responses\r\n\r\nAll endpoints may return the following error responses:\r\n\r\n- **Code:** 400 BAD REQUEST\r\n\r\n  ```json\r\n  {\r\n    \"message\": \"Error message describing the issue\"\r\n  }\r\n  ```\r\n\r\n- **Code:** 401 UNAUTHORIZED\r\n\r\n  ```json\r\n  {\r\n    \"message\": \"Authentication failed\"\r\n  }\r\n  ```\r\n\r\n- **Code:** 500 INTERNAL SERVER ERROR\r\n  ```json\r\n  {\r\n    \"message\": \"Internal server error message\"\r\n  }\r\n  ```\r\n\r\n## Testing\r\n\r\nTo run the tests:\r\n\r\n```\r\nnpm test\r\n```\r\n\r\nFor watching mode:\r\n\r\n```\r\nnpm run test:watch\r\n```\r\n\r\nFor test coverage:\r\n\r\n```\r\nnpm run test:coverage\r\n```\r\n\r\n## Rate Limiting\r\n\r\nThe API implements rate limiting to prevent abuse. Currently, users are limited to:\r\n\r\n- 10 comments per 15-minute window\r\n\r\n## Error Handling\r\n\r\nThe API uses custom error handling middleware. All errors are returned in a consistent format:\r\n\r\n```json\r\n{\r\n  \"message\": \"Error message\",\r\n  \"httpCode\": 400,\r\n  \"isOperational\": true\r\n}\r\n```\r\n\r\n## Architecture\r\n\r\nThe project follows a layered architecture:\r\n\r\n1. **Controllers**: Handle HTTP requests and responses\r\n2. **Services**: Contain business logic and interact with the database\r\n3. **Models**: Define data structures and database schema (using Prisma)\r\n4. **Middlewares**: Handle cross-cutting concerns like authentication and error handling\r\n\r\n## Database\r\n\r\nThe project uses PostgreSQL with Neon, a serverless PostgreSQL service. Prisma ORM is used for database operations, providing type-safe database access.\r\n\r\n## Authentication\r\n\r\nJSON Web Tokens (JWT) are used for user authentication. Protected routes require a valid JWT in the Authorization header.\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fritulbhatnagar%2Fmulti-level-comment-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fritulbhatnagar%2Fmulti-level-comment-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fritulbhatnagar%2Fmulti-level-comment-system/lists"}