|
1 | | -# LOYALTY-TOKENS-USING-HLF |
| 1 | +# A LOYALTY PLATFORM APPLICATION USING HYPERLEDGER FABRIC |
2 | 2 |
|
3 | | -This projects keeps track record of any product starting from manufacturer to customer. |
| 3 | +This platform is to allow manufacturer(P&G here) directly award their cusomter for being a loyal cusomters and customers can redeem those tokens at any of the retailer's store associated with the manufacturer. |
| 4 | + |
| 5 | +## Use Case digram |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## Flow diagram |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +1. Blockchain operator setup the private blockchain network having 3 organizations, 3 certificate authorities and 1 channel. |
| 14 | +2. The end user ( admin, user, consumer ) interacts with ReactJS UI for register, update , grant tokens and reedem tokens. |
| 15 | +3. The ReactJS platforms uses API gateway to interact with the blockchain network. |
| 16 | +4. The ExpressJS API application uses fabric SDK to interact with the nwtwork. |
| 17 | + |
| 18 | +## Technologies used |
| 19 | + |
| 20 | +1. Hyperledger Fabric 1.4.6 |
| 21 | +2. Node.js |
| 22 | +3. React.js |
| 23 | + |
| 24 | +## Software versions |
| 25 | + |
| 26 | + |
| 27 | +| System | Driver | Version |
| 28 | +| --- | --- | --- | |
| 29 | +| Platform | Hyperledger Fabric | 1.4.6 |
| 30 | +| Docker | Docker | 18.09.09 |
| 31 | +| Language | Go | 1.11 |
| 32 | +| Node | node | 10.20 |
| 33 | +| UI | React | latest |
| 34 | + |
| 35 | +_____________________________________________________________________________________________________________________________ |
| 36 | +## Steps to replicate locally |
| 37 | + |
| 38 | +1. Clone this repository |
| 39 | +2. Install required softwares for this app |
| 40 | +3. Start the fabric network using shell script |
| 41 | +4. Start the API server |
| 42 | +5. Start the Client APP |
| 43 | + |
| 44 | +### Step 1. Clone the repository |
| 45 | + |
| 46 | +`git clone git@github.com:kuldeep23907/loyalty-token-using-hlf.git` |
| 47 | + |
| 48 | +`cd loyalty-token-using-hlf` |
| 49 | + |
| 50 | +### Step 2. Install required softwares |
| 51 | + |
| 52 | +They are hyperledger fabric 1.4.6, golang, docker, docker-composer, node, python3 |
| 53 | + |
| 54 | +### Step 3. Start the fabric network using shell script |
| 55 | + |
| 56 | +`chmod 777 operate.sh` |
| 57 | + |
| 58 | +`sudo ./operate.sh up` |
| 59 | + |
| 60 | +When you run a script, the following things happen in order: |
| 61 | + |
| 62 | + Generate certificates through the "artifacts/crypto-config.yaml" file. |
| 63 | + |
| 64 | + Generate channel artifacts through the "artifacts/configtx.yaml" file. |
| 65 | + |
| 66 | + Deploy the required containers on the Fabric network through the docker-compose command and the "arifacts/docker-compose.yaml" file. |
| 67 | + |
| 68 | + Run the "scripts/script.sh" file using the cli docker container. |
| 69 | + |
| 70 | +When you run a script in the cli docker container, the following things happen in order: |
| 71 | + |
| 72 | + Create a loyaltyplatformchannel channel.' |
| 73 | + |
| 74 | + All peers join the loyaltyplatformchannel channel. |
| 75 | + |
| 76 | + Update anchor peers for each organization. |
| 77 | + |
| 78 | + Install chaincode on all peers. |
| 79 | + |
| 80 | + Instantiate chaincode in manufacturer peer0. |
| 81 | + |
| 82 | + Invoke the initLedger method to seed P&G as manufacturer and an admin in the ledger. |
| 83 | + |
| 84 | +For more details, see the contents of the operate.sh file. |
| 85 | + |
| 86 | +### Step 4. Start the web server |
| 87 | + |
| 88 | +`cd web-app/servers/` |
| 89 | + |
| 90 | +`npm install` |
| 91 | + |
| 92 | +`nodemon app.js` |
| 93 | + |
| 94 | +### Step 5. Start the client app |
| 95 | + |
| 96 | +`cd ../../client/` |
| 97 | + |
| 98 | +`npm install` |
| 99 | + |
| 100 | +`npm start run` |
| 101 | + |
| 102 | +Now everything is setup and testing could be started. Go to `http://localhost:3000` to see the client app running. Please refer to demo video link here to proceed: |
| 103 | + |
| 104 | +## Stop the network |
| 105 | + |
| 106 | +After testing is done or an error occurs or to stop the network, go to `loyalty-token-using-hlf` and run the following scripts |
| 107 | + |
| 108 | +`chmod 777 stopNetwork.sh` |
| 109 | + |
| 110 | +`chmod 777 teardown.sh` |
| 111 | + |
| 112 | +`sudo ./stopNetwork.sh` |
| 113 | + |
| 114 | +`sudo teardown.sh` |
| 115 | + |
| 116 | +____________________________________________________________________________________________________________________________ |
| 117 | +## About the fabric private blockchain network |
| 118 | + |
| 119 | +### Network and channel architecture |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | +### Ledger Structs Relationship |
| 124 | + |
| 125 | + |
0 commit comments