cyproto / examination-system_with_hyperledger-fabric

An examination system that uses blockchain to store results. The main motive is maintain integrity of exam results. Hyperledger-fabric is used as the blockchain framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Examination System using Hyperledger-fabric

This repository contains chaincode, test-network and API made to work as a backend for examination system project whose frontend can be found here.

Currently, the file structure is same as fabric-samples provided by hyperledger.

  • The chaincode is written with reference of fabcar example.
  • APIs are written in Node.js.
  • And for network test-network is being used.

Getting started

Make sure that you have setup your environment and are done with all the prerequisites.

Versions:

  • fabric: 2.1.0
  • golang: go1.14.1
  • node: v10.15.2
  • npm: 5.8.0

Now, just run the following command to clone and pull all the binaries and dockers images. No need to clone this repository manually, it'll all be done by the script.

curl -sSL https://bit.ly/3eh7nxE | bash

Start fabric network:

After running this you will have to start the network and deploy the chaincode on it. For that just

cd exam_result
sudo ./startNetwork.sh

Now, enroll admin and register user by doing

cd javascript
node enrollAdmin.js
node registerUser.js

If everything goes as expected the chaincode will be deployed on channel mychannel and fabric network will be up and running.

API:

Now heading towards the API, run

node app.js

which will start a node server on localhost:8080.

  • There are 2 apis namely getResult which will fetch result from the fabric ledger, it needs emailId as a query param of the candidate who has already taken the exam/test. Check request and response formats. This API calls queryResult chaincode function.

  • Other one is sendResult which takes the request in JSON, calculates result and pushes it to the blockchain. Check the request and response. This API calls createResult with appropriate args.

Chaincode:

  • For now tis just has 3 basic functions as initLedger which initializes the ledger with some dummy values as soon as chaincode is deployed.
  • Then there's queryResult which uses 'emailId' as an argument to pull state/data from the ledger.
  • Finally createResult is used to insert result in the blockchain.

Screenshots:

getResult

sendResult

About

An examination system that uses blockchain to store results. The main motive is maintain integrity of exam results. Hyperledger-fabric is used as the blockchain framework.

License:Apache License 2.0


Languages

Language:Shell 86.9%Language:JavaScript 13.1%