- Usage instructions
- Prerequisites
- Installation Steps
- Troubleshooting on starting fabric network
- Architecture
- Components
- API Documentation
- Scenario
This guide covers the installation and setup process for the REC System, including agent configuration and Fabric network deployment.
-
Ubuntu version = 22.04
-
Node.js version = 20.10
-
Docker
-
Add docker to sudo group to use docker without using sudo
-
Redis server
- using docker
docker run --name redis-server -p 6379:6379 -d redis
-
Install JQ by running command
sudo apt install -y jq
The following steps will set up and configure the Fabric network:
- Copy the .env.sample file to a new .env file, and update all path variables according to your local setup.
cd service/rec/server
cp .env.sample .envDo not forget to change the path variables
- Run
installPrerequisite.shonce during the initial server setup to install all necessary dependencies:
cd service/rec
./installPrerequisite.sh- Start the Hyperledger Fabric network and deploy the chaincode:
./startNetwork.sh- A Redis server must be running either on Docker or localhost using the default port. To start a Redis server using Docker:
docker run --name redis-server -p 6379:6379 -d redis- Start the server. This will also start the Fabric Subscriber Service which is connected with the REC Agent (Publisher)
cd service/rec/server
npm run devFabric server will run at PORT 3005
- Navigate to the agent directory and install dependencies. This SDK includes both REC Agent and Client Agent functionalities.
cd agent
npm install
- Add the following variables to your
.envfile:
FABRIC_API='http://localhost:3005'
- Start an organization api:
npm run org <email> <port>
- Start a client api:
npm run client <email> <port>
Replace <email> with the actual email of the organization or client, and <port> with the port number on which you want the API to run. Example: npm run org org1@rec.com 5000 or npm run client client1@rec.com 5001
Configure and start the Organization Interface as follows:
- Add the following variables to your
.envfile:
FABRIC_API=http://localhost:3005
- Navigate to the
organizationInterfacedirectory, install dependencies, and start the interface server:
cd ../organizationInterface
npm install
npm run dev
Organization Interface server will run on port 3000
- Please open the client and organization interface in a separate window (not a separate tab, same window) or browser for each client and organization at the same time. This may cause a conflict with the local storage data of separate clients or organizations in the browser.
Configure and start the Client API as follows:
- Add the following variables to your
.envfile:
JWT=secret
FABRIC_API=http://localhost:3005
- Navigate to the
clientInterfacedirectory, install dependencies, and start the interface server:
cd ../clientInterface
npm install
npm run dev
Client Interface server will run on port 3001
- Navigate to data directory and install dependencies
cd data
npm install
- Run this command to generate data
npm run dataGenerate
- You can view data format in rec2.csv file
- To understand to process of data generation, view data-gen.js file.
- Navigate to data directory and install dependencies
cd data
npm install
- Copy environment data from .env.sample
cp .env.sample .env
npm run repeatedApiCall
.env.sampleconatins all the variables needed to run the realtime api call. Please carefully set the variables in .env file.- To understand to process of realtime api call, view repeatedApiCaller.js file.
If there is an issue with "Peer binary and configuration files not found..", please follow this instructions otherwise leave it.
- Stop all running docker containers and clear docker images and containers by running
docker system prune -a. - Clone the fabric sample with fabric version 2.5.2 and fabric-ca-version 1.5.6 in a separate directory.
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s -- 2.5.2 1.5.6
- Copy the bin file from fabric-samples directory and replace rec_dlt/service/bin with it.
- Interface
- Agents
- Fabric API
- Message Broker
| Method | Endpoint | Request Body | Response | Description |
|---|---|---|---|---|
| POST | /create-invitation | {} | Returns a new oob invitation | Creates and returns a new out-of-band invitation |
| POST | /receive-invitation | {invitationUrl} | Establishes connection with given invitationUrl | Initiates a connection and returns invitation details |
| POST | /receive-message | {message, connectionId} | Sends message to a specific connection | Sends a message to a specific connection and returns a response |
| Method | Endpoint | Request Body | Response | Description |
|---|---|---|---|---|
| POST | /receive-invitation | {invitationUrl} | Establishes connection with given invitationUrl | Initiates a connection and returns invitation details |
| POST | /send-message | {connectionId, messageData, organizationId: email} | Sends message to organization node and returns specific message | Sends a message to a recipient node and returns a specific response |
| Method | Endpoint | Request Body | Response | Description |
|---|---|---|---|---|
| POST | /client/register | {name, email, agentEndpoint, password} | Returns success message | Registers a new client using given credentials. |
| POST | /client/login | {email, password} | Returns success message, clientData | Logs in a client and sets an authorization cookie. |
| POST | /organization/register | {name, email, agentEndpoint, password} | Returns success message | Registers a new organization using given credentials. |
| POST | /organization/login | {email, password} | Returns success message, clientData | Logs in a organization and sets an authorization cookie. |
| GET | /organization/all | N/A | Returns all organization data | Fetches all organizations. |
| GET | /client/connections | N/A | Returns connected organization data | Fetches client connections if the user is authenticated, otherwise returns a 401 error. |
| GET | /organization/realtime-data/:connectionId | N/A | Returns realtime data of a specific client | Fetches real-time data if the organization is authenticated. |
| GET | /organization/connected-organization/clients/{email} | N/A | Returns array of clients data | Fetches the list of clients of a different organization connected to this user based on the provided email. |
| GET | /organization/connection/organizations | N/A | Returns array of connected organizations | Fetches the list of organizations connected to the current user. |
| GET | /organization/sorted-data/:connectionId | N/A | Returns array of message data sent by a client | Fetches sorted data for a connected client based on connectionId. |
| POST | /organization/connected-organization/clients/sorted-data | {connectedOrganizationId, connectionId} | Returns array of message data sent by a client | Fetches sorted data sent by a client to a connected organization. |