This project implements an MQTT data handling system that saves received data into chunks. It connects to an MQTT broker, processes incoming messages, and uploads the data to IPFS. The IPFS Content Identifiers (CIDs) are then stored on an Ethereum smart contract.
To better understand the data flow within the Stakeholder Aggregator, refer to the following diagrams:
The project directory is organized as follows:
-
src: Contains the main source code files for the MQTT data handling system.
- mqtt: Contains the files related to MQTT communication and data handling.
- data: Contains the files related to data processing.
- smartcontract: Contains the Solidity smart contract code and compiled contract artifacts.
- utils: Contains utility files used throughout the application.
- index.js: The main entry point of the application.
-
config.json: Configuration file with various settings for the application. -
Dockerfile: Dockerfile for containerization of the application. -
package.json: Node.js package file specifying dependencies and scripts. -
IoTSimulator: An external repository simulating data and acting as the MQTT broker for testing.
- Clone the repository to your local machine using Git:
git clone https://github.com/BlockOasis/stakeholderAggregator.git
cd stakeholderAggregator- Install the project dependencies:
npm install- Update the
config.jsonfile with your specific configuration settings. Provide the necessary private keys, API credentials, contract address, and other parameters.
To start the MQTT data handling system, run the following command:
npm startThe application will connect to the MQTT broker (IoT Simulator) specified in the config.json file, handle incoming data messages, and upload data chunks to IPFS. The IPFS CIDs will be stored on the Ethereum smart contract.
-
Make sure you have Docker installed on your system.
-
Build the Docker image using the provided Dockerfile:
docker build -t stakeholderaggregator .- Run the application in a Docker container:
docker run -d --name stakeholderaggregator-app stakeholderaggregatorThe application will be running inside the Docker container, connecting to the MQTT broker (IoT Simulator) and handling incoming data messages as before.
-
Ensure that the IoT Simulator (acting as the MQTT broker) is set up and running for simulating data to test the MQTT data handling system.
-
Take care of sensitive information such as private keys and API secrets. Avoid committing them to version control and keep them secure.
-
For production deployments, consider securing your MQTT broker, IPFS service, and Ethereum smart contracts, and follow best practices for handling and storing sensitive data.