|
| 1 | +# Money transfer Rest API |
| 2 | + |
| 3 | +A Java RESTful API for money transfers between users accounts |
| 4 | + |
| 5 | +### Technologies |
| 6 | +- JAX-RS API |
| 7 | +- As an in memory database static Concurrent Hashmap used |
| 8 | +- Jetty Container |
| 9 | +- Grizzly server for Test |
| 10 | + |
| 11 | +### How to run |
| 12 | +``` Executable jar at path : executableJar/ |
| 13 | +
|
| 14 | + java -jar moneytransfer-1.0 {Will start the server, the api can then be hit using Postman} |
| 15 | +``` |
| 16 | + |
| 17 | +#### Implementation Design |
| 18 | +Application starts a jetty server on localhost port 8080 . An in memory database (currently concurrent Hashmap) initialized with some sample user and account data To view |
| 19 | + |
| 20 | +- http://localhost:8080/userAccount/1 |
| 21 | +- http://localhost:8080/userAccount/2 |
| 22 | + |
| 23 | +-Basic validations to prompt the user in case the request is not proper. For eg, when user does not have sufficient balance |
| 24 | + |
| 25 | +-Junit Testcases to user account service and transaction service. |
| 26 | + |
| 27 | + |
| 28 | +### Available Services |
| 29 | + |
| 30 | + |
| 31 | + | HTTP METHOD | PATH | USAGE | |
| 32 | + | ----------- | --------------------- | ------ | |
| 33 | + | GET | /userAccount/{userId} | get userAccount by user Id | |
| 34 | + | GET | /userAccount/ | get all userAccounts | |
| 35 | + | POST | /userAccount/ | create a new userAccount | |
| 36 | + | PUT | /userAccount/{userId} | update userAccount | |
| 37 | + | DELETE | /userAccount/{userId} | remove userAccount | |
| 38 | + | POST | /transaction/withdraw | withdraw money from account | |
| 39 | + | POST | /transaction/deposit | deposit money to account | |
| 40 | + | POST | /transaction/transfer | perform transfer between 2 user accounts | |
| 41 | + |
| 42 | +### Http Status |
| 43 | +- 200 OK: The request has succeeded |
| 44 | +- 201 Created: The request has been created . |
| 45 | +- 400 Bad Request: The request could not be understood by the server |
| 46 | +- 404 Not Found: The requested resource cannot be found |
| 47 | +- 500 Internal Server Error: The server encountered an unexpected condition |
| 48 | + |
| 49 | +### Sample JSON for User and Account |
| 50 | +##### User : |
| 51 | +```sh |
| 52 | +{ |
| 53 | + "userName" : "Test", |
| 54 | + "balance" : "100" |
| 55 | + } |
| 56 | +``` |
| 57 | +##### User Transaction: |
| 58 | + |
| 59 | +```sh |
| 60 | +{ |
| 61 | + "fromUserId": "2", |
| 62 | + "toUserId": "1", |
| 63 | + "amount": "100" |
| 64 | +} |
| 65 | +``` |
| 66 | +#### Current Limitations: |
| 67 | +- Static Hashmap can be replaced by in memory database like H2 |
| 68 | +- Validations can be enhanced. |
0 commit comments