Coder Social home page Coder Social logo

foodprintlabs / foodprint Goto Github PK

View Code? Open in Web Editor NEW
59.0 7.0 46.0 110.29 MB

Algorand dApp for blockchain-enabled food transparency and traceability in local food supply chains. For use by smallholder farmers, food co-operatives and consumers.

Home Page: https://www.foodprintlabs.com

License: MIT License

JavaScript 27.05% HTML 35.83% CSS 9.99% SCSS 1.59% EJS 25.53%
dapp web3 food-supply-chain traceability transparency foodprint blockchain algorand

foodprint's Introduction

FoodPrint

FoodPrint is a digital, blockchain-enabled, farm-to-fork (fresh produce) supply chain platform for smallholder farmers. FoodPrint is designed to:

  • Simplify production and harvest data collection for smallholder farmers.
  • Directly connect them to market opportunities - including but not limited to intermediaries such as markets and retailers, as well as consumers.
  • Provide them with access to blockchain-based financial and transactional services.

Overview

FoodPrint has 5 types of users:

  • Super User Admin

The Super User is responsible for setting up the infrastructure and system configuration.

  • System Admin

The System Admin is responsible for the day-to-day running of the platform, providing user support (on-boarding and operations) and basic configuration.

  • Farmer

The Farmer is responsible for capturing produce data at harvest time onto FoodPrint. The Farmer also transports the produce to the Market as per order from Market Admin.

  • Intermediary e.g. Wholesaler, Retailers, Farmers Market Admin etc

The Intermediary is responsible for receiving produce from the Farmer and capturing the relevant data onto FoodPrint.

  • Consumer

The consumer is the final actor in a food supply chain. They purchase fresh produce from an intermediary. The consumer can scan a barcode associated with produce and view the verified produce information and supply chain stories i.e. view information on the produce they are buying, it's source and journey, hence from farm-to-fork. Android versions 8 & 9 and iOS versions 11 & 12 can automatically scan QR codes using the camera app.

IDE Setup

IDE of choice is VS Code

Code Formatter is Prettier

Make sure prettier is installed i.e. npm install --save-dev --save-exact prettier

Project specific Prettier config file is .prettierrc.json which is in the project root

Make sure Prettier extension is installed in VS Code (run following command in VS Code ext install esbenp.prettier-vscode)

Project specific VS Code config file is .vscode/settings.json

To run Prettier CLI npm run format (which is defined in package.json)

To run Prettier manually for specific file formats prettier --write 'src/**/*.{ts,tsx}'

Credit - https://glebbahmutov.com/blog/configure-prettier-in-vscode/

Installation (Development Environment)

In order to run FoodPrint, an environment with the following is required:

  • Node.js
  • Algosdk
  • Bootstrap
  • MySQL
  1. Install node dependencies.
$npm install
  1. Create a blank MySQL database

  2. Create a .env file in the root directory of your project. Add environment-specific variables on new lines in the form of NAME=VALUE. For example

