matiru

Blockchain-Based Supply Chain Transparency for Agricultural Produce
commit 2eb1c86e7c7efe40424f7e3f2518722df0767ca1
parent ccef1974b433e6c575b7d78feda6826bc1a961f7
Author: maydayv7 <maydayv7@gmail.com>
Date:   Tue,  7 Oct 2025 18:47:53 +0530

docs: Move install instructions

Diffstat:
MREADME.md | 127++-----------------------------------------------------------------------------
Adocs/INSTALL.md | 116+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+), 124 deletions(-)

diff --git a/README.md b/README.md @@ -1,127 +1,6 @@ # Matiru -For a detailed overview about this project, read [this](./docs/SOLUTION.md). -The model is described [here](./docs/MODEL.md). +For a detailed overview about this project, read [SOLUTION.md](./docs/SOLUTION.md). +The model is described in [MODEL.md](./docs/MODEL.md). ---- - -To run the app for the first time, follow all sections in order: - -### A. Backend - -Get the blockchain network up and running with the `chaincode`, along with our `backend` -> - -1. Install Chaincode dependencies: - -``` -cd chaincode -npm install -``` - -1. Install Docker, Docker Compose -2. Install Fabric binaries and Docker images like so: - -``` -cd fabric -curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh -chmod +x install-fabric.sh -./install-fabric.sh -``` - -Ensure the `config` directory is present inside `fabric` - -1. Start Fabric network: - -``` -cd network -./network.sh up createChannel -ca -c CHANNEL_NAME -cd addOrg3 -./addOrg3.sh up -c CHANNEL_NAME -cd ../addOrg4 -./addOrg4.sh up -c CHANNEL_NAME -cd .. -``` - -After initial setup, you can use the following commands: - -``` -./network.sh up # Start network -./network.sh down # Reset everything -> Need to setup again -``` - -4. Deploy Chaincode: - -``` -./network.sh deployCC -c CHANNEL_NAME -ccn CHAINCODE_NAME -ccp /path/to/chaincode -ccl javascript -``` - -5. Wallet Creation: - -``` -DIR=../../backend/connections -mkdir -p $DIR -cp organizations/peerOrganizations/org1.example.com/connection-org1.json $DIR/connection-org1.json -cp organizations/peerOrganizations/org2.example.com/connection-org2.json $DIR/connection-org2.json -cp organizations/peerOrganizations/org3.example.com/connection-org3.json $DIR/connection-org3.json -cp organizations/peerOrganizations/org4.example.com/connection-org4.json $DIR/connection-org4.json -cd ../../backend -mkdir -p wallet -node initWallet.js org1 ../fabric/network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp ./wallet admin-org1 -node initWallet.js org2 ../fabric/network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp ./wallet admin-org2 -node initWallet.js org3 ../fabric/network/organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp ./wallet admin-org3 -node initWallet.js org4 ../fabric/network/organizations/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp ./wallet admin-org4 -``` - -6. The `.env` file must be created in `backend` like so: - -``` -# Backend server -PORT=4000 - -# JWT -JWT_SECRET=some_secret -TOKEN_EXPIRES_IN=24h - -# Fabric Connection -CHANNEL=CHANNEL_NAME -CHAINCODE=CHAINCODE_NAME -AS_LOCALHOST=true -WALLET_PATH="./wallet" - -IDENTITY_ORG1="admin-org1" -CCP_PATH_ORG1="./connections/connection-org1.json" -IDENTITY_ORG2="admin-org2" -CCP_PATH_ORG2="./connections/connection-org2.json" -IDENTITY_ORG3="admin-org3" -CCP_PATH_ORG3="./connections/connection-org3.json" -IDENTITY_ORG4="admin-org4" -CCP_PATH_ORG4="./connections/connection-org4.json" -``` - -Make sure the port is not blocked by a firewall - -1. Start `backend`: - -``` -npm install -npm run init -npm start -``` - -### B. Frontend - -To start the `frontend` -> - -``` -cd frontend -npm install -``` - -Then find your computer's IP address (using `ifconfig`) and execute the following: - -``` -echo 'export const API_BASE = "http://IP_ADDRESS:4000/api";' >> config.js -npm start -``` - -Install [Expo Go](https://expo.dev/go) on your phone and scan the QR Code to view the mobile app +Read [INSTALL.md](./docs/INSTALL.md) to run the app. diff --git a/docs/INSTALL.md b/docs/INSTALL.md @@ -0,0 +1,116 @@ +### A. Backend + +1. Install Docker & Docker Compose +2. Install Fabric binaries and Docker images like so: + +``` +cd .. +curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh +chmod +x install-fabric.sh +./install-fabric.sh +``` + +Ensure the `config` directory is present inside `fabric` + +3. Install Chaincode dependencies: + +``` +cd chaincode +npm install +``` + +4. Start Fabric network: + +``` +cd ../network +./network.sh up createChannel -ca -c CHANNEL_NAME +cd addOrg3 +./addOrg3.sh up -c CHANNEL_NAME +cd ../addOrg4 +./addOrg4.sh up -c CHANNEL_NAME +cd .. +``` + +After initial setup, you can use the following commands: + +``` +./network.sh up # Start network +./network.sh down # Reset everything -> Need to setup again +``` + +5. Deploy Chaincode: + +``` +./network.sh deployCC -c CHANNEL_NAME -ccn CHAINCODE_NAME -ccp /path/to/chaincode -ccl javascript +``` + +6. Wallet Creation: + +``` +DIR=../../backend/connections +mkdir -p $DIR +cp organizations/peerOrganizations/org1.example.com/connection-org1.json $DIR/connection-org1.json +cp organizations/peerOrganizations/org2.example.com/connection-org2.json $DIR/connection-org2.json +cp organizations/peerOrganizations/org3.example.com/connection-org3.json $DIR/connection-org3.json +cp organizations/peerOrganizations/org4.example.com/connection-org4.json $DIR/connection-org4.json +cd ../../backend +mkdir -p wallet +node initWallet.js org1 ../fabric/network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp ./wallet admin-org1 +node initWallet.js org2 ../fabric/network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp ./wallet admin-org2 +node initWallet.js org3 ../fabric/network/organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp ./wallet admin-org3 +node initWallet.js org4 ../fabric/network/organizations/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp ./wallet admin-org4 +``` + +7. The `.env` file must be created in `backend` like so: + +``` +# Backend server +PORT=4000 + +# JWT +JWT_SECRET=some_secret +TOKEN_EXPIRES_IN=24h + +# Fabric Connection +CHANNEL=CHANNEL_NAME +CHAINCODE=CHAINCODE_NAME +AS_LOCALHOST=true +WALLET_PATH="./wallet" + +IDENTITY_ORG1="admin-org1" +CCP_PATH_ORG1="./connections/connection-org1.json" +IDENTITY_ORG2="admin-org2" +CCP_PATH_ORG2="./connections/connection-org2.json" +IDENTITY_ORG3="admin-org3" +CCP_PATH_ORG3="./connections/connection-org3.json" +IDENTITY_ORG4="admin-org4" +CCP_PATH_ORG4="./connections/connection-org4.json" +``` + +Make sure the port is not blocked by a firewall + +8. Start `backend`: + +``` +npm install +npm run init +npm start +``` + +### B. Frontend + +To start the `frontend` -> + +``` +cd frontend +npm install +``` + +Then find your computer's IP address (using `ifconfig`) and execute the following: + +``` +echo 'export const API_BASE = "http://IP_ADDRESS:4000/api";' >> config.js +npm start +``` + +Install [Expo Go](https://expo.dev/go) on your phone and scan the QR Code to view the mobile app