Skip to content

Purvanshsingh/creditrisk-poc

 
 

Repository files navigation

creditrisk-poc

Creditrisk-poc is a Hydra powered API which serves loan portfolio data using EBA NPL Template.

Creditrisk-poc

Working Project

API is live @ http://34.145.188.116:8080/

Features

creditrisk-poc consist following features:

  • ResidentialMortgage, PrivateBorrower, Collateral, Portfolio & manymore classes.
  • Portfolio class collection.
  • classes are linked with each other using foreign keys.
  • All the classes can perform all the CRUD operations ( GET, PUT, POST, DELETE).
  • Portfolio class collection can perform all the CRUD operations.

Classes are linked in the following manner:

Here's the Database schema for the classes.

NonPerformingLoan.jsonld

The NonPerformingLoan.jsonld is a subset vocabulary for NonPerformingLoan portfolios, vocabulary is generated automatically using vocab_generator.py from NonperformingLoan.owl ontology.

python npl_vocab/vocab_generator.py

It will generate the JSON-LD vocabulary which can be used to create ApiDoc.

API_DOC

API_Doc is generated through hydra-python-core module doc_writer and nplvoac_parse.py which automates the creation of classes and properties from JSON-LD vocabulary.

API_Doc, doc_writer & nplvocab_parser.py files can be found here :

api_doc
|
|___ ApiDoc.jsonld
|___ api_docwriter.py
|___ nplvocab_parser.py

nplvocab_parser parse all the classes & properties from NonPerformingLoan.jsonld and provide functions for converting them to HydraClass & HydraClassProp.

ApiDoc is a JSON serialized object, It can be accessed as follows:

import json

ApiDoc_file = open("creditrisk_poc/api_doc/ApiDoc.json","r")
doc = json.load(ApiDoc_file)

you will get the doc in python dict format.

ApiDoc is generated with this flow:

Automation_structure

Repository Structure

creditrisk_poc
|
|____api_doc
|    |
|    |_____api_docwriter.py
|    |_____ApiDoc.jsonld
|    |_____nplvocab_generator.py
|
|____npl_vocab
|    |
|    |____NonPerformingLoan.jsonld
|    |____NonPerformingLoan.owl
|    |____nplo.jsonld
|    |____vocab_generator.py
|
|____"__main.py__"

Demo

To run hydra powered creditrisk-poc API, just do the following:

  1. Clone creditrisk-poc
git clone https://github.com/HTTP-APIs/creditrisk-poc.git
cd creditrisk-poc
  1. Install a Python virtual environment using:
python3.7 -m venv .venv

or:

virtualenv -p python3.7 .venv
  1. Install requirements:
source .venv/bin/activate
pip install -r requirements.txt
  1. Run hydrus server
cd creditrisk_poc
python __main__.py

The hydrus should be up & running on http://localhost:8080/creditrisk_api/

API can be tested using Mock_portfolio_generator

cd tests
python mock_portfolio_generator.py

Mock_portfolio_generator is a mock client which can populate the database with the more realistic data, It automatically creates the object of the classes on the basis of ApiDocumentation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.5%
  • Dockerfile 0.5%