{"id":21076365,"url":"https://github.com/rapter1990/simplebanking","last_synced_at":"2025-05-16T06:32:20.520Z","repository":{"id":204299951,"uuid":"711321717","full_name":"Rapter1990/simplebanking","owner":"Rapter1990","description":"Simple Banking App (Spring Boot, Gradle, JUnit, Integration Test, Postgresql, Prometheus, Grafana, Github Actions, Postman)","archived":false,"fork":false,"pushed_at":"2023-11-03T18:36:17.000Z","size":3667,"stargazers_count":30,"open_issues_count":0,"forks_count":6,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-04-24T06:34:04.438Z","etag":null,"topics":["ci-cd","continuous-deployment","continuous-integration","docker","docker-compose","github-actions","gradle","grafana","integration-test","java","junit","monolith","openapi","postgresql","postman","prometheus","spring-boot","swagger"],"latest_commit_sha":null,"homepage":"","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/Rapter1990.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}},"created_at":"2023-10-28T22:06:03.000Z","updated_at":"2024-04-13T00:48:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee2cd5a9-d039-48b6-b629-e3a96b440be0","html_url":"https://github.com/Rapter1990/simplebanking","commit_stats":{"total_commits":71,"total_committers":1,"mean_commits":71.0,"dds":0.0,"last_synced_commit":"8f7d85d09aac70613e2d22d1d47ea6a8ad7e4740"},"previous_names":["rapter1990/simplebanking"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rapter1990%2Fsimplebanking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rapter1990%2Fsimplebanking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rapter1990%2Fsimplebanking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rapter1990%2Fsimplebanking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rapter1990","download_url":"https://codeload.github.com/Rapter1990/simplebanking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225413243,"owners_count":17470544,"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":["ci-cd","continuous-deployment","continuous-integration","docker","docker-compose","github-actions","gradle","grafana","integration-test","java","junit","monolith","openapi","postgresql","postman","prometheus","spring-boot","swagger"],"created_at":"2024-11-19T19:28:02.594Z","updated_at":"2024-11-19T19:28:03.193Z","avatar_url":"https://github.com/Rapter1990.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Case Study - Simple Banking API\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"screenshots/simple_banking_main_image.png\" alt=\"Main Information\" width=\"700\" height=\"400\"\u003e\n\u003c/p\u003e\n\nIn this assignment you will build a banking service that can handle any number of transactions for bank accounts. The service is part of a larger collection of services that model the inner workings of a bank. The services for the \"bank account\" provide a simple model of how bank accounts might work in an overly simplified world.\n\nFor this assignment, the bank account is exclusively interested in maintaining the name of the account owner, the number of the account and the account’s balance. The endpoints will be limited to methods that provide a means of crediting and debiting the account. \n\nYour data model for the bank account object must have fields owner where the field type is java.lang.String, fields to hold the account number (String) and balance (double). the credit() service as specified above adds the supplied amount to the receiving BankAccounts balance and the the debit() service subtracts the supplied amount from the receiving BankAccounts balance.  \n\nThe object model for our banking system must include transaction objects. A transaction object keeps track of the kind of transaction (deposit, withdrawal, payments etc.) as well as the date and amount of the transaction. Each transaction type will require its own parameters. The following diagram shows how BankAccounts and Transactions are related. An instance of DepositTransaction represents a deposit; a WithdrawalTransaction represents a withdrawal (the triangle on the diagram indicates inheritance). Inheritance for the PhoneBillPaymentTransaction, CheckTransaction etc. is not shown - you must decide where to put this class.  All transactions must have  have the fields date and amount at a minimum. The date field should contain the time of the transaction and should be automatically calculated.\n\n![model](images/model.png)\n\n## You can use provided project template as a start\nThe template project (gradle Java) is available under the src folder.  We recommend that you use Quarkus or Spring(boot), Junit, JPA as the primary choices for your implementation.\n\n## Task 1: Implement and test the model\nThese transaction objects will be used both to make financial requests of a BankAccount and to keep a record of those requests. The following Unit test segment indicates how transactions will be used on the service side:\n\n    BankAccount account = new BankAccount(\"Jim\", 12345);\n    account.post(new DepositTransaction(1000));\n    account.post(new WithdrawalTransaction(200));\n    account.post(new PhoneBillPaymentTransaction(\"Vodafone\", \"5423345566\", 96.50));\n    assertEquals(account.getBalance(), 703.50, 0.0001)\n\n### BONUS Task 1: Find a better implementation alternative\nThe bank account post method must do something special for each Transaction type. e.g. post(DepositTransaction) and post(WithdrawalTransaction. This solution will work but creating families of overloaded methods is discouraged as it causes problems with maintenance. Consider, if we added more Transaction subclasses we would need to keep changing the BankAccount class, overloading even more post methods. It is considered bad form in OO  to write case statements based on the type of objects. It also has the same maintenance problems as the first solution. Adding more Transaction subclasses would require changes. Find a solution to delegate the operation using polymorphism so that the Bank account is never changed by introducing new transaction types. At a öinimum you shoudl make the provided uni test to run:\n\n\n## Task 2:  Provide a REST API using Spring Rest Controllers and TEST\nProvide a REST API to the banking system as follows. The following code demonstrates how BankAccounts might be used.  Use services and repositories to persist your model above into a Database using JPA.  Please provide tests (MOCK or othrewise) for your code:\n\nTo deposit money into an account, one would use:\n\n    curl --location --request POST 'http://localhost:8080/account/v1/credit/669-7788' \\\n    --header 'Content-Type: application/json' \\\n    --header 'Accept: application/json' \\\n    --data-raw '    {\n            \"amount\": 1000.0\n        }'\n\n    response would be (200):\n    {\n        \"status\": \"OK\",\n        \"approvalCode\": \"67f1aada-637d-4469-a650-3fb6352527ba\"\n    }\n\nTo withdraw money:\n\n    curl --location --request POST 'http://localhost:8080/account/v1/debit/669-7788' \\\n    --header 'Content-Type: application/json' \\\n    --header 'Accept: application/json' \\\n    --data-raw '    {\n            \"amount\": 50.0\n        }'\n\n    response would be (200):\n    {\n        \"status\": \"OK\",\n        \"approvalCode\": \"a66cce54-335b-4e46-9b49-05017c4b38dd\"\n    }\n\nTo get the current account data, one would use:\n\n    curl --location --request GET 'http://localhost:8080/account/v1/669-7788'\n\n    response would be:\n\n    {\n        \"accountNumber\": \"669-7788\",\n        \"owner\": \"Kerem Karaca\",\n        \"balance\": 950.0,\n        \"createDate\": \"2020-03-26T06:15:50.550+0000\",\n        \"transactions\": [\n            {\n                \"date\": \"2020-03-26T06:16:03.563+0000\",\n                \"amount\": 1000.0,\n                \"type\": \"DepositTransaction\",\n                \"approvalCode\": \"67f1aada-637d-4469-a650-3fb6352527ba\"\n            },\n            {\n                \"date\": \"2020-03-26T06:16:35.047+0000\",\n                \"amount\": 50.0,\n                \"type\": \"WithdrawalTransaction\",\n                \"approvalCode\": \"a66cce54-335b-4e46-9b49-05017c4b38dd\"\n            }\n        ]\n    }\n\n### Explore Rest APIs\n\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n      \u003cth\u003eMethod\u003c/th\u003e\n      \u003cth\u003eUrl\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n      \u003cth\u003eRequest Body\u003c/th\u003e\n      \u003cth\u003eHeader\u003c/th\u003e\n      \u003cth\u003eValid Path Variable\u003c/th\u003e\n      \u003cth\u003eNo Path Variable\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003ePOST\u003c/td\u003e\n      \u003ctd\u003e/api/v1/account/createAccount\u003c/td\u003e\n      \u003ctd\u003eCreate Account\u003c/td\u003e\n      \u003ctd\u003eCreatedAccountRequest\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003ctr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003eGET\u003c/td\u003e\n      \u003ctd\u003e/api/v1/account/account-number/{accountNumber}\u003c/td\u003e\n      \u003ctd\u003eGet Account Details\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003eaccountNumber\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003ctr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003ePOST\u003c/td\u003e\n      \u003ctd\u003e/api/v1/account/credit\u003c/td\u003e\n      \u003ctd\u003eDeposit Money to Account\u003c/td\u003e\n      \u003ctd\u003eCreateCreditRequest\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003ctr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003ePOST\u003c/td\u003e\n      \u003ctd\u003e/api/v1/account/debit\u003c/td\u003e\n      \u003ctd\u003eWithdraw Money from Account\u003c/td\u003e\n      \u003ctd\u003eCreateWithdrawalRequest\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003ctr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003ePOST\u003c/td\u003e\n      \u003ctd\u003e/api/v1/account/payment\u003c/td\u003e\n      \u003ctd\u003ePayment of Phone Bill from Account\u003c/td\u003e\n      \u003ctd\u003eCreatePhoneBillPaymentRequest\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003ctr\u003e\n  \n\u003c/table\u003e\n\n\n### Technologies\n\n---\n- Java 11\n- Spring Boot 2.5.5\n- Restful API\n- Lombok\n- Gradle\n- Junit5\n- Mockito\n- Integration Tests\n- Docker\n- Docker Compose\n- CI/CD (Github Actions)\n- Prometheus and Grafana\n- Postman\n- Actuator\n- Swagger 3\n- PostgreSQL\n\n\n### Swagger\n\n```\nhttp://localhost:1222/swagger-ui/index.html\n```\n\n### Prerequisites\n\n#### Define Variable in .env file\n\n```\nDATABASE_USERNAME={DATABASE_USERNAME}\nDATABASE_PASSWORD={DATABASE_PASSWORD}\n```\n\n---\n- Gradle or Docker\n---\n\n### Docker Run\nThe application can be built and run by the `Docker` engine. The `Dockerfile` has multistage build, so you do not need to build and run separately.\n\nPlease follow directions shown below in order to build and run the application with Docker Compose file;\n\n```sh\n$ cd simplebanking\n$ docker-compose up -d\n```\n\nIf you change anything in the project and run it on Docker, you can also use this command shown below\n\n```sh\n$ cd simplebanking\n$ docker-compose up --build\n```\n\n---\n### Gradle Run\nTo build and run the application with `Gradle`, please follow the directions shown below;\n\n```sh\n$ cd simplebanking\n$ gradle clean build\n$ gradle bootRun\n```\n\n## Reference Documentation\nFor further reference, please consider the following sections:\n\n* [Official Gradle documentation](https://docs.gradle.org)\n* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/gradle-plugin/reference/html/)\n* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/reference/htmlsingle/#using-boot-devtools)\n\n### Guides\nThe following guides illustrate how to use some features concretely:\n\n* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/)\n\n### Additional Links\nThese additional references should also help you:\n* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle)\n\n### Screenshots\n\n\u003cdetails\u003e\n\u003csummary\u003eClick here to show the screenshots of project\u003c/summary\u003e\n    \u003cp\u003e Figure 1 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_1.PNG\"\u003e\n    \u003cp\u003e Figure 2 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_2.PNG\"\u003e\n    \u003cp\u003e Figure 3 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_3.PNG\"\u003e\n    \u003cp\u003e Figure 4 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_4.PNG\"\u003e\n    \u003cp\u003e Figure 5 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_5.PNG\"\u003e\n    \u003cp\u003e Figure 6 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_6.PNG\"\u003e\n    \u003cp\u003e Figure 7 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_7.PNG\"\u003e\n    \u003cp\u003e Figure 8 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_8.PNG\"\u003e\n    \u003cp\u003e Figure 9 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_9.PNG\"\u003e\n    \u003cp\u003e Figure 10 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_10.PNG\"\u003e\n    \u003cp\u003e Figure 11 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_11.PNG\"\u003e\n    \u003cp\u003e Figure 12 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_12.PNG\"\u003e\n    \u003cp\u003e Figure 13 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_13.PNG\"\u003e\n    \u003cp\u003e Figure 14 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_14.PNG\"\u003e\n    \u003cp\u003e Figure 15 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_15.PNG\"\u003e\n    \u003cp\u003e Figure 16 \u003c/p\u003e\n    \u003cimg src =\"screenshots/screenshot_16.PNG\"\u003e\n\u003c/details\u003e\n\n### Contributors\n\n- [Sercan Noyan Germiyanoğlu](https://github.com/Rapter1990)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapter1990%2Fsimplebanking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapter1990%2Fsimplebanking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapter1990%2Fsimplebanking/lists"}