This guide covers the installation and setup process for the REC System, including agent configuration and Fabric network deployment.
- Node.js version >= 18.18
- Redis server
- Docker
- Add docker to sudo group to use docker without using sudo
- Install JQ by running command
sudo apt install -y jq
- Navigate to the agent directory and install dependencies. This SDK includes both REC Agent and Client Agent functionalities.
cd agent
yarn
- Add the following variables to your
.env
file:
FABRIC_API='http://localhost:3005'
- Start an organization api:
yarn org <email> <port>
- Start a client api:
yarn 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: yarn org org1@rec.com 5000
or yarn client client1@rec.com 5001
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 .env
Do not forget to change the path variables
- Run
installPrerequisite.sh
once 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 run Redis 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 dev
Fabric server will run at PORT 3005
Configure and start the Organization Interface as follows:
- Add the following variables to your
.env
file:
FABRIC_API=http://localhost:3005
- Navigate to the
organizationInterface
directory, 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
.env
file:
JWT=secret
FABRIC_API=http://localhost:3005
- Navigate to the
clientInterface
directory, 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
- To understand to process of realtime api call, view repeatedApiCaller.js file.
- 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. |