Skip to content

mattdean1/blockchain-supply-chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blockchain-supply-chain

A technical framework for improving traceability in supply chain systems using blockchain. Developed as part of my final year project at University. See dissertation.pdf for further discussion.

Improving Supply chain systems offers benefits to quality, cost, and regulatory compliance, but interoperability between organisations is an obstacle. This project addresses the issue of interoperability through the introduction of blockchain technology, implementing a complex supply chain model from literature on the Hyperledger platform.

The process of translating a supply chain network model to an implementation is described in detail; coupled with the the complexity of the network model chosen, this allows the system to be generalised well to a variety of supply chain use cases. The system includes infrastructure, application and integration layers, providing an end-to-end reference implementation for creation of supply chain systems in enterprise.

Prequisites

  • Docker
  • Postman
  • Node.js / npm
  • yarn

Install

Download Fabric Docker images

curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0-rc1

(docs)

Install Composer command line tools

npm i -g composer-cli@0.16.3 composer-rest-server@0.16.3 passport-github

Import sample participant identities

cd network
./importIdCards.sh

Enable authentication for API server

Create a new OAuth application on GitHub

  • Application name: composer-rest-server
  • Homepage URL: http://localhost:3000/
  • Application description: OAuth application for the multi-user mode of composer-rest-server
  • Authorization callback URL: http://localhost:3000/auth/github/callback

Run

Start the network

# in 'network' directory
export COMPOSE_PROJECT_NAME=biswas
./deployNetwork.sh

Start the API server

export COMPOSER_PROVIDERS='{
  "github": {
    "provider": "github",
    "module": "passport-github",
    "clientID": "REPLACE_WITH_CLIENT_ID",
    "clientSecret": "REPLACE_WITH_CLIENT_SECRET",
    "authPath": "/auth/github",
    "callbackURL": "/auth/github/callback",
    "successRedirect": "/",
    "failureRedirect": "/"
  }
}'

composer-rest-server -c grower-network-admin@biswas -a true -m true

The API explorer is now located http://localhost:3000/explorer.

Interacting with the network

Import identities into API server

  • Navigate to http://localhost:3000/auth/github and authenticate with GitHub
  • Find the /wallet/import endpoint at the bottom of the list in the API explorer
  • Import the admin identity card from ./network/fabric/id-cards/grower-network-admin/card using the name admin
  • Import the identity cards for the sample network participants from ./network/fabric/id-cards/users using the same endpoint. The names should be the same as the name of the card, i.e. the file distributor.card should be imported as distributor

Add sample data using Postman

  • Navigate to the end-to-end test run documentation and click 'Run in Postman'
  • Select the imported sample-env environment
  • Display your OAuth access token in the explorer by clicking 'show'. Copy this into your Postman environment as the value for the key accessToken
  • Run the requests using the collection runner

View traceability information

  • Copy your OAuth access token into line 9 of ./frontend/src/controllers/api.js
  • Start the web application by running yarn start inside ./frontend
  • Copy the value of bottleID from the Postman environment
  • Navigate to the frontend at http://localhost:3001/
  • Search for the copied bottleID.

Development

Unit tests

# in ./network/composer
npm t