Incident Accuracy Reporting System

IARS solution overview

We currently live in an environment where we are finding more instances where law enforcement agencies could be seen as being racially biased or conducting unlawful practices and policies. The practices and policies are shaping the methodology by which data is created, which increases inaccurate, skewed, or systemically biased information. The lack of transparent and accurate data available to assess police behavioral infractions means that police reports can be falsified and covered up.

This tutorial shows you how to create a content management application that captures statements, videos, and audio feeds from firsthand individuals relating to police incident reports. It provides:

  • An interface for firsthand individuals to enter information or data related to an incident report
  • Automated/manual flagging of inconsistencies and inaccuracies contained in initial incident reports based on collected data
  • Cross-reference report data with officer history on misconduct
  • A mechanism for disputing claims in incident reports
  • A back end to a blockchain instance that contains a hash to the actual document stored in IBM Cloud® Object Storage

Learning objectives

In this tutorial, you will:

  • Provision the following IBM Cloud services
    • IBM Watson® Speech to Text
    • IBM Watson Language Translator
    • IBM Cloud Object Storage
  • Install and configure a local instance of Hyperledger blockchain
  • Initiate the back-end server
  • Initiate the front-end application

Prerequisites

  1. Register for an IBM Cloud account.
  2. Get the code.

Estimated time

It should take you approximately 45 minutes to complete this tutorial.

Architecture diagram

IARS flow diagram

  1. The user uploads the documents to the platform.
  2. The app runs the document through the Watson Speech to Text service and creates a transcript if the documents contain video or audio.
  3. The document is translated to English if the document is in a foreign language.
  4. The document is validated with other case documents using scikit-learn and Watson Machine Learning.
  5. The document is stored in IBM Cloud Object Storage linked to a hash stored in the Hyperledger blockchain.

Steps

Provision your IBM Cloud services

  1. Create a .env file by copying the Incident-Accuracy-Reporting-System/backend/STT-Audio/env.example file in the same directory.

  2. Provision and create the following services:

    1. Register for a free trial account if you do not have an IBM Cloud account.
    2. Create a Watson Speech to Text instance.
    3. Create a Watson Language Translator instance.
    4. Create an IBM Cloud Object Storage instance.
  3. Gather the credentials:

    1. From the main navigation menu (☰), select Resource list to find your services under Services.
    2. Click each service to find the Manage view where you can collect the API Key and URL to use for each service when you configure the credentials.
  4. Add the credentials for the Watson Speech to Text and Watson Language Translator services to the .env file that you created earlier.

    
     # Environment variables
     SPEECH_TO_TEXT_IAM_APIKEY=
     SPEECH_TO_TEXT_URL=
    
     LANGUAGE_TRANSLATOR_IAM_APIKEY=
     LANGUAGE_TRANSLATOR_URL=
    

Provision blockchain ledger

After provisioning the IBM Cloud Object Storage, Watson Speech to Text, and Watson Language Translator services, you must deploy a blockchain ledger. This ledger keeps track of all digital assets that have been uploaded. There are two ways to deploy a ledger: locally or in the cloud. For this solution, we focus on deploying the blockchain locally.

Clone blockchain application

First, clone the repository that contains the blockchain application code.

git clone https://github.com/IBM/Blockchain-for-maintaining-Digital-Assets

Clean up outdated Docker images

Make sure you don’t have any old Hyperledger Fabric images. Check this by issuing the following commands:

./stopFabric.sh
docker rmi -f $(docker images -q)

docker ps
docker images

You should see no images listed.

Update script to install the chaincode

  1. Update the installChaincode.sh file that is found in the Blockchain-for-maintaining-Digital-Assets/local/ directory.

  2. Update the CONTRACT_PATH variable with the path of where you installed your Blockchain-for-maintaining-Digital-Assets repo. As an example:

     export CONTRACT_PATH='/Users/laurabennett/2020/EMBRACE-Challenge'
    

Install and instantiate Smart Contracts, and deploy blockchain application

Configure the IBM Cloud Object Storage instance

First, you must configure your IBM Cloud Object Storage instance. During this process, you add your IBM Cloud Object Storage credentials to the config.json file in the Blockchain-for-maintaining-Digital-Assets/server/config directory.

  1. Go to your IBM Cloud Object Storage instance. Then, go to Buckets in the left navigation pane, and click Create bucket.
  2. Choose Standard under Predefined buckets, provide a unique bucket name according to the naming rules specified, skip the upload files step, then click Next.
  3. Skip the test bucket out step, and click Next. After the bucket is successfully created:

    1. Under Bucket details, obtain the bucket name, and specify it as cos_bucketName in the config.json file.
    2. Under Service Credentials, obtain the API key and resource_instance_id values, and specify them as the cos_apiKeyId and cos_serviceInstanceId, respectively, in the config.json file.
    3. Under Endpoints, obtain the Public endpoint, and specify this value as the cos_endpoint in the config.json file.

      Object store gif

  4. Change to the directory where you installed Blockchain-for-maintaining-Digital-Assets.

