Thursday, June 27, 2019

IoT And Blockchain – Finally The Right Technologies for Food Supply Chain Track & Trace



A Personal Experience with Food Safety – the Need for Track & Trace

It was 2013. I was staying in the posh Grand Hyatt Shanghai. As the March sun fought through the all too common afternoon haze, I sat in my room high above the city.  Looking down from above the 80th floor at a river nearby, I pondered what I wanted for dinner. Pork, for sure, should be on the list. Images of pork dishes rushed immediately to my head: pork dumplings, chasu, mapo tofu, twice cook pork, soy sauce braised pork, sweet-and-sour pork - all tantalized my appetite. But alas, pork was scratched off my list.  You might wonder why? Pork is a main staple in China – so much so that China ranks second in the world in terms of pork consumption by capita (https://www.pork.org/facts/stats/u-s-pork-exports/world-per-capita-pork-consumption/).  With so much consumption, they should really know their pork. So why no? The answer is: food safety.

I Love Pork – Just Not Today Please

Around the time of my visit, there were reports in the news media of dead pigs being dumped into the Huang Pu Jiang, a major river that ran through Shanghai (and the very same river that I was looking at from high up). As the hours passed, more details emerged. The dead pigs were being dumped illegally into this river by farmers to rid themselves of diseased pigs. What compounded matters and ultimately led me to delist pork was - these dead and diseased pigs were being plucked out of the water by unscrupulous opportunists, then resold as pork.  But China is not alone in food safety. The United Kingdom had to fight “mad cow” disease. The United States had multiple recalls of farm products such as romaine lettuce. So what can be done?


Track & Trace Needed For Food Safety, Authenticity, Conditions at Origin

Food safety requires knowing the entire history of food source, and hence a mechanism of track and trace is needed. Tracking is the process and technology needed to tag and record attributes of the food source, such as time, place, and temperature. Tracing is the process and technology needed to view the complete history of the tracked food, such as show the complete journey of the pork chop on your dinner table. The food path can be long – from farm to processor to storage to grocery – on a variety of transportation modes. This long path creates risk and vulnerability for the supply chain. Once track & trace is enabled, there are multiple benefits, including:

  1.  Food safety : Is the pork sourced from a reputable farm?
  2.  Authenticity: Is your Iberico Jamon real?
  3.  Conditions at origin: How do you know if your food is organic, cage-free, or grass-fed?



Challenges of Current Track & Trace Technologies

Track & trace process and technologies have been deployed for decades, including using RFID and serialization technologies. But to achieve true end-end track & trace, data needs to be collected, processed, and responded to in real time. Current track & trace technologies cannot do this for multiple reasons. Some systems are paper based, resulting in erroneous entries and delayed uploading. Some systems are not real time, resulting in urgent data that cannot be responded to in real time.  Separate systems provide different versions of the same data, requiring effort to mapping and/or merging, resulting in mistakes and delays.  


Emerging Technology to the Rescue: Tracking using IoT, Tracing using Blockchain

To address the short comings of exiting track & trace technologies, we can look at the combination of two emerging technologies to help : IoT and Blockchain. IoT is used help track all aspects of food, including place, time, temperature. The pencil and paper method of collecting data replaced with sensors that send error-free data in real time. Think of IoT as the eyes, ears, and nose of the track & trace system. In parallel, blockchain can be used as the central single data store to store the data collected by IoT. So instead of separate systems that stored its version of the truth at the time it deems convenient, data now will arrive in a timely, consistent manner. Think of blockchain as a ledger used to track all of the information gathered by IoT.


Current Examples of Success: Alpha Acid Brewing, World Bee Project Hive Network

There already are early adopters of blockchain and IoT for food track & trace. One example is IBM Food Trust, where you can find multiple types of food being tracked & traced, including coffee and precision agriculture.  Another example is Alpha Acid Brewing. Starting from the condition of the raw materials (hops, malt, and yeast), the entire beer chain is tracked using IoT and traced using blockchain.  In addition in aiding with creating quality beer, the blockchain can also enhance customer drinking experience with information (malt, yeast supplier) about the beer they are drinking.


Conclusion

The case for food supply chain track & trace is not new. However, the technology that currently supports it is old. With the emergence of blockchain, it is now time to finally solve this problem to improve food safety, verify authenticity, and validate the conditions at origin. 

Thursday, March 21, 2019

LAMP Stack Introduction

Abstract :  LAMP (Linux OS,  Apache Web Sever, MySQL Database, PHP Programming Language) is collection of software that work together to provide the backend web server service to a web browser client front end. The LAMP backend web server service uses Apache that can handle complex transactions such as talking to a MySQL database.




Initial Problem and UX Requirements (What):

Craigslist List is a web site where users can browse or search for goods or services to buy or sell. Basic requirements are:

Browse:

  • For Sale : browse things to buy 
  • Services : browse services to rent 
  • Location : localize browse things to buy or services to a region


Post:

  • For Sale : offer things to sell
  • Services : offer services to rent out





Screen Shot 2016-05-03 at 10.55.22 AM.png





Initial Problem and UX Requirements (How):


Once the initial UX requirements is done, it is time to create the specification architecture. Here is the initial web front-end (client) and back-end (server). The red part is the data model and flow. The blue part is the control.



lampp_project.JPG



Front End / Client  (HTML,CSS, JS)


In the screenshot below, you can see a LAMP stack running. The hosting OS is Windows 8. The guest OS is Ubuntu Linux. Ubuntu is running on Windows 8 via VMWare Workstation 12 Player (free). In Ubuntu, the LAMP software was installed - with includes Apache web server, MySQL database server, and PHP.  The client is a web browser, being served by the Apache web browser. The project is located in my home directory (~albert/lamp_class_project).


The starting client web page site is cll.html. There are two major functionalities implemented. One is the browse section such as Books, Lessons, Part-Time, Stockholm. The section functionality is New Post.





finalproj1.png


Server / Back End (PHP, MySQL)

In the HTML, when the  user clicks on a category to browse (say books), the category is linked to a PHP file. The PHP file will execute and it will open a connection to MySQL, submit a MySQL query, then print/echo the results (which will be rendered by HTML where the books link was clicked).



Screen Shot 2016-05-03 at 11.56.21 AM.png


Data Model and Database :


A simple naming convention helps to differentiate between tuple (row), attribute (column), and relation (table). Below, I created a database called "dbHW3".


Screen Shot 2016-05-03 at 12.05.07 PM.png





Data Pre-Population of Categories, Locations  (MySQL)

Here is a SQL command to pre-populate the Craiglist Lite database.

Screen Shot 2016-05-03 at 12.06.29 PM.png


Results:

We showed how a LAMP stack can be used to create a simple "Craigslist Lite" web site to allow a community to browse or search for goods or services to buy or to sell.

finalproj4.png

Sunday, February 3, 2019

Drained - Can Only Blog So Much

2018 was a very quiet year for me - in terms of personal blogging. The biggest reason was that I had to manage one of the micro blog sites at work, and doing that caused me to be creatively drained.  And being creatively drained is not a good start for writing a blog. And so this blog site went quiet.

But if you are curious what I wrote during that gap on my work site, visit:

   https://blogs.oracle.com/author/albert-chiang




Ruby On Rails - Develop. Test. Deploy. Part I

You probably have heard about Ruby on Rails. It is a web app language and framework. It is used by well known brands such as Airbnb, Github, and Shopify (rubyonrails.org). With a language and framework geared for web app building, you can quickly develop a web app, test it (Ruby is guided by Test Driven Development, or TDD), and deploy.





In this blog series titled "Ruby on Rails - Develop. Test. Deploy",  I will cover some key concepts, including:


  • Ruby (an Object Oriented Programming scripting language) and 
  • Rails (the Model View Controller web app framework developed using the Ruby language)
  • GEM  (Ruby package manager)
  • Rake (make utility for Ruby)
  • Database (SQLite, PostGRES, simple data modeling)


We will create an potluck sign-up website for client Neil. The final product will be a Ruby on Rails production website accessible publicly (as opposed to only deployed on a local laptop). This will be demonstrated via a “Thanksgiving Potluck Signup” app hosted on Heroku (a Platform-As-A-Service).