Skip to content

the-chain/airmedfoundation-terminal

Repository files navigation

Airmed Foundation - Node.js Terminal

The Airmed Foundation is an open source initiative that provides a secure channel to store and transfer medical records. It is based on the Interplanetary File System (IPFS) and Hyperledger Fabric. The conjunction of these technologies guarantees the immutability and availability of the data.

In order to achieve secure and reliable file management:

  • We replicate all records on the IPFS network using the Bittorrent protocol.
  • We restrict access to records using asymmetric cryptography.
  • We protect and store cryptographic access keys in the Hyperledger Fabric blockchain.

Sharing files with the Airmed Foundation platform is pretty straightforward. Depending on their desired privacy level, one can upload files with or without asymmetric encryption. We have created this tutorial to explain both procedures.

Installation and Usage

The following dependencies must be downloaded and installed in order to use Airmed Foundation's Node.js terminal:

  • Interplanetary File System (IPFS)
  • Docker
  • Docker Compose
  • Node.js
  • NPM
  • NVM
  • Hyperledger Fabric

Here we guide you through this process.

Interplanetary File System (IPFS)

Project website: https://ipfs.io/

wget https://dist.ipfs.io/go-ipfs/v0.4.19/go-ipfs_v0.4.19_linux-amd64.tar.gz
tar xvfz go-ipfs_v0.4.19_linux-amd64.tar.gz
cd go-ipfs
sudo ./install.sh
ipfs init

Docker and Docker Compose

Project website: https://docs.docker.com/install/linux/docker-ce/ubuntu/ (Docker)
Project website: https://docs.docker.com/compose/install/ (Docker Compose)

sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo apt-get install docker-compose

Node.js, NPM and NVM

Project website: https://nodejs.org/en/ (Node.js)
Project website: https://www.npmjs.com/ (NPM)
Project repo: https://github.com/creationix/nvm#installation-and-update (NVM)

sudo apt-get install nodejs
nvm install 8.15.0
nvm use 8.15.0

Hyperledger Fabric

Project website: https://www.hyperledger.org/projects/fabric

git clone https://github.com/hyperledger/fabric-samples
cd fabric-samples
./scripts/bootstrap.sh 1.4.0 1.4.0
cd first-network
./byfn.sh generate
./byfn.sh up

Download Airmed Foundation

Project website: https://airmedfoundation.thechain.tech/

git clone https://github.com/the-chain/airmedfoundation-terminal
cd airmedfoundation-terminal
npm install 

Install Chaincode to Hyperledger Network

cd airmedfoundation-terminal
docker exec -it cli peer chaincode instantiate -C mychannel -l "node" -n airmed -v v1 -c '{"Args":[]}' -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
docker exec -it cli peer chaincode instantiate -C mychannel -l "node" -n secureRec -v v1 -c '{"Args":[]}' -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

Configuration of Airmed Foundation's server

Edit config/datastores.js

Change values to connect to postgreSQL. In order to install postgreSQL, you can run the following command in the terminal:

docker-compose up -d

Setup appconfig.json

{ "email": { "admin":"[email protected]", "auth": { "user": "[email protected]", "pass": "password" }, "service": "Gmail", "emailVerification": 1 }, "database": { "adapter": "sails-postgresql", "user": "admin", "password": "adminpassword", "port": "5432", "host": "localhost", "database": "airmed" }, "session": { "name": "sails.sid", "secret": "secretKey", "redis": { "url": "redis://: [email protected]:6379/15", "host": "127.0.0.1", "port": 6379, "pass": "redisPassword", "db": 15 } }, "ipfs": { "host":"127.0.0.1", "port":"5001" } }

Edit config/policies.js

For testing purposes, remove comment from line 20. That is, line

//'*': 'isHTTPS',

should now look like

'*': 'isHTTPS',

Edit Hyperledger configuration file

In the file fabric-api/config/configfile.yaml, you should replace the default admin certificate paths with the actual path of your project. Please note that you should only modify paths from adminPrivateKey in Line 44 under Org1, and in Line 56 under Org2. Everything else must remain unaltered.

As a further advice, please make sure that fabric-sample and airmedfoundation-terminal are in the same directory.

The paths should look as follows:
/home/root/Desktop/fabric-sample
/home/root/Desktop/airmedfoundation-terminal

Running the application

Running the application is very simple. You just need to:

  • Run IPFS
ipfs daemon &
  • Run the server
node ./node_modules/sails/bin/sails.js l --redis --safe
  • Run the sync process
./init.sh &

And now you're ready to go!


Contact: This open source project is brought to you by The Chain, a software shop specialized in the development of applications and services based on blockchain technology and artificial intelligence. Any questions that might arise should be sent to the project's maintainers. We will be happy to assist you.

License: This project is under the GNU Affero General Public License v3.0.