{"id":22712201,"url":"https://github.com/buildit/calculator-assignment","last_synced_at":"2026-02-07T12:31:58.232Z","repository":{"id":78235648,"uuid":"381711322","full_name":"buildit/calculator-assignment","owner":"buildit","description":null,"archived":false,"fork":false,"pushed_at":"2021-07-08T14:39:29.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-30T08:00:33.191Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/buildit.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-06-30T13:27:43.000Z","updated_at":"2021-07-08T14:39:32.000Z","dependencies_parsed_at":"2023-04-13T22:51:04.747Z","dependency_job_id":null,"html_url":"https://github.com/buildit/calculator-assignment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/buildit/calculator-assignment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildit%2Fcalculator-assignment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildit%2Fcalculator-assignment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildit%2Fcalculator-assignment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildit%2Fcalculator-assignment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buildit","download_url":"https://codeload.github.com/buildit/calculator-assignment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildit%2Fcalculator-assignment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29194019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":[],"created_at":"2024-12-10T13:09:39.395Z","updated_at":"2026-02-07T12:31:58.216Z","avatar_url":"https://github.com/buildit.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Assignment\n\nThe task is to build a Calculator Manager service.\nThe service should have three endpoints as described in the [openapi spec](spec.yml) in this project.\n\nThe service allows a client to execute calculations.\nYour service will not need to implement the calculation itself, for this a calculator service is provided via a docker image.\nYour service will use the calculator and will aggregate results per day.\n\nPlease host your completed example at a publically available git URL -- you can use a public GitHub repository for this.\n\n## Calculator Service\nThis service is provided to you via a docker image. It has only one endpoint which is described [here](calculator-service.yml).\n\nThe docker image is pubically available on Docker Hub as `gillius/buildit-calculator-service`. The service runs on port 8080 internally, but it should be exposed on the host as port 8888 to be consistent with the graded environment (`-p 8888:8080`). If you are running the service correctly, the following links should work:\n\n- UI: http://localhost:8888/swagger-ui.html\n- OpenAPI spec: http://localhost:8888/v3/api-docs\n\n### the calculate endpoint\n\nThis `calculate` endpoint receives as input for the calculation an object with two properties:\n- `category` which indicates how the calculator needs to process\n- `value` the start value for the calculation\n\nThe services then calculates an `index` for the given input which is the value we are interested in.\n\nHere a sample request:\n```json\n{\n    \"category\" : \"cat-77\",\n    \"value\" : 40478\n}\n```\n\nAnd a sample response:\n```json\n{\n  \"category\": \"cat-77\",\n  \"duration\": 1065,\n  \"index\": 860214\n}\n```\nThe `index` is the calculated result we are interested in.\n\n### Remarks\n- An individual calculation can take just few milli-seconds or up to several seconds\n- the service can process multiple concurrent requests\n- the calculation is not necessarily deterministic, the same input can lead to different results at different times\n- it is not important for this assignment to understand the internal logic of the calculator, it just returns values\n- for this assignment you can for now assume that the service is reliable and does not throw any exceptions\n\n\n## Daily Calculator Service\nThis service needs to be implemented by you. It will use the above Calculator Service but adds the concept of a daily context to it:\nCalculation requests are always executed against a given date.\nAt end of day a `close` request can be invoked which returns the aggregated totals for the given day.\nA closed context should not accept further calculation requests.\n\nThe process is as follows:\n\n### 1) context is implicitly created\n\nA context is created implicitly by calling the endpoint `calculate` with a date and a calculation input.\n\n### 2) calculations are executed\nThen the clients can trigger many calculations concurrently against this context (again via the same endpoint `calculate``).\nEach of the calculation requests will need to be forwarded to the Calculation Service but without blocking the calling client.\n \n### 3) context is closed\nFinally the context will be closed by a client.\nThis endpoint should return:\n- the number of calculations executed against this context\n- the sum of all calculations against this context\n\nThe returned values here needs to take all calculations into account which where triggered before the `close` endpoint was called:\nany still running calculations must complete before the close result can be delivered.\n\n### the endpoints\n\nAll date formats are `yyyy-MM-dd`\n\n#### calculate endpoint\n\nSample input for a `POST`:\n```json\n{\n    \"category\" : \"cat-77\",\n    \"value\" : 105\n}\n```\nThere is no response body as the service should return right away.\n\n\n#### close endpoint\n\nThe `close` endpoint returns the daily totals for the given context:\n\n```json\n{\n    \"sum\": 101313,\n    \"count\": 417\n}\n```\n\nwith\n- `sum` the sum of all calculations of the given context\n- `count` the number of calls against the given context\n\n\n#### delete endpoint\nA context can be deleted and even recreated if needed.\nOn recreation, it should start from scratch i.e., any previous values should be discarded.\n\n### Further service requirements\n\n- A closed context cannot be closed again\n- A closed context should not accept further calculations\n- once a context was deleted it can be recreated\n\nSee also the spec for the expected http status codes, payloads and other requirements.\n\n## Assignment requirements\nYou should provide a readme including your design decisions and instructions how to start the service.\nFor Java-based projects, you can assume the evaluator has JDK installed. JDK 11 is preferred but latest JDK is allowed. Maven wrapper (`mvnw`) or Gradle wrapper (`gradlew`) are the allowed build systems for Java-based projects.\nThe implementation should follow good practices.\n\n\n## Files summary\n\n- [calculator-service.yml](calculator-service.yml) openapi spec of the Calculator Service implemented already, accessible via a docker image\n- [spec.yml](spec.yml) openapi spec of the service to be built by you\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuildit%2Fcalculator-assignment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuildit%2Fcalculator-assignment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuildit%2Fcalculator-assignment/lists"}