NODE_ENV=staging
PORT=3000
APP_NAME=REPLACE_ME
SESSION_SECRET=REPLACE_ME
EMAIL_ADDRESS=GMAIL_EMAIL_ADDRESS
EMAIL_PASSWORD=GMAIL_EMAIL_PASSWORD
WEBAPP_PASSWORD=WEBAPP_PASSWORD
EMAIL_HOST=EMAIL_HOST
EMAIL_PORT=EMAIL_PORT
TEST_EMAIL_ADDRESS=TEST_EMAIL_ADDRESS
EMAIL_OVERRIDE=OVERRIDE_EMAIL_ADDRESS
BLOCKCHAINENV=TESTNET
DEV_ALGOD_API_KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
DEV_ALGOD_SERVER=http://localhost
DEV_ALGOD_PORT=4001
DEV_ALGOINDEXER_PORT=8980
TESTNET_ALGOD_API_KEY=REPLACE_ME
TESTNET_ALGOD_SERVER=https://testnet-algorand.api.purestake.io/ps2
TESTNET_ALGOINDEXER_SERVER=https://testnet-algorand.api.purestake.io/idx2
TESTNET_ALGOD_PORT=
MAINNET_ALGOD_API_KEY=REPLACE_ME
MAINNET_ALGOD_SERVER=https:https://mainnet-algorand.api.purestake.io/ps2
MAINNET_ALGOINDEXER_SERVER=https://mainnet-algorand.api.purestake.io/idx2
MAINNET_ALGOD_PORT=
ACCOUNT1_ADDRESS=REPLACE_ME
ACCOUNT1_MNEMONIC=REPLACE_ME
ACCOUNT2_ADDRESS=REPLACE_ME
ACCOUNT2_MNEMONIC=REPLACE_ME
DB_DIALECT=REPLACE_ME
DB_URL=REPLACE_ME
USER1_PASSWORD=REPLACE_ME
USER2_PASSWORD=REPLACE_ME
USER3_PASSWORD=REPLACE_ME
USER4_PASSWORD=REPLACE_ME
USER5_PASSWORD=REPLACE_ME
USER6_PASSWORD=REPLACE_ME
USER7_PASSWORD=REPLACE_ME
DO_BUCKET_NAME=REPLACE_ME
DO_KEY_ID=REPLACE_ME
DO_SECRET=REPLACE_ME
DO_ENDPOINT=REPLACE_ME
TWILIO_ACCOUNT_SID=REPLACE_ME
TWILIO_AUTH_TOKEN=REPLACE_ME

You can then access the variables in your code using process.env e.g. console.log(process.env.NODE_ENV)

  1. Start the web server (Express) and navigate to http://localhost:3000/ in your browser.
$npm run dev

Production Deployment

  1. To deploy to a production server e.g. heroku, first bundle and uglify then deploy
$npm run build
$npm run start

Other

  • Generating Sequelize Models from an existing database using Sequelize Auto. For convenience Sequelize Auto provides a programmatic api that can be used in the generation of models in addition to their cli. You can use the convenience script src/js/sequelise_auto_export.js to generate required models by supplying the table names in the tables section of the options object. The script establishes a connection to the database using the config data specified in step 3. Execute the command below within src/js to generate the models for the specified tables:
node sequelise_auto_export.js

The generated models can be found in ./models

  • Creating sequelize migration (which creates a js file in migrations folder and will need to be commited)
npx sequelize migration:create --name name_of_new_db_column

Run the migration

npx sequelize db:migrate --url ‘mysql://username:password@localhost:3306/databasename'
  • Generate test UUID's from command line (i.e. server side).
$node
>const uuidv4 = require('uuid/v4')
>uuidv4()
  • Generate test QRCode's from command line (i.e. server side).
$node
>var QRCode = require('qrcode');
>let produceUrl = "http://www.google.com";
>let supplier = "supplier";
>let produce = "Storage";
>var res2 = await QRCode.toDataURL(produceUrl);
>res2

Deploy to Heroku

Summary

Create app on Heroku

login to Heroku via command line i.e. heroku login

add heroku remote to your local repo i.e. heroku git:remote -a app name

Link to Git Repo

Update env variables

Create database addon Postgres (natively supported by Heroku) or ClearDB which is MySQL -
https://devcenter.heroku.com/articles/cleardb


$ heroku addons:create cleardb:ignite
$ heroku config | findstr CLEARDB_DATABASE_URL
$ heroku config | set DATABASE_URL= # MySQL database url retrieved from above line

Deploy repo to Heroku

$ git push heroku main

Install Heroku releases retry plugin (if you deploy to heroku and it fails, you no longer have to commit a dummy txt file in order to bump up the latest commit hash so that your next push up to heroku will trigger a deploy.)

$ heroku plugins:install heroku-releases-retry

Then to retry failed deploy

$ heroku releases:retry

Login to Heroku bash

$ heroku run bash

