Skip to content

Nas2020/Perishable-Supply-Chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perishables supply chain

Blockchain solution to track batteries through a supply chain, using Solidity, Node.js and ReactJS. Presented as final assingment for BCDV1011 - Design Patterns for Blockchain from Blockchain Development program from George Brown College.

For architecture, flow diagrams and more detailed explanation, please check Project Documents folder.

Cherukkatil Naseer  |   Henry Eriko Mwenge  |   Lorran Sutter  |   Wanja Mascarenhas  |   Zakariya Jasat

Preview

🏃 How to run

Open your terminal in the folder you want to clone the project

# Clone this repo
git clone https://github.com/Nas2020/Perishable-Supply-Chain.git

# Go to the project folder
cd Perishables-supply-chain

To run the application you will need to set your own configurations of port, database, private key and blockchain emulator uri. Create the following .env file in the indicated path and format with your customized configurations:

// ./backend/.env

PORT=5000
MONGODB_URI_DEV="YOUR_DEV_MONGO_URI"
MONGODB_URI_TEST="YOUR_TEST_MONGO_URI"
PRIVATE_KEY="YOUR_STRONG_PRIVATE_KEY"
BLOCKCHAIN_EMULATOR_URI="http://127.0.0.1:9545/"

Now you will need three opened terminals to run the project. One for truffle to simulate the EVM, another one for the server and a third one for the frontend.

Truffle will run on http://127.0.0.1:9545/

Server will run on http://localhost:5000/

Frontend will run on http://localhost:3000/

## In the first terminal ##

# Go to smart contract folder
cd smart_contract

# Init truffle
truffle develop

# Run migrations
migrate

The previous command will generate a new ABI and write contract address in a JSON file. You do not have to worry about importing these info in the backend though. Also you may change the smart contract and run migrations again to see your changes.

If you change your contract, you will have to run migrations again. Just type the following command:

# Run migrations again
migrate --reset

Install backend dependencies:

## In the other terminal ##

# Go to backend application
cd backend

# Install dependencies
npm install

To kick-start application data, you can run populate script, which will write basic data in truffle develop blockchain environment and database:

npm run populate

Run the project:

# Run the project
npm run start

# Or to use nodemon
npm run dev

Finally run the frontend application:

## In the third terminal ##

# Go to frontend application
cd frontend

# Install dependencies
npm install

# Run the project
npm run start

Login credentials

  • username: distributor
  • password: 123456

💉 Tests

Both Smart Contract and backend application have its own tests suite. To run the tests execute the following commands:

# Smart Contracts folder
cd smart_contracts

# Run tests
truffle test

# Backend folder
cd backend

# Run tests
npm run test

📖 Resources and technologies 💻

  1. Smart Contract

  2. Backend

    • Express.js - web application framework
    • MongoDB - NoSQL database
    • Mongoose - object data modeling (ODM) library for MongoDB and Node.js
    • Async - library to perform asynchronous operations
    • Express validator - middleware to validate data
    • Bcryptjs - library to perform cryptography
    • JWT.IO - JSON Web Tokens to allow, decode, verify and generate JWT
    • Jest - library for tests
    • Web3.js - interact with smart contracts
    • Dotenv - loads environment variables from a .env file
  3. Frontend

About

BCDV1011-Group Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published