{"id":18336635,"url":"https://github.com/mmintel/questionnaire-coding-challenge","last_synced_at":"2025-04-09T19:56:10.567Z","repository":{"id":92632699,"uuid":"344283065","full_name":"mmintel/questionnaire-coding-challenge","owner":"mmintel","description":null,"archived":false,"fork":false,"pushed_at":"2021-03-08T10:09:41.000Z","size":1365,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T19:56:03.553Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://mmintel.github.io/questionnaire-coding-challenge","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/mmintel.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":"2021-03-03T22:38:08.000Z","updated_at":"2021-03-08T10:09:44.000Z","dependencies_parsed_at":"2023-05-05T09:33:43.556Z","dependency_job_id":null,"html_url":"https://github.com/mmintel/questionnaire-coding-challenge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmintel%2Fquestionnaire-coding-challenge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmintel%2Fquestionnaire-coding-challenge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmintel%2Fquestionnaire-coding-challenge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmintel%2Fquestionnaire-coding-challenge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmintel","download_url":"https://codeload.github.com/mmintel/questionnaire-coding-challenge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103911,"owners_count":21048245,"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-11-05T20:08:26.923Z","updated_at":"2025-04-09T19:56:10.533Z","avatar_url":"https://github.com/mmintel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Task\nYou need to implement a questionnaire to recommend a user the best insurance plan for their situation. We prepared an API for you, you can find the documentation below.\n\nLet's split the task into the following sub-tasks:\n1. Collect the data from the user.\n2. Send the data to the API.\n3. Fetch the recommendation and display it to the user.\n\n## 1. Questionnaire \u0026 data collection\nAt first, we would need to collect the following information from the user, in the given order:\n- First name\n- Address\n- If they have any children (boolean)\n    - If yes → How many do they have?\n- Their occupation\n    - Employed\n    - Student\n    - Self-employed\n- Email address\n\nYour questionnaire will need to satisfy the following criteria:\n\n- Only one question per page.\n- Persistency. It should be possible to close the browser, then open it again and retrieve the previously entered information.\n\n## 2. Send the questionnaire to the API\n\nOnce completed, the questionnaire will be sent back to a backend service. This backend service will store the questionnaire respond with a [JWT](https://jwt.io), which can then be used to display recommendations.\n\n### Endpoint\n\n`POST` `/user` `Unauthenticated`\n\nRequest:\n```JSON\n{\n\t\"firstName\": \"Jane\",\n\t\"address\": \"Lohmühlenstraße 65\",\n\t\"numberOfChildren\": 2,\n\t\"occupation\": \"EMPLOYED\",\n\t\"email\": \"jane.doe@feather-insurance.com\"\n}\n```\n\nwhere `occupation` can have the following values: `EMPLOYED`, `SELF_EMPLOYED`, `STUDENT`.\n\nResponse:\n```JSON\n{\n\t\"jwt\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImphbmUuZG9lQGdldHBvcHN1cmUuY29tIiwiZmlyc3ROYW1lIjoiSmFuZSIsIm51bWJlck9mQ2hpbGRyZW4iOjIsIm9jY3VwYXRpb24iOiJFTVBMT1lFRCIsImFkZHJlc3MiOiJMb2htXHUwMGZjaGxlbnN0cmFcdTAwZGZlIDY1IiwiaWQiOiIyMDRjMDM5ZC1hOTA2LTQ3MTAtYjVkYi0zOTRmZmFiZmFhYzgifQ.TR5rPmcMItQHsFOgAtYto3XVO1IbXaHltsDJn7XIcJk\"\n}\n```\n\nExample Request:\n```\ncurl https://challenge-dot-popsure-204813.appspot.com/user \\\n-H 'Content-Type: application/json' \\\n-d '{\"firstName\":\"Jane\",\"address\":\"Lohmühlenstraße 65\",\"numberOfChildren\":2,\"occupation\":\"EMPLOYED\",\"email\":\"jane.doe@getpopsure.com\"}' \\\n-X POST\n```\n\n## 3. Fetch and display the recommendation\nAfter the user has been created you can now use the JWT to authenticate your requests. You need to store the token locally, and use it in a header:\n\n`Authorization: Bearer \u003ctoken\u003e`\n\nWith a valid token you should be able to fetch the recommendation tailored for the user:\n\n### Endpoint\n\n`GET` `/recommendation` `Authenticated`\n\n`/recommendation`\n\nResponse:\n\n```json\n[\n\t{\n\t\t\"type\": \"PRIVATE_LIABILITY\",\n\t\t\"price\": {\n\t    \t\"amount\": 4.3,\n\t\t\t\"periodicity\": \"MONTH\"\n\t\t}\n\t},\n\t{\n\t\t\"type\": \"HOME_CONTENT\",\n\t\t\"price\": {\n\t\t\t\"amount\": 103.32,\n\t\t\t\"periodicity\": \"YEAR\"\n\t\t}\n\t},\n\t{\n\t\t\"type\": \"HEALTH_INSURANCE\",\n\t\t\"price\": {\n\t\t\t\"amount\": 320.32,\n\t\t\t\"periodicity\": \"MONTH\"\n\t\t}\n\t}\n]\n```\n\n# Notes\n## Caveats\n* you can go back and forth using browser functionality, no validation happening here\n* data from localStorage is not validated and errors might occur when you change it manually\n\n## Future improvements\n* add loading states\n* you should add more types of questions and add better validation\n* you could use an AuthenticatedHttpService instead of passing the token\n* you could use Input and Output ports for use cases\n* make use of config or env vars\n* add more tests also integration tests\n* generate better testing data\n\n# Setup\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `yarn start`\n\nRuns the app in the development mode.\\\nOpen [http://localhost:3000](http://localhost:3000) to view it in the browser.\n\nThe page will reload if you make edits.\\\nYou will also see any lint errors in the console.\n\n### `yarn test`\n\nLaunches the test runner in the interactive watch mode.\\\nSee the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.\n\n### `yarn build`\n\nBuilds the app for production to the `build` folder.\\\nIt correctly bundles React in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.\\\nYour app is ready to be deployed!\n\nSee the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.\n\n### `yarn eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can’t go back!**\n\nIf you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.\n\nInstead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.\n\nYou don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.\n\n## Learn More\n\nYou can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).\n\nTo learn React, check out the [React documentation](https://reactjs.org/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmintel%2Fquestionnaire-coding-challenge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmintel%2Fquestionnaire-coding-challenge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmintel%2Fquestionnaire-coding-challenge/lists"}