This project consists of multiple components. Follow the instructions below to start each service. you can do it following instructions in the dependency section below. Project description is also available in a section below.
- React App:
./frontend - FastAPI Server:
./fastapi/pyapp - Hardhat Node:
./hardhat - IPFS Daemon: Runs as a background process
-
Navigate to the project directory:
cd /home/dinsystems/projects/DINv1MVC -
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/pyapp - Start Command:
source /home/dinsystems/projects/pyDIN/.pyDIN/bin/activate cd ./fastapi/pyapp 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 npx hardhat compile - 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:
cd /home/dinsystems/projects/DINv1MVCcd ./hardhat
npm init -y
npm install --save-dev hardhat
npx hardhat initpython3 --version
cd /home/dinsystems/projects/pyDIN
python -m venv .pyDIN
cd /home/dinsystems/projects/DINv1MVC/fastapi/
source /home/dinsystems/projects/pyDIN/.pyDIN/bin/activate
pip install fastapi uvicorn
pip freeze > requirements.txt
pip install -r requirements.txt
mkdir pyapp
cd ./pyapp
mkdir Dataset
mkdir Dataset/clients
mkdir Dataset/train
mkdir Dataset/test
mkdir data
mkdir models
mkdir models/clients
mkdir models/modelowner
mkdir models/validatorssudo apt update && sudo apt upgrade -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 --version
ipfs init
ipfs daemoncd ./DINv1MVC
npx create-react-app frontend
cd ./frontend
npm installcd /home/dinsystems/projects/DINv1MVC/fastapi/pyapp
rm -rf Dataset/clients/*
rm -rf Dataset/train/*
rm -rf Dataset/test/*
rm -rf data/*Note: Make sure to click
Distribute Datasetbutton in the running frontend react app to distribute the dataset on first run.
-
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 | bashwget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bashAfter running the installation script, you need to add the following lines to your shell configuration file (
~/.bashrc,~/.zshrc, or~/.bash_profiledepending 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
zshusers: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