{"id":17613918,"url":"https://github.com/marktopper/interflora","last_synced_at":"2025-03-30T00:13:05.386Z","repository":{"id":86929797,"uuid":"487930260","full_name":"marktopper/interflora","owner":"marktopper","description":null,"archived":false,"fork":false,"pushed_at":"2022-05-02T19:02:29.000Z","size":78,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T05:16:10.685Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/marktopper.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":"2022-05-02T17:23:07.000Z","updated_at":"2022-05-02T17:23:43.000Z","dependencies_parsed_at":"2023-05-29T20:45:26.103Z","dependency_job_id":null,"html_url":"https://github.com/marktopper/interflora","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/marktopper%2Finterflora","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marktopper%2Finterflora/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marktopper%2Finterflora/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marktopper%2Finterflora/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marktopper","download_url":"https://codeload.github.com/marktopper/interflora/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246258869,"owners_count":20748573,"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-22T18:15:01.621Z","updated_at":"2025-03-30T00:13:05.365Z","avatar_url":"https://github.com/marktopper.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://www.interflora.co.uk/images/logo.svg\" width=\"400\"\u003e\u003c/p\u003e\n\n# Exercice \n\nWe in Interflora Denmark, need to model how our company is structured so we can help our new employees have a better overview of our \ncompany structure.\n\nWe have our root node (only one, in our case the CEO) and several child nodes.\nEach of these nodes may have its own children. \n\nIt can be structured as something like this: \n```\n        root\n       /    \\\n      a      b\n      |\n      c\n    / \t\\\n   d     e\n```\n\n# Requirements\n\n- Laravel Valet\n- PHP 8.0\n- Composer\n- MySQL\n- SQLite (for automatic tests in memory)\n\n# Install\n\nUse Laravel Valet or similar with the public path to be `public/`.\n\nInstall composer dependencies.\n```shell\ncomposer install\n```\n\nCopy `.env.example` to `.env` and update the database credentials.\n\nMigrate and seed the database:\n```shell\nphp artisan migrate --seed\n```\n\n# API Documentation\n\n## Add a new node to the tree.\nRequest:\n```\ncurl --location --request POST '/api/nodes' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"name\": \"Awesome Node\",\n    \"parent_id\": 1,\n    \"programming_language\": \"php\",\n    \"department\": \"Development\"\n}'\n```\n\nResponse:\n```\n{\n    \"data\": {\n        \"id\": 2,\n        \"name\": \"Awesome Node\",\n        \"department\": \"Development\",\n        \"programming_language\": \"php\",\n        \"parent_id\": 1,\n        \"height\": 2,\n        \"children\": []\n    }\n}\n```\n\n## Get all child nodes of a given node from the tree. (Just 1 layer of children)\nRequest:\n```\ncurl --location --request GET '/api/nodes/1'\n```\n\nResponse:\n```\n{\n    \"data\": {\n        \"id\": 1,\n        \"name\": \"R00T\",\n        \"department\": null,\n        \"programming_language\": null,\n        \"parent_id\": 1,\n        \"height\": 0,\n        \"children\": [\n            {\n                \"id\": 2,\n                \"name\": \"a\",\n                \"department\": null,\n                \"programming_language\": null\n            },\n            {\n                \"id\": 3,\n                \"name\": \"b\",\n                \"department\": null,\n                \"programming_language\": null\n            }\n        ]\n    }\n}\n```\n\n## Change the parent node of a given node.\nRequest:\n```\ncurl --location --request PATCH '/api/nodes/3' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"parent_id\": 1\n}'\n```\n\nResponse:\n```\n{\n    \"data\": {\n        \"id\": 3,\n        \"name\": \"Awesome Node\",\n        \"department\": null,\n        \"programming_language\": null,\n        \"parent_id\": 1,\n        \"height\": 1,\n        \"children\": []\n    }\n}\n```\n\n# Testing\nThis application is fully automatic tested.\n\n```shell\n/vendor/bin/phpunit\n\nPHPUnit 9.5.20 #StandWithUkraine\n\n............                                                      12 / 12 (100%)\n\nTime: 00:00.273, Memory: 32.00 MB\n\nOK (12 tests, 22 assertions)\n```\n\n# Questions\n\n## Should the identifier be string-based?\nWe could easily convert the Node identifier to be string based in order to support the strings being like `root`, `a`,\n`b` and so on. That might make sense in this case, but I wouldn't overcomplicate this\nby during so if it wasn't intended.\n\n## Should Nodes have roles?\nFrom the description it sounds like there could be a use-case for roles, here including Developers and Managers\nto define their access to the additional `department` and `programming_language` field.\n\n## Only one root node?\nShould we make a limit to allow only one root node to exists?\n\n# Improve\n\nWhat would I improve if I had more time.\nI would clean-up the request classes and the tests even further.\nI would add some database indexes and query improvements.\nAdd cache for Node's for better performance.\nAdd pagination and other API enhancements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarktopper%2Finterflora","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarktopper%2Finterflora","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarktopper%2Finterflora/lists"}