diff --git a/README.md b/README.md index d42bb64..b1a97d7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,59 @@ # creditrisk-poc -A proof of concept serving the EBA NPL template schema via a hydra API +Creditrisk-poc is a Hydra powered API which serves loan portfolio data using EBA NPL Template. + +## Features +creditrisk-poc consist following features: +* Loan & Borrower classes. +* Borrower class collection. +* Loan & Borrower class are linked using a foreign key ("CounterpartyId"). +* Loan class can perform all the CRUD operations ( GET, PUT, POST, DELETE). +* Borrower can perform all the CRUD operations. +* Borrower class collection can perform all the CRUD operations. + +## API_DOC +API_Doc is generated through hydra-python-core module doc_writer. + +API_Doc & doc_writer file can be found here : +``` +API_Doc +| +|___ APIDOC +|___ Creditrisk_api_docwriter.py +``` +`APIDOC` is a pickle serialized object, It can be accessed as follows: +```python +import pickle + +API_Doc_file = open("creditrisk_poc/API_Doc/APIDOC","rb") +doc = pickle.load(API_Doc_file) +``` +you will get the doc in `python dict` format. + +## Demo +To run hydra powered creditrisk-poc API, just do the following: +1) Clone creditrisk-poc +```bash +git clone https://github.com/HTTP-APIs/creditrisk-poc.git +cd creditrisk-poc +``` +2. Install a [*Python virtual environment*](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/) using: +```bash +python3.7 -m venv .venv +``` +or: +```bash +virtualenv -p python3.7 .venv +``` + +3. Install requirements: +```bash +source .venv/bin/activate +pip install -r requirements.txt +``` +3) Run hydrus server +```bash +cd creditrisk_poc +python main.py +``` +The hydrus should be up & running on `http://localhost:8080/creditrisk_api/` diff --git a/docs/Functionality.md b/docs/Functionality.md new file mode 100644 index 0000000..3fe0959 --- /dev/null +++ b/docs/Functionality.md @@ -0,0 +1,67 @@ +# Making CRUD operations to Creditrisk-poc via POSTMAN + +> Please make sure hydrus is up & running. + +To check if hydrus is up and running, open Postman and make a GET request to http://localhost:8080/creditrisk_api/. You should see the following response on Postman: +![Screenshot from 2021-06-15 19-00-01](https://user-images.githubusercontent.com/49719371/122061389-16a87400-ce0c-11eb-8f07-0b19896f6e89.png) + +## Adding Borrower + To add a borrower, we need to make a PUT Request to http://localhost:8080/creditrisk_api/Borrower with the following request body. + ```json +{ + "@type" : "Borrower", + "TotalAssets" : 10000, + "LegalEntityIdentifier" : " ", + "DateOfIncorporation": "2021-06-15-18:00:00" +} + ``` + ![Screenshot from 2021-06-15 19-11-33](https://user-images.githubusercontent.com/49719371/122063036-8bc87900-ce0d-11eb-83bd-0295d28a1d30.png) + +The object was successfully added. To see the object we need to make GET request to `http://localhost:8080/creditrisk_api/Borrower/` + + ## Modifying Borrower + To change the Borrower object we need to make POST request to `http://localhost:8080/creditrisk_api/Borrower/` Object will be modified with the following request body. + ```json +{ + "@type" : "Borrower", + "TotalAssets" : 50000, + "LegalEntityIdentifier" : " ", + "DateOfIncorporation": "2021-06-15-18:00:00" +} + ``` + + + ## Adding Loan + For creating loan object we will need the borrower object-id as FOREIGN KEY for Loan class. + we need to make PUT request to http://localhost:8080/creditrisk_api/Loan , with the following request body. + ```json + { + "@type" : "Loan", + "CounterpartyId" : "0f55898b-6a70-4c9c-aeba-92e603dcfb3a", + "TotalBalance" : 50000, + "ChannelOfOrigination": "[]" +} +``` +![Screenshot from 2021-06-15 19-27-05](https://user-images.githubusercontent.com/49719371/122065605-b4ea0900-ce0f-11eb-9242-176c61146cfe.png) + +## Creating Borrower Collection +For adding Borrower collection we need to make the PUT request to http://localhost:8080/creditrisk_api/Borrowers , add the borrower with the following request body. +```json +{ + "@type" : "Borrowers", + "members" : [ + { + "@id" : "http://localhost:8080/creditrisk_api/Borrower/0f55898b-6a70-4c9c-aeba-92e603dcfb3a", + "@type": "Borrower" + } + ] +} +``` +![Screenshot from 2021-06-15 19-39-27](https://user-images.githubusercontent.com/49719371/122067719-6fc6d680-ce11-11eb-9b39-71637a352e05.png) + +## Get Collection +To retrive a collection we need to make GET request to `http://localhost:8080/creditrisk_api/Borrowers/collection-id` +![Screenshot from 2021-06-15 19-43-30](https://user-images.githubusercontent.com/49719371/122068413-0398a280-ce12-11eb-91fc-0e4b6a1d3b5f.png) + +## Deleting Class Instances and Collection Instances +To delete a resource make a DELETE operation on the http://localhost:8080/creditrisk/Loan/. Similarly to delete a collection, make DELETE operation to http://localhost:8080/api/Borrowers/.