When complete, your Blockchain-for-maintaining-Digital-Assets/server/config/config.json should look something like the following example:

 {
    "channel_name": "mychannel",
    "smart_contract_name": "blockchain-for-maintaining-digital-assets",
    "connection_file": "Org1MSP_profile.json",
    "appAdmin": "app-admin",
    "appAdminSecret": "app-adminpw",
    "orgMSPID": "Org1MSP",
    "caName": "184.172.229.220:31844",
    "peerName": "184.172.229.220:30884",
    "gatewayDiscovery": { "enabled": true, "asLocalhost": false },
    "smtpHost": "smtp.mailtrap.io",
    "smtpPort": 2525,
    "smtpUserName": "cb49e25f8cbe5f",
    "smtpPassword": "3734c09cfdj05f",
    "senderEmail": "no-reply@digitalassetscodepattern.com",
    "cos_endpoint": "s3.us-south.cloud-object-storage.appdomain.cloud",
    "cos_apiKeyId": "QrC2rLBkjEmS755xR88_78seDgD2ai8DIQxVd74G21Je",
    "cos_serviceInstanceId": "crn:v1:bluemix:public:cloud-object-storage:global:a/86ac1b16b6f8b9639124a38d8edbd301:2f8d9627-46ff-46e9-a053-9d3e7121eedf::",
    "cos_bucketName": "blockchain-digital-assets-bucket"
 }

Start the blockchain network

This step starts the network in a series of Docker images, creates a network channel, and joins a peer.

cd Incident-Accuracy-Reporting-System/backend/blockchain/local
./startFabric.sh

Upon successful completion, you should see the following:

2020-10-13 17:32:46.599 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-10-13 17:32:46.612 UTC [cli.common] readBlock -> INFO 002 Received block: 0
2020-10-13 17:32:46.862 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-10-13 17:32:46.948 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel

Install and instantiate the Smart Contracts onto the network

This step installs, instantiates, and tests a smart contract on the network.

cd Incident-Accuracy-Reporting-System/backend/blockchain/local
./installChaincode.sh

Upon successful completion, you should see the following:

+ LANGUAGE=golang
+ export CONTRACT_PATH=/Users/laurabennett/2020/EMBRACE-Challenge
+ CONTRACT_PATH=/Users/laurabennett/2020/EMBRACE-Challenge
+ echo 'Copying Chaincode to cli container'
Copying Chaincode to cli container
+ docker cp /Users/laurabennett/2020/EMBRACE-Challenge/Blockchain-for-maintaining-Digital-Assets/contract/ cli:/opt/gopath/src/github.com/asset
+ echo 'Install and Instantiate Chaincode'
Install and Instantiate Chaincode
+ docker exec -e CORE_PEER_LOCALMSPID=Org1MSP -e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp cli peer chaincode install -n asset -v 1.0 -p /opt/gopath/src/github.com/asset -l node
2020-10-13 18:04:56.309 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-10-13 18:04:56.309 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-10-13 18:04:56.335 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
+ sleep 5
+ docker exec -e CORE_PEER_LOCALMSPID=Org1MSP -e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp cli peer chaincode instantiate -l node -o orderer.example.com:7050 -C mychannel -n asset -v 1.0 -c '{"Args":[]}' -P 'OR ("Org1MSP.member")'
2020-10-13 18:05:01.608 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-10-13 18:05:01.608 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
+ echo 'Chaincode Instantiated'
Chaincode Instantiated
+ sleep 10
+ echo 'Test Chaincode'
Test Chaincode
+ docker exec -e CORE_PEER_LOCALMSPID=Org1MSP -e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp cli peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n asset -c '{"Args":["queryAllDigitalAssets"]}'
2020-10-13 18:05:40.265 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 payload:"[]"

After the blockchain ledger is up and running, we’ll deploy an application to track uploaded media on the ledger. This works by taking a hash of a file and storing it on the blockchain ledger. Then, the original file is placed in an IBM Cloud Object Storage instance. If the file is tampered with in the IBM Object Storage instance, it no longer matches the hash, and an alert is generated.

Install dependencies and start the blockchain application

  1. In a new terminal, navigate to the server (web-app/server) directory:

     cd Blockchain-for-maintaining-digital-assets/web-app/server/
    
  2. Build the node dependencies:

     npm install
    
  3. Start the server:

     npm start
    
  4. In a separate terminal, navigate to the client (web-app/client) directory

     cd Blockchain-for-maintaining-digital-assets/web-app/client/
    
  5. Build the node dependencies:

     npm install
    
  6. Start the client:

     npm run serve
    

After both the server and client have successfully started, the UI can be accessed at http://localhost:8080/?#/. The Digital Asset Management app is intended for use within a police force for managing the stored documents.

Main page of blockchain application

Start the Incident Accuracy Reporting System web application

  1. Change to the Incident-Accuracy-Reporting-System directory:

     cd Incident-Accuracy-Reporting-System
    
  2. Start the front-end web app:

     cd frontend
     npm install
     npm run serve
    
  3. Start the back end:

     cd backend
     npm install
     npm start
    

Summary

You now know how to integrate artificial intelligence with blockchain technologies to build an intelligent content management system that ensures consistency and security for uploaded content. Now you might want to consider how to extend the application by adding support for mobile devices. Additionally, given that law enforcement agencies might consider using different cloud platforms, consider how to deploy the application across a multiplatform environment.

Contribute to the Incident Accuracy Reporting System and help make a change.