Serverless Computing



Use case: Better Food

A barcode within a photography* is processed so that one gets its Nutri-Score from openfoodfacts.org (JSON API here…). For that, the following workflow is established:

  1. Extract from photography computable data (i.e., barcode (as number)). Extraction relies on homemade image processing versus reuse of appropriate libraries (e.g., javascript-barcode-reader or QuaggaJS in JavaScript).
  2. Compute checksum of barcode (here…) subject to extraction succeeded (correct format is 13 digits with checksum (4 in picture) at 13th position).
  3. Retrieve Nutri-Score from openfoodfacts.org by means of barcode (as number) provided that checksum is correct.

*JavaScript WebRTC technology allows the management of a Web camera within a browser in order to take a photography (example here…).

Download Better_Food.Cloudflare.ts.zip 

Utilities

Installation of technologies requires various Operating System (OS) utilities.

Cloudflare workers

Principles

How to

General process

wrangler login
wrangler whoami
wrangler dev
# Alternative: 'wrangler dev ./ts/index.ts'
wrangler publish
# Alternative: 'wrangler publish ./ts/index.ts --name better_food'

Access: https://better_food.barbierdarnal.workers.dev

wrangler delete
Cloudflare workers

Orchestration

Amazon Lambda
https://www.cncf.io/blog/2021/08/25/webassembly-serverless-functions-in-aws-lambda/

WebAssembly serverless functions in AWS Lambda here

Serverless browser automation with AWS Lambda and Puppeteer here

Serverless Puppeteer on AWS here

VERCEL Lambda
https://vercel.com/docs/concepts/functions/serverless-functions/quickstart https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js https://www.secondstate.io/articles/vercel-wasmedge-webassembly-rust/

WebAssembly serverless functions in AWS Lambda here

Serverless browser automation with AWS Lambda and Puppeteer here

Serverless Puppeteer on AWS here