Viva guide

Before you start

Start with start.sh or start.bat and wait for "Scanner service ready" in the console. Run the test page once, allow the camera on the terminal, and place the terminal and wallet tabs side by side. Keep a bottle, a can and a non-recyclable object (or photos of them) within reach.

Five-minute demo script

How the data moves

Terminal tabCamera frame and load-cell weight, live preview only
→
serve.py /apiSame-origin proxy; admin routes and project files are not exposed
→
Scanner serviceFastAPI: MobileNetV2 model, tariff rules, payout
→
SQLite ledgerDeposit and wallet credit in one transaction
→
Wallet tabPinged by the terminal, then refetches from the server

A real deployment moves the service and database to a cloud host and adds user login; the screens stay the same.

Likely questions and answers

Where is the money stored?

In a SQLite ledger owned by the scanner service, not in the browser. Each scan is recorded and the wallet credited inside one BEGIN IMMEDIATE transaction, balances have a database check that they never go negative, and the browser only ever sees the result.

What would a real machine use?

Load cells with an HX711 amplifier for weight, a camera with an on-device model such as MobileNet or YOLO for classification, a microcontroller or Raspberry Pi to run the logic, and MQTT or a REST API to send each transaction to a cloud database. Payouts would go through UPI.

Is the AI real?

Yes. It is a MobileNetV2 model fine-tuned on four classes (plastic bottle, aluminium can, plastic bag, other) and scores 86% accuracy on the held-out test set. It runs on the server; anything under 75% confidence is rejected and the user is asked to rescan.

How do you stop people cheating?

The browser cannot set the payout: the server re-classifies the deposited frame and applies its own tariff. Weight is only paid after the item is classified as payable, and must be between 100 g and 500 g. In this simulation the weight comes from a slider; a real machine reads the load cell on its own controller. Real machines also add barcode, shape and transparency checks and per-user rate limits.

Why is the minimum 100 g?

Very light items are usually caps, wrappers or sensor noise rather than a whole container. The threshold is one setting, ECOREWIND_MIN_WEIGHT_G, on the server, and the terminal reads it from /api/rates.

Why store money as paise?

Floating-point numbers cannot represent values like 0.1 exactly, so repeated additions drift. Integers never do. The wallet stores whole paise and only formats rupees for display.

How does the second tab update without a reload?

After a deposit the terminal sends a BroadcastChannel message to other tabs of the same origin, and the wallet refetches from the server. The wallet also polls every 5 seconds, which picks up changes made elsewhere, such as an operator paying a withdrawal.

What if two terminals write at the same time, or the network drops?

SQLite serialises writers, and each deposit is a single transaction, so two terminals cannot interleave a read-modify-write. Every deposit carries an Idempotency-Key: if the response is lost and the terminal retries, the server returns the original result instead of paying twice.

What would you add next?

User login by phone number or QR, a real UPI payout integration (withdrawals are approved by an operator today), signed load-cell readings, per-material pricing from live scrap rates, and a municipal dashboard showing bin fill levels and collection routes.

If something goes wrong