If everything went well, you’ve successfully deployed your Node.js app to Heroku. To open your app, run:

$ heroku open

If you ever need to restart/stop the Heroku app

$ heroku ps:restart web -a nameofapp
$ heroku ps:stop web -a nameofapp

If you need to run sequelize migrations in Heroku (although this is included in the build step in package.json)

$ heroku run npx sequelize-cli db:migrate --url 'mysql://root:password@mysql_host.com/database_name' --app nameofapp

Alternatively

$ heroku run npm run build -a name-of-app

Tail Heroku logs

$ heroku logs --tail

Migrate data from MySQL to local Postgres using pgloader

$ pgloader mysql://username:password@localhost/mysqldbname postgresql:///pgdbname

Push local Postgres to Heroku (v1)

$ heroku pg:psql heroku-db-name --app nameofapp

Push local Postgres to Heroku (v2)

$ PGUSER=postgres PGPASSWORD=password123  heroku pg:push postgres://localhost/example <heroku-db-name>

Reset Heroku Postgres database (i.e. truncate)

$ heroku pg:reset

Backup Heroku Postgres database

$ heroku pg:backups:capture
$ heroku pg:backups:download

Previous contract details

Initial contract was deployed at Ethereum Testnet (rinkeby) at address https://rinkeby.etherscan.io/address/0xfC4d26073650887069dFa7Da686A491535ab8Fd4.

This was followed by a deployment to the Matic Testnet (mumbai) at address https://mumbai.polygonscan.com/address/0x650168110ADa1f089D443904c6759b7349576A0d,

Latest version of FoodPrint is integrated with the Algorand TestNet via the algosdk and PureStake service.

Supported Browsers

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Samsung
Samsung
Opera
Opera
IE11, Edge Supported Supported Supported Supported Supported Supported

foodprint's People

Contributors

danielmaaron avatar dependabot[bot] avatar jajukajulz avatar natashaoa avatar nkululekombhele avatar rideam avatar rungwe avatar thandeka25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

foodprint's Issues

Request For Demo Video Of This Project

Hi Team,
First of all very thankful This is very nice project and very helpful.
I successfully clone, configured and run on my local machine. Now i need flow how to use this project did you have any demo video/ Flow diagram of this project. It could be very helpful for me.
I successfully SignUp and response Message Recieved "Your registration has been submitted and is currently under review by the FoodPrint Team! You will be notified of status updates via the email you provided."
But when i go to DB then no record found in any DB Table and also no email received. I also configured email address and password in .env file. Please help
Thanks,

QR code not working

Hi!
The qr code is generated but after scanning the link of this qr code shows "Not found". Due to this the food cannot be tracked. Some features are not shown in the website like Market Check in , weekly, market subscription, etc. The app is not fully developed and some elements are missing or not working. Kindly look into this issue.

when I ran the command truffle compile, I found the below error.

Dear Sir,
I was trying out your application, but I encounter some difficulties. Could you please take a look at it? Thank you very much.

Error: ENOENT: no such file or directory, open '.infurakey' at Object.openSync (fs.js:440:3) at Object.readFileSync (fs.js:342:35) at Object.<anonymous> (/Users/dannyng/Desktop/foodprint/truffle-config.js:24:22) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Module.require (internal/modules/cjs/loader.js:849:19) at Object.require (internal/modules/cjs/helpers.js:74:18) at Function.load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:161:1) at Function.detect (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:150:1) at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/compile.js:68:1) at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:136:1) at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/cli.js:56:1) at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/webpack:/webpack/bootstrap:19:1) at /usr/local/lib/node_modules/truffle/build/webpack:/webpack/bootstrap:83:1 at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:89:10) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) at internal/main/run_main_module.js:17:11 Truffle v5.1.46 (core: 5.1.46) Node v12.13.0

Farmer and Admin dashboard error

When trying to access Admin and Farmer dashboard, it is showing " Error:
Unexpected Error occured"
image
Kindly resolve this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.