Thursday, September 21, 2017

Implementing WorkFlow Applications Using BigchainDB

Blockchain Enterprise Applications :    As  mentioned  in  earlier  article,  thinking  Blockchain way will  transform the  way  traditional  enterprise  applications  are  done  so far. As  mentioned earlier,  BigchainDB  is  a   scalable  blockchain  database.  It  is a  NOSQL big data base  with blockchain chracteristics.  Also this  database  is  good  for  Asset  Registers  and  Transfers. Infact viewing  database  transaction  in terms  of  Asset  is  one of the fundamental  attributes  of this database.

On  thinking  about  the  database,  the  very   nature  of  Asset  Registration  and  subsequent  transfer between  multiple  owners,  can  be  viewed  from  the  angle  of  traditional  workflow  applications  that  is  prevalent  in  enterprises  today.

Considering  a   Loan  Application  of  a  new  Car.  The  work  flow  could  be.

1.  The  End  User  Sends  the  Request  for  a  loan,  say  through  a  dealer
2. The   Application Clerk (Alice),   validates  the  data  performs  Pre-Checks  and  creates  the  Initial  application in the  system  through a  user  interface
3. The  Loan  Application is  then  forwarded (transferred) to   next  level,  where  the  Credit and Document  Validations are  done.  Done By Bob.
4. Finally  the  Loan  is  passed  to  Disbursement  of  final  amount. Done By Mary.

This  may  be  a  simplistic loan  approval  process  and  in  actual  there could  be multiple  steps  in between,  but  this  particular  scenario  can  easily   be  modelled  in  BigchainDB  database  and  the whole  process  can  be  viewed  from a  different  angle.

Now  considering  that  each  of these  individuals  belong  to a  different  organization or group, A  consortium  blockchain  database  could be an  ideal solution.

1. In the  below  steps,  the  initial  Asset ,  which is basically  a  Loan  Request  is  created  by  Alice.

request_asset = {
            'data': {
                        'request': {
                            'name':'Allen Anderson',
                            'requesttype':'car loan',
                            'carmake': 'Toyota',
                            'currency':'USD',
                            'dealerlocation':'chicago',
                            'loanamt':'15000',
                            'repaymentmonths':36,
                            'yearlyincome':60000,
                            'address':'284 N Cross St XXXX ',
                            'otherloans':'none'
                            },
                        },
            }

request_asset_metadata = {
            'comments': ' Request Created In The System'
            }

prepared_creation_tx = bdb.transactions.prepare(
            operation='CREATE',
                signers=alice_public,
                    asset=request_asset,
                        metadata=request_asset_metadata
                        )

fulfilled_creation_tx = bdb.transactions.fulfill(
            prepared_creation_tx,
                private_keys=alice_private
                )

sent_creation_tx = bdb.transactions.send(fulfilled_creation_tx)

2.  In the  second  step,  Alice  performs  the   Pre Screening  and  transfers  the  Asset  i.e the  Request to  Bob.  Even  though  due  to  immutable  nature  the  asset/request  itself  cannot be modified  it  is  the  metadata  that  gets  changed  to  reflect the  current  status.

transfer_input={
           'fulfillment':output['condition']['details'],
           'fulfills':{
               'output_index':output_index,
               'transaction_id':requestassetid,
            },
           'owners_before':output['public_keys'],
        }
transfer_asset={
           'id':requestassetid
        }
transfer_asset_metadata = {
            'comments': 'Pre Screening Done and  Ready For Credit Check'
            }
prepared_transfer=bdb.transactions.prepare(
            operation='TRANSFER',
            asset=transfer_asset,
            metadata=transfer_asset_metadata,
            inputs=transfer_input,
            recipients= bob_public
        )
fulfilled_transfer=bdb.transactions.fulfill(
        prepared_transfer,private_keys=alice_private
        )
transfertx=bdb.transactions.send(fulfilled_transfer)


3.  Finally  Bob  performs  the  Credit  Check   and  Documentation Check  and  transfers  the  Asset to Mary.

transfer_input={
           'fulfillment':output['condition']['details'],
           'fulfills':{
               'output_index':output_index,
               'transaction_id':prevtransid,
            },
           'owners_before':output['public_keys'],
        }
transfer_asset={
           'id':requestassetid
        }
transfer_asset_metadata = {
            'comments': 'Credit Check  Done, Documentation check Done, Approved For Disbursement'
            }
prepared_transfer=bdb.transactions.prepare(
            operation='TRANSFER',
            asset=transfer_asset,
            metadata=transfer_asset_metadata,
            inputs=transfer_input,
            recipients= mary_public
        )
fulfilled_transfer=bdb.transactions.fulfill(
        prepared_transfer,private_keys=bob_private
        )
transfertx=bdb.transactions.send(fulfilled_transfer)


In  each step,  the  Asset  ownership  changes  reflecting  the  steps  in the workflow.  Also  the  Asset Meta Data  can  be  effectively used  to  get the  details  about  the  current  approval  status.

Also  there  are  many  Query  constructs  that  are  available  to  perform RDBMS  like  search on the whole  data  set  to   perform   further  reporting  on it.

While  the  above  scenario  can  also  be done  using  Other Relational Databases,  thinking  Blockchain  and  Distributed  way   of  building  enterprise  applications  will  lead  to  new  possibilities.

Let  me know  of  other use  cases  that  will   fit  these  scenarios.

No comments:

Post a Comment