{"id":18575609,"url":"https://github.com/jsiqbal/info-hub","last_synced_at":"2025-05-16T00:30:17.584Z","repository":{"id":214237228,"uuid":"736032734","full_name":"JsIqbal/info-hub","owner":"JsIqbal","description":"ShareTrip Node.js assignment","archived":false,"fork":false,"pushed_at":"2023-12-28T21:35:43.000Z","size":283,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-17T15:13:32.046Z","etag":null,"topics":["artillery","docker","docker-compose","expressjs","javascript","jest","makefile","module-pattern","mysql","nodejs","sequelize","supertest","swagger"],"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/JsIqbal.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":"2023-12-26T19:41:39.000Z","updated_at":"2024-08-20T02:00:00.000Z","dependencies_parsed_at":"2023-12-26T21:13:51.016Z","dependency_job_id":"5b979686-6b47-4a02-a781-4a622e482981","html_url":"https://github.com/JsIqbal/info-hub","commit_stats":null,"previous_names":["jsiqbal/info-hub"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JsIqbal%2Finfo-hub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JsIqbal%2Finfo-hub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JsIqbal%2Finfo-hub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JsIqbal%2Finfo-hub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JsIqbal","download_url":"https://codeload.github.com/JsIqbal/info-hub/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254447269,"owners_count":22072753,"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":["artillery","docker","docker-compose","expressjs","javascript","jest","makefile","module-pattern","mysql","nodejs","sequelize","supertest","swagger"],"created_at":"2024-11-06T23:20:38.399Z","updated_at":"2025-05-16T00:30:17.506Z","avatar_url":"https://github.com/JsIqbal.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ShareTrip Backend API\n\nThis project is a backend REST API designed to handle keyword searches on an external API and store the results in a database. It was created as part of the ShareTrip Node.js developer assessment test.\n\n## Table of Contents\n\n-   [Introduction](#introduction)\n-   [Technologies](#technologies)\n-   [Setup](#setup)\n-   [Usage](#usage)\n-   [Database Schema](#database-schema)\n-   [Example](#example)\n-   [Swagger Documentation](#swagger-documentation)\n-   [Testing](#testing)\n-   [Conclusion](#conclusion)\n\n## Introduction\n\nThe ShareTrip Backend API is a Node.js application built to handle user requests for keyword searches. Upon receiving a request, the API fetches data from an external API, performs keyword matching on the response, and stores the matching records in a database. The API then returns the search results to the user.\n\n### Endpoint\n\n-   `/api/search?keyword=\u003cuser_keyword\u003e`\n\n### Example\n\n-   User searches for mango: `localhost:3000/api/search?keyword=mango`\n\n## Technologies\n\n-   Node.js\n-   Express.js\n-   MySQL (database of choice)\n-   Sequelize (A promise-based Node.js ORM)\n-   Winston (for logging)\n-   Swagger (for API documentation)\n-   Docker (for containerization)\n-   Docker Compose(running multi-container Docker applications)\n-   Jest (test runner)\n-   Artillery (test runner)\n\n## Setup\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/JsIqbal/info-hub.git\n```\n\n2. Set up the environment variables:\n\n-   Know this: Environment variables values differ as per the configuration of the software.\n\n```.env\nPORT=3000\nDB_NAME=\u003cdatabase_name\u003e\nDB_HOST=\u003cdatabase_host\u003e\nDB_USER=\u003cdatabase_user\u003e\nDB_PASSWORD=\u003ccan be \"\" or password\u003e\nEXTERNAL_API=\u003cyour_external_api\u003e\n\n```\n\n3. Run in Terminal:\n\n```bash\nmake serve\n```\n\n-   you will see a choosing option.\n-   Either you can select 1 to run the project using docker or you can choose 2 to locally run the project. Instructions are given on the terminal.\n\n## Usage\n\n-   Make a GET request to the search endpoint:\n\n```link\nhttp://localhost:3000/search?keyword=ratione\n```\n\n-   example response if searh finds any contents:\n\n```json\n[\n    {\n        \"userId\": 2,\n        \"id\": 17,\n        \"title\": \"fugit voluptas sed molestias voluptatem provident\",\n        \"body\": \"eos voluptas et aut odit natus earum\\naspernatur fuga molestiae ullam\\ndeserunt ratione qui eos\\nqui nihil ratione nemo velit ut aut id quo\"\n    }\n]\n```\n\n## Database Schema\n\n-   The database schema is designed to capture user searches and matching blog posts. The basic schema includes fields such as timestamp, user ID, and references between tables for a one-to-many relationship.\n\n## Example\n\n-   Suppose a user searches for \"mango,\" and the external API returns the following posts:\n\n```json\n[\n    {\n        \"userId\": 10,\n        \"id\": 96,\n        \"title\": \"Orange is best\",\n        \"body\": \"Orange is of orange color\"\n    },\n    {\n        \"userId\": 10,\n        \"id\": 97,\n        \"title\": \"Best fruit\",\n        \"body\": \"Eat mango, mangoes are being sold on the local market\"\n    },\n    {\n        \"userId\": 10,\n        \"id\": 98,\n        \"title\": \"Mango juice\",\n        \"body\": \"Don’t like fruits? Try juice instead\"\n    }\n]\n```\n\n-   Matching posts with the keyword \"mango\" (id 97, 98) are stored in the database, and the API returns these blog posts as the response.\n\n## Swagger Documentation\n\n-   Swagger documentation for the API is available at:\n\n```link\nhttp://localhost:3000/api-docs\n```\n\nExplore the API endpoints and test requests using Swagger.\n\n## Testing\n\n-   The ShareTrip Backend API comes with a robust testing suite to ensure the reliability and correctness of its functionality.\n\n    -   The tests covers:\n        -   Integration test\n        -   Unit test\n        -   Artillery test\n\n### Running Integration \u0026 Unit tests:\n\n```bash\nnpm test\n```\n\n-   This command will trigger the Jest test runner, executing basic tests to ensure that the application starts without errors. It's a quick way to verify the initial configuration of the project.\n\n---\n\n### Running Artillery/load test:\n\n```bash\nnpm run test:load\n```\n\n-   This command will trigger the Artillery test runner, executing basic load tests to ensure that the application can handle concurrent users and traffic efficiently.\n\n## Conclusion\n\nThe ShareTrip Backend API is a robust Node.js application, efficiently managing keyword searches and database operations. Leveraging technologies like Express.js, Sequelize, and Docker, it ensures scalability and reliability. The well-documented README provides clear setup instructions, Swagger documentation, and comprehensive testing with Jest and Artillery.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsiqbal%2Finfo-hub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsiqbal%2Finfo-hub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsiqbal%2Finfo-hub/lists"}