{"id":27198572,"url":"https://github.com/nickylogan/stockchainz","last_synced_at":"2025-04-09T20:52:22.576Z","repository":{"id":44107782,"uuid":"177397461","full_name":"nickylogan/stockchainz","owner":"nickylogan","description":"Integrated inventory management system using Hyperledger Composer","archived":false,"fork":false,"pushed_at":"2023-01-04T00:48:52.000Z","size":117838,"stargazers_count":0,"open_issues_count":23,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2023-03-12T05:27:02.210Z","etag":null,"topics":["blockchain-network","hyperledger-composer","hyperledger-fabric","inventory-management"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nickylogan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-24T10:02:53.000Z","updated_at":"2020-01-05T12:30:19.000Z","dependencies_parsed_at":"2023-02-01T16:00:30.137Z","dependency_job_id":null,"html_url":"https://github.com/nickylogan/stockchainz","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickylogan%2Fstockchainz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickylogan%2Fstockchainz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickylogan%2Fstockchainz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickylogan%2Fstockchainz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickylogan","download_url":"https://codeload.github.com/nickylogan/stockchainz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248111957,"owners_count":21049577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain-network","hyperledger-composer","hyperledger-fabric","inventory-management"],"created_at":"2025-04-09T20:52:21.981Z","updated_at":"2025-04-09T20:52:22.558Z","avatar_url":"https://github.com/nickylogan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stockchainz\n\nThis implementation shows how inventory management can be done on a blockchain using Hyperledger Composer and Fabric.\n\nA group marketplaces agreed to share merchants' inventory data, so that the item count is synced up acrossed the network. To achieve this, they decided to create a blockchain network tracking inventory data. Common inventory transactions are recorded and spread throughout the network.\n\n## Getting Started\n\n### Prerequisites\n\n#### VirtualBox\n\nDownload and install VirtualBox from [here](https://www.virtualbox.org/wiki).\n\n#### Vagrant\n\nDownload and install Vagrant from [here](https://www.vagrantup.com).\n\n#### `vagrant-disksize`\n\n[`vagrant-disksize`](https://github.com/sprotheroe/vagrant-disksize/) is a plugin to easily resize the VM's disksize via Vagrant (make sure that Vagrant is already installed beforehand). Run the command below to install the plugin:\n\n```sh\nvagrant plugin install vagrant-disksize\n```\n\n### Setting up\n\n#### Booting up the VM\n\nAll of the other dependencies are already provisioned in the vagrant configuration. Boot up the machine by running the following command in this directory:\n\n```sh\nvagrant up\n```\n\nSSH into the machine by running:\n\n```sh\n\u003e vagrant ssh\n...\nvagrant@ubuntu-xenial:~$ _\n```\n\n#### Configuring the REST server\n\nChange directory into `rest-server`. Inside, you should see a directory called `docker-images`. Build the container first by running:\n\n```sh\n./rest-mgr.sh build\n```\n\nYou can safely ignore `npm ERR` or `WARN` messages. In its internals, the bash script builds the provided `Dockerfile` in the `rest-server/docker-images` directory.\n\nInside this directory, you should see a file called `.env.example`. Duplicate the file and rename it to `.env`. The file should look something like this:\n\n```sh\nCOMPOSE_PROJECT_NAME=net\nGOOGLE_OAUTH_CLIENTID1=\nGOOGLE_OAUTH_SECRET1=\nGOOGLE_OAUTH_CLIENTID2=\nGOOGLE_OAUTH_SECRET2=\nGOOGLE_OAUTH_CLIENTID3=\nGOOGLE_OAUTH_SECRET3=\nSUCCESS_REDIRECT_URL1=/\nFAILURE_REDIRECT_URL1=/\nSUCCESS_REDIRECT_URL2=/\nFAILURE_REDIRECT_URL2=/\nSUCCESS_REDIRECT_URL3=/\nFAILURE_REDIRECT_URL3=/\n```\n\nAs you can see, there are `GOOGLE_OAUTH_*`  variables. Set this using your own Google OAuthv2 client id and secret (create **three** client IDs). You can read about the details [here](https://hyperledger.github.io/composer/latest/tutorials/google_oauth2_rest)\n\n##### *Market1*\n\n```sh\nAuthorized JavaScript origins:\n\n* http://localhost:3000\n* http://api-market1-stockchainz.serveo.net\n\nAuthorized Redirect URIs:\n\n* http://localhost:3000/auth/google\n* http://localhost:3000/auth/google/callback\n* http://api-market1-stockchainz.serveo.net/auth/google\n* http://api-market1-stockchainz.serveo.net/auth/google/callback\n```\n\n##### *Market2*\n\n```sh\nAuthorized JavaScript origins:\n\n* http://localhost:4000\n* http://api-market2-stockchainz.serveo.net\n\nAuthorized Redirect URIs:\n\n* http://localhost:4000/auth/google\n* http://localhost:4000/auth/google/callback\n* http://api-market2-stockchainz.serveo.net/auth/google\n* http://api-market2-stockchainz.serveo.net/auth/google/callback\n```\n\n##### *Market3*\n\n```sh\nAuthorized JavaScript origins:\n\n* http://localhost:5000\n* http://api-market2-stockchainz.serveo.net\n\nAuthorized Redirect URIs:\n\n* http://localhost:5000/auth/google\n* http://localhost:5000/auth/google/callback\n* http://api-market3-stockchainz.serveo.net/auth/google\n* http://api-market3-stockchainz.serveo.net/auth/google/callback\n``` \n\nReplace the variables in `.env`, so that it looks like the following:\n\n```sh\nCOMPOSE_PROJECT_NAME=net\n# Replace with your OAuth client id and secrets\nGOOGLE_OAUTH_CLIENTID1=XXXXX\nGOOGLE_OAUTH_SECRET1=XXXXX\nGOOGLE_OAUTH_CLIENTID2=XXXXX\nGOOGLE_OAUTH_SECRET2=XXXXX\nGOOGLE_OAUTH_CLIENTID3=XXXXX\nGOOGLE_OAUTH_SECRET3=XXXXX\n\nSUCCESS_REDIRECT_URL1=https://stockchainz.github.io/market1-app/\nFAILURE_REDIRECT_URL1=https://stockchainz.github.io/market1-app/\nSUCCESS_REDIRECT_URL2=https://stockchainz.github.io/market2-app/\nFAILURE_REDIRECT_URL2=https://stockchainz.github.io/market2-app/\nSUCCESS_REDIRECT_URL3=https://stockchainz.github.io/market3-app/\nFAILURE_REDIRECT_URL3=https://stockchainz.github.io/market3-app/\n```\n\n#### Spinning up the network\n\nStart the whole network by executing `start.sh`:\n\n```sh\n$ ./start.sh\n...\n@@@@@ SET UP FINISHED @@@@@\n```\n\n#### Playing with the web app\n\nThe live version of the web app can be accessed on these links:\n\n* `https://stockchainz.github.io/market1-app/`\n* `https://stockchainz.github.io/market2-app/`\n* `https://stockchainz.github.io/market3-app/`\n\nIf you are to access it, you should see a \"Cannot connect to server\" message. This is because the API can't be accessed by the web app. To open the API endpoints publicly, do the following commands in six different terminals:\n\n* `ssh -R api-market1-stockchainz:80:localhost:3000 serveo.net`\n* `ssh -R account-market1-stockchainz:80:localhost:3005 serveo.net`\n* `ssh -R api-market2-stockchainz:80:localhost:4000 serveo.net`\n* `ssh -R account-market2-stockchainz:80:localhost:4005 serveo.net`\n* `ssh -R api-market3-stockchainz:80:localhost:5000 serveo.net`\n* `ssh -R account-market3-stockchainz:80:localhost:5005 serveo.net`\n\nOnce all of them are ready, you can access the web apps through the provided links.\n\n**IMPORTANT:** The SSH session will be terminated if no requests are being received. If you need to access the API again, simply restart the relevant command.\n\n\n#### Stopping the network\n\nThe network can be torn down by running the script `./stop.sh` in the `composer` directory:\n\n```sh\n$ ./stop.sh\n...\n@@@@@ TEAR DOWN FINISHED @@@@@\n```\n\n\n## Running the tests\n\nThere are three automated tests, one of which is automatically done when the Fabric infrastructure is built.\n\n**IMPORTANT:** The following tests require [Node](https://nodejs.org/en/) to be installed on the machine. The testing environment ***MUST*** be either Linux or Mac OS.\n\n### Testing the Hyperledger Composer business network\n\nChange directory into the `business-network` directory. Install npm dependencies by running the following command:\n\n```sh\nnpm install\n```\n\n**IMPORTANT:** The npm dependencies require a Linux/Mac OS environment\n\nOnce installed, run tests by executing\n\n```sh\nnpm test\n```\n\n### Testing the REST API\n\nFor this test, the Fabric network must be already up and running. It is best that the blockchain network is still clean slate.\n\nCreate four test Google accounts. Each of these corresponds with four different participants of the blockchain network.\n\nChange directory into the `rest-server` directory. Install npm dependencies first by running:\n\n```sh\nnpm install\n```\n\n**IMPORTANT:** If the REST containers are running, stop them first by executing the following command. Note that everytime the `.env` file changes, the REST containers must be restarted.\n\n```sh\n./rest-mgr.sh stop\n```\n\nAfter following the instructions in ***\"Configuring the REST Server\"*** above, a `.env` file is produced. For testing, replace the values of `*_REDIRECT_URL*` with `/` (change them back to the original values once the test is done).\n\nStart up the REST containers by running:\n\n```sh\n./rest-mgr.sh start\n```\n\n#### Access tokens\n\nInside `rest-server/test` there is a `.env.example` file. Duplicate the file and rename it to `.env`.\n\nWait for a few minutes and access the following URLs in the browser:\n\n* `http://localhost:3000/auth/google`\n* `http://localhost:4000/auth/google`\n* `http://localhost:5000/auth/google`\n\nLog in with one of the previously created Google account. You will be redirected to `/explorer` in the browser. Show the access token and copy it into the `.env` file in the `test` directory. Replace the values of variables `SELLER1_TOKEN1`, `SELLER1_TOKEN2`, and `SELLER1_TOKEN3` with the tokens obtained from `:3000`, `:4000`, and `:5000` respectively.\n\nClear the browser session and log in with the other accounts. Do the same thing for other `*_TOKEN*` variables.\n\n#### Test\n\nFrom the `rest-server` directory, run the following command to execute the tests:\n\n```sh\nnpm test\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickylogan%2Fstockchainz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickylogan%2Fstockchainz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickylogan%2Fstockchainz/lists"}