Skip to content

dhealthproject/BlockRabies-DTPS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlockRabies-DTPS

License Discord Telegram

Introduction

BRApp is the BlockRabies application used for managing event data around the movement of Rabies vaccines from the manufacturer all the way to the patient. The core objective of BlockRabies is to write this data to the blockchain in order to enable incorruptible audits of the entire supply chain.

At present, the BlockRabies application is written in PHP and installed directly on the servers at the various clinics and supply chain facilities. On the other hand, the dHealth blockchain libraries (the “dHealth SDK”) are implemented using TypeScript and run using node.js. Thus, any transaction that is generated by the BRApp must use the TypeScript libraries in order to generate digital signatures for the blockchain transactions.

This document describes a proxy server, written in node.js, that enables the PHP BRApp instance to send data to the blockchain. This is a temporary solution until the PHP app can be upgraded to interface directly with locally installed dhealth client libraries written in node.js.

Overview

alt text

  1. The BlockRabies app is configured to set labels for each role for which it needs to submit transactions. Example: “Bouake Clinic” or “Abidjan Pharmacy”.

  2. The dHealth Transaction Proxy Server (DTPS) is configured with: the allow-list of IP addresses from which requests should be accepted. a map of each BlockRabies label and its corresponding dHealth wallet keys.

  3. During operation, the BlockRabies app sends an API request to the DTPS, specifying the source and destination labels and the data to be announced. The data should be plain text and limited to 1000 characters.

  4. The DTPS creates a transaction using the private key and public key corresponding to the specified source and destination labels, and including the specified data as the transaction payload.

  5. The success code from the transaction request is returned to the caller as the result of the API call.

API specification

There will be a single HTTPS API endpoint named /announce.

Each request will include an authorization code.

The post data will be a JSON format plain text, with two fields:

  • sender: this uniquely identifies the entity on whose behalf the announcement will be made.
  • data: this is an application-specific json formatted string that will be included in the blockchain transaction. It is NOT interpreted by the DTPS, but instead directly attached to the transaction.

The HTTPS result code will indicate the success or failure of the blockchain transaction creation operation.

Example:

POST https://dtps.dhealth.cloud/announce
post-data:
{
  “sender”: “ML-bouake-clinic”,
  “data”: {
    “event”: “RECEIVED”,
    “entity”: “mali-supplier1”,
    “serial_numbers”: “abc123,def456,geh789,ijk012”
  }
}
result: http response code corresponding to transaction creation status.

Deployment

Ideally, the DTPS should be hosted on a cloud service to avoid service interruptions. Given its stateless nature, it can most easily be implemented as a firebase cloud function (equivalent to an AWS lambda function), that is able to communicate with any one of several available blockchain nodes.

Functions found here

Following functions are defined and exported with this library:

Function Description
dtps This function acts as the dHealth Transaction Proxy Service, which allow BlockRabies clients to send transactions to the dHealth blockchain network with given data.

Install Notes

Development

Serving function only

Serving the cloud functions locally works by executing the following command from the root directory of the project:

npm run serve

This will serve the cloud functions locally at http://localhost:8083/blockrabies-dtps/us-central1/dtps.

Serving with an emulator of Firestore and Hosting

To run the cloud function locally with an emulator of Firestore and Firebase Hosting, execute the command:

firebase emulators:start

This command will serve:

Deployment

Cloud Function

Cloud functions can be deployed to Firebase using the following command:

npm run deploy

Cloud Hosting

Hosting site can be deployed to Firebase using the following command:

firebase deploy --only hosting:dtps

Why Firebase Hosting ?

Unchangable domain names of Firebase functions will be similar to https://dtps-abcd12345-uc.a.run.app which is hard to enter and remember.

The hosting site acts as a proxy server that allows the function to have simpler, more friendly domain names (e.g. https://dtps.com).

Custom domain can be configured following this guide.

License

Copyright 2023-present dHealth Network, All rights reserved.

Licensed under the LGPL v3.0

About

BlockRabies dHealth Transaction Proxy Service (DTPS)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages