Coder Social home page Coder Social logo

aws-samples / aws-cdk-loan-broker Goto Github PK

View Code? Open in Web Editor NEW
23.0 7.0 7.0 1.38 MB

This project is an AWS Cloud Development Kit (CDK) implementation of Gregor Hohpe's Loan Broker example. The purpose is to show how serverless orchestration with integration patterns could be implemented with CDK.

License: Apache License 2.0

JavaScript 30.42% TypeScript 69.58%
aws cdk cdk-examp eip integrations

aws-cdk-loan-broker's Introduction

Loan Broker with AWS CDK

This project is an AWS Cloud Development Kit (CDK) implementation of Gregor Hohpe's Loan Broker example.

The purpose is to show how serverless orchestration with integration patterns could be implemented with CDK.

Table of content

Overview

The example application demonstrates a basic integration scenario, which consists of several steps:

  1. A Customer submits a loan application with personal data and desired terms, such as loan amount and duration.
  2. The Loan Broker enriches the request with the customer's credit score retrieved from the Credit Bureau.
  3. The Loan Broker submits the application to multiple Banks.
  4. The Banks reply with a loan offer if they are willing to service the loan.
  5. The Loan Broker aggregates the results, for example by selecting the best offer.
  6. The Loan Broker returns the result(s) to the Customer.

Loan Broker - Overview

Loan Broker implementations

Recipient List

This version uses the Recipient List pattern, meaning the Loan Broker first retrieves a list of banks to request quotes from. For more details, see here.

Recipient List - Architecture overview

Publish Subscribe

In order to be able to dynamically route loan application to multiple banks this version uses the Scatter Gather pattern, meaning the Loan Broker does not require to know upfront how many banks there are or how they are implemented. For more details, see here.

Scatter Gather - Architecture overview

Usage

Bootstrap your environment

cdk bootstrap aws://ACCOUNT-NUMBER/REGION       # e.g. cdk bootstrap aws://123456789012/us-east-1

For more details, see AWS Cloud Development Kit.

Install dependencies

npm install

Initial deployment

cdk deploy LoanBroker-RecipientList-Stack
cdk deploy LoanBroker-PubSub-Stack

Pre-populate LoanBrokerBanksTable for RecipientsList stack

aws dynamodb put-item \
    --table-name=LoanBrokerBanksTable \
    --item='{ "Type": { "S": "Home" }, "BankAddress": {"L": [ { "S": "BankRecipientPremium" }, { "S": "BankRecipientUniversal" }, { "S": "BankRecipientPawnshop" } ] } }'

Execute loan broker request

In order to start the state machine, execute:

aws stepfunctions start-execution \
    --name=cli-test-run \
    --state-machine-arn=STATE_MACHINE_ARN \
    --input="{\"SSN\": \"123-45-6789\", \"Amount\": 500000, \"Term\": 30 }"

You can use the resulting state machine ARN that is included in the CDK output.

The result contains the execution ARN, that is needed to request the output, e.g:

{
    "executionArn": "STATE_MACHINE_ARN:cli-test-run",
    "startDate": "2021-12-01T13:37:00.000000+00:00"
}

To see the output of the state machine execution, execute this:

aws stepfunctions describe-execution \
    --execution-arn=STATE_MACHINE_ARN:cli-test-run \
    --query="output" | jq -r  '. | fromjson'

This will result in:

{
   "Credit": { "Score": 693, "History": 24 },
   "Amount": 600000,
   "Quotes": [
    { "rate": 5.271301238502866, "bankId": "Universal" },
    { "rate": 3.8970175730277457, "bankId": "Premium" }
   ],
  "Term": 30,
  "SSN": "123-45-6789"
}

Destroy the stacks

cdk destroy --all

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

aws-cdk-loan-broker's People

Contributors

amazon-auto avatar moralesl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.