SaFi Bank Space : Loans - Integration with risk and product tool

This part of the loan-manager is responsible for retrieving risk data for a particular client from the risk microservice, querying the product recommendation table for product parameters, caching the results, and providing it to the frontend using API. It provides functionality to call the OpenStop Platform to reevaluate the risk scoring data.

All the features are implemented directly inside the loan-manager.

Use cases

Both use cases are provided for personal loans and overdrafts.

Showing product parameters to the client

  1. Request risk parameters from the risk microservice.

  2. Get matching rows from the product recommendation table.

  3. Adjust partially matched rows to align with the max amount.

  4. Store maximum amount to the pre-approved limit cache.

  5. Create JSON data structure for the client.

Approving/Rejecting the product

  1. Call OneStop Platform workflow to update the risk profile.

  2. Wait for the result.

  3. Request risk parameters from the risk microservice.

  4. Get matching rows from the product recommendation table.

  5. Adjust partially matched rows to align with the max amount.

  6. Store maximum amount to the pre-approved limit cache.

  7. Approve/Reject the product application.

Risk microservice client

The risk micro service provides information about scores for the customers based on their id. It is called whenever the loan-manager needs risk information. The risk microservice does not trigger score recalculation. It always provide the most recent calculated score.

The loan-manager implements simple client service to access the risk microservice endpoint.

REST request

POST https://decision-product-score-6dp53idjvq-ew.a.run.app
Content-Type: application/json

{"id": "521d16ac-003f-4135-bac0-8d02b691175a"}

REST response

{
  "id": "521d16ac-003f-4135-bac0-8d02b691175a",
  "timestamp": "2022-11-30 08:08:44",
  "personal_loan": {
    "grade_score": 7,
    "max_amount": 500,
    "max_monthly_installment": 120,
    "max_tenor": 6,
    "max_offered_amount": 350
  },
  "overdraft": {
    "grade_score": 7,
    "max_amount": 300,
    "max_offered_amount": 200
  }
}

The risk microservice provides two values - maximum and maximum offered amount. The max_amount is used to limit the maximum possible loan and the max_offered_amount is used to advertise the maximum amount to the customer.

Loan Risk OneStop Platform client

The OSP client implements methods for calling OSP platform to run a workflow to recalculate risk data.

There is just asynchronous method for calling a workflow (synchronous was deprecated).

The result of asynchronous workflow running is implemented using webhooks. The client sends a Kafka message whenever the webhook is triggered.

The documentation of OSP is at the end of this page. The update workflow API has to be provided by risk team.

Pre-approved limit cache

The pre-approved limit cache is implemented using PostgreSQL database and repository layer. The cache record is created when the risk calculation OSP workflow is finished after onboarding. Whenever the product recommendation result is gathered, the cache is updated.

The cache provides method to invalidate values for all or selected customers. It returns null value then.

The cache is invalidated when the new product table data is imported.

The cache stores both pre-approved limits for an overdraft and a personal loan.

Frontend app API integration

Frontend app API provides data for the product selection tool and the pre-approved limit values for each client.

The product selection tool data is calculated based the current risk data.

The data for pre-approved limit is served from the cache. If the cache is not available, the recalculation is done and the new value is returned.

Data served to FE are sorted in non-overlapping intervals. And all products are unique.

Product parameters calculator

The calculator is responsible for querying the product recommendation tool based on risk data. It queries the tool to get the partially matching rows too and adjust result to match the max total principal and max monthly installment.

It returns results in the format already implemented in loan-manager PoC.

Personal loan product parameters calculation

  1. The risk parameters are retrieved from the risk microservice.

    • Grade

    • Max amount

    • Max monthly installment

    • Max tenor

  2. The product recommendation tool is queried to match the rows based on risk parameters.

    • P(Grade min) <= R(Grade) <= P(Grade max)

    • P(Tenor) <= R(Max tenor)

    • P(Min amount) < R(Max amount)

    • P(Min monthly installment) < R(Max monthly installment)

  3. The matched rows are modified to not exceed the constraints.

    1. Max amount = min(P(Max amount), R(Max amount))

    2. Max monthly installment = min(P(Max monthly installment), R(Max monthly installment))

    3. Max amount = min(Max amount, Max monthly installment * tenor)

    4. Max monthly installment = min(Max monthly installment, Max amount / tenor)

P - product recommendation table

R - risk microservice

See also

Risk workflow (Decision tree) integration using Advance AI

(Deprecated) Onboarding integration with Risk/Fraud components