Search code examples
loopbackjshyperledger-composer

Web app using Hyperledger Composer REST Server


I'm building a Web application as an interface for a Business Network. I would like to reuse some of the REST Server functionality (e.g. GitHub login and storing cards in a MongoDB database) but do a few things differently. For example, I want to generate all cards on the server, so that the users won't have to upload them. Plus, I need to serve the static files from somewhere. I'm trying to figure which architecture I should use.

The app would serve 10's - 100's of users, potentially scaling to 100's of 1000's.

So far, I thought about these options: 1. Have a different app on a different port; REST endpoints called from the client. 2. Same, but REST endpoints called from the server (also means that I'll have to forward the login process somehow). 3. Extend the REST server with custom functionality (is it possible?). 4. Don't use the REST server but steal some of its code to use it in my app.

Questions:

  • Is it possible to extend the REST server with custom routes?
  • What is the recommended architecture for a Web interface for a Business Network in production?

Solution

    1. Yes you can take the REST server and customise, its open source
    2. See https://github.com/hyperledger/composer-knowledge-wiki/blob/latest/knowledge.md#information_source--node-js-application-development-questions-eg-build-real-time-apps-login-etc for some insights, resources and guidance. The business network is essentially a smart contract (including transaction logic, code, queries, access control lists etc etc) deployed to a blockchain runtime (running as native chaincode in Fabric). Your web interface to interact with the ledger (ie through business network cards stored in wallets (whether server based or cloud based ) could be using Angular (app) / Typescript / React JS (for UI elements) but the salient point is that you can interact with the deployed business network card using the Composer APIs, JS and REST. The application users would interact from the app, using their business network cards, which connection info, the user's blockchain identity and some other metadata. See more info here on Composer's architecture.