This project is located at FLAIpoc/HEpoc
relative to the repository root and consists of multiple components. Follow the instructions below to start each service. All the dependencies are installed on this Ubuntu server. If you need to install the dependencies on your machine, you can do it following instructions in the dependency section below. Project description is also available in a section below.
For internal Audum labs members: you can find the project at /home/audumlabs/projects/FLAIpoc/HEpoc
. please cd to /home/audumlabs/projects/FLAIpoc/HEpoc
.
- React App:
./frontend
- FastAPI Server:
./fastapi/pyhefl
- Hardhat Node:
./hardhat
- IPFS Daemon: Runs as a background process
-
Navigate to the project directory:
- internal Audum labs members:
cd /home/audumlabs/projects/FLAIpoc/HEpoc
- external users:
cd to root of repository after cloning cd HEpoc
-
Start the React App:
- Directory:
./frontend
- Start Command:
cd ./frontend npm start
- Access: Open your browser and navigate to http://localhost:3000.
- Directory:
-
Start the FastAPI Server:
- Directory:
./fastapi/pyhefl
- Start Command:
cd ./fastapi/pyhefl uvicorn main:app --host 0.0.0.0 --port 8000 --reload
- Access: API available at http://localhost:8000.
- Directory:
-
Start the Hardhat Node:
- Directory:
./hardhat
- Start Command:
cd ./hardhat npx hardhat node
- RPC Port: The Hardhat node will start a blockchain node with RPC available at port 8545 (http://localhost:8545).
- Directory:
-
Start the IPFS Daemon:
- Start Command:
ipfs daemon
- The IPFS daemon will run as a background process and will use the default port 5001 (http://localhost:5001).
- Start Command:
- Dependencies: Ensure that all required dependencies are installed for each component.
- Documentation: For more details, refer to the official documentation for React, FastAPI, Hardhat, and IPFS.
Happy coding!
This is a poc project to demonstrate the centralized federated learning using Homomorphic encryption (Tenseal) as privacy preserving mechanism. The FL is orchestrated using the smart contracts on the hardhat blockchain. The frontend is built using React, and the backend is powered by FastAPI (python). The IPFS is used as a decentralized storage for the model and data.
-
install python if needed
sudo apt-get install python3
-
Installing NVM (Node Version Manager)
To install NVM (Node Version Manager), follow the steps below:
Run one of the following commands in your terminal to download and install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
After running the installation script, you need to add the following lines to your shell configuration file (
~/.bashrc
,~/.zshrc
, or~/.bash_profile
depending on your shell):export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
echo 'export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"' >> ~/.bashrc echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrc
Or for
zsh
users:echo 'export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"' >> ~/.zshrc echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.zshrc
Once you've added the necessary lines to your shell configuration file, reload it by running:
For
bash
:source ~/.bashrc
Or for
zsh
:source ~/.zshrc
Finally, verify that NVM was installed correctly by checking its version:
nvm --version
If everything went well, you should see the version number of NVM printed in your terminal.
You're now ready to use NVM to manage different versions of Node.js!
-
Install Node.js v20.18.1 via NVM
nvm install v20.18.1 node -v
-
React
- Directory:
./frontend
- Start Command:
cd ./frontend npm install npm start
- Directory:
-
FastAPI
- Directory:
./fastapi/pyhefl
- Start Command:
cd ./ # to root of repo sudo apt update sudo apt install python3-venv python3 -m venv .venv source .venv/bin/activate cd ./fastapi pip install -r requirements.txt cd ./pyhefl/utils mkdir aggregator mkdir clients mkdir decrypter mkdir validator
- Access: API available at http://localhost:8000.
- Directory:
-
Hardhat
- Directory:
./hardhat
- Start Command:
cd ./hardhat npm install npx hardhat compile
- Directory:
-
IPFS
To install IPFS on Ubuntu, follow these steps:
sudo apt update && sudo apt install wget -y
wget https://dist.ipfs.tech/kubo/latest/kubo-linux-amd64.tar.gz
tar -xvzf kubo-linux-amd64.tar.gz
sudo mv kubo/ipfs /usr/local/bin/ipfs
ipfs --version
ipfs init
ipfs daemon
This will start the IPFS node and make it ready for use.