{"id":16679549,"url":"https://github.com/mfelsche/carpark-ubi","last_synced_at":"2026-04-21T23:04:53.425Z","repository":{"id":143100555,"uuid":"225245905","full_name":"mfelsche/carpark-ubi","owner":"mfelsche","description":"codechallenge ubitricity","archived":false,"fork":false,"pushed_at":"2019-12-02T23:33:38.000Z","size":70,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T04:18:40.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/mfelsche.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":"2019-12-01T23:20:30.000Z","updated_at":"2022-10-14T12:10:24.000Z","dependencies_parsed_at":"2023-03-27T15:35:06.591Z","dependency_job_id":null,"html_url":"https://github.com/mfelsche/carpark-ubi","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/mfelsche%2Fcarpark-ubi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfelsche%2Fcarpark-ubi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfelsche%2Fcarpark-ubi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfelsche%2Fcarpark-ubi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfelsche","download_url":"https://codeload.github.com/mfelsche/carpark-ubi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243365640,"owners_count":20279215,"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-12T13:36:02.034Z","updated_at":"2025-12-29T00:08:56.094Z","avatar_url":"https://github.com/mfelsche.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coding challenge\n**Carpark Ubi**\n\n## Domain vocabulary:\nEV - electric vehicle.\nCP - charging point, an element in an infrastructure that supplies electric energy for the recharging of electric vehicles.\n\n## Problem details:\nThe task is to implement a simple application to manage the charging points installed at Carpark Ubi.\nCarpark Ubi has 10 charging points installed. When a car is connected it consumes either 20 Amperes (fast charging) or 10 Amperes (slow charging). \nCarpark Ubi installation has an overall current input of 100 Amperes so it can support fast charging for a maximum of 5 cars or slow charging for a maximum of 10 cars at one time.\nA charge point notifies the application when a car is plugged or unplugged.\nThe application must distribute the available current of 100 Amperes among the charging points so that when possible all cars use fast charging and when the current is not sufficient some cars are switched to slow charging. \nCars which were connected earlier have lower priority than those which were connected later.\nThe application must also provide a report with a current state of each charging point returning a list of charging point, status (free or occupied) and - if occupied – the consumed current.\n\n## Requirements:\n1. The solution must be implemented as a Spring Boot application with Java.\n2. We need to be able to start it and run tests.\n3. BIZ logic needs to be implemented correctly.\n4. Interaction with the APP needs to happen through well-defined REST APIs.\n4. Include at least one unit test and one integration test.\n3. Solution needs to be thread safe.\n\n## Examples:\n\n```\nCP1 sends a notification that a car is plugged\nReport: \nCP1 OCCUPIED 20A\nCP2 AVAILABLE\n...\nCP10 AVAILABLE\n```\n\n```\nCP1, CP2, CP3, CP4, CP5 and CP6 send notification that a car is plugged\nReport:\nCP1 OCCUPIED 10A\nCP2 OCCUPIED 10A\nCP3 OCCUPIED 20A\nCP4 OCCUPIED 20A\nCP5 OCCUPIED 20A\nCP6 OCCUPIED 20A\nCP7 AVAILABLE\n...\nCP10 AVAILABLE\n```\n\n## Deliverables:\nLink to the git repository with the implementation and the documentation on how to call the API (Swagger/Postman collection/text description).\nPlease add any details about your ideas and considerations to this README and add it to the repository.\n\n## Challenge Details\n\n**WARNING: This is my first Spring Boot / Java Enterprise Code, EVER.**\n\nI implemented the challenge modelling the ChargePoints as POJOS persisted in a JPA repository to the H2 embedded database. The overall used ampere are tracked using those ChargePoints in the database with their `status` and `chargeType` fields. When a car is plugged,\nthe repository is consulted to check if we need to switch chargepoints with cars plugged in earlier to slow charging, in order to provide fast-charge to the new car. When a car is unplugged, the repository is consulted to check if we can switch other chargepoints to fast charging. All this while maintaining the maximum possible ampere of 100A.\n\nThread safety is achieved by wrapping the operations upon plug and unplug events into `@Transactional`, ensuring a (database?) transaction\nis used across several calls to the repository to retrieve and manipulate the current state in one atomic step.\n\nThe application is built as REST Api consuming and producing json. Modelling of the endpoints might be a but un-RESTy to some.\nThe basic idea behind adding an endpoint like  `/chargepoint/\u003cID\u003e/event` and putting event type and timestamp into url params\nwas to maybe also record single events in addition to maintaining the computed current state in the ChargePointRepository.\nIt might be more appropriate to solve it differently but I found it appealing to do so and didnt regret it during implementation.\n\nThe Swagger UI can be found at:\n\nhttp://localhost:8080/swagger-ui.html\n\nIt can also be inspected at https://editor.swagger.io using the given `swagger.json` file in this repository.\n\n* There are still tests missing, especially:\n  - Verifying that chargepoints with cars plugged in earlier are prioritized when downgrading to slow charging with 10A\n  - Verifying that remaining amperes are distributed with priority to chargepoints with cars plugged in later\n  - a property test ensuring proper handling and distribution of available ampere to all charging points (not exceeding max ampere) given any order of events\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfelsche%2Fcarpark-ubi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfelsche%2Fcarpark-ubi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfelsche%2Fcarpark-ubi/lists"}