Try it now, no login: https://snap.rajista.com Code (Apache-2.0): https://github.com/Risingtell/rajista-snap

Inspiration

I run a tech shop in Kano, Nigeria. Here, most supplier invoices are written by hand in carbon-copy books, in shorthand like 2 ctn GP Sugar @ 30,000. To keep proper records, a shop owner has to type every line into an app. When Rajista, the shop and stock app I build (www.rajista.com), went into its first trial shops, not one owner got as far as adding a product. Typing the catalogue is the wall.

Rajista Snap removes it: photograph the invoice, check it, keep it.

What it does

  • Reads a photo of a supplier invoice, handwritten or printed, even taken sideways, into lines: quantity, product, unit cost, line total and the invoice total.
  • Checks the arithmetic to the naira: every line (quantity × unit cost = line total) and the whole invoice (lines plus any VAT, delivery or discount = total).
  • Warns when the paper itself does not add up. Snap reads the photo twice, and only when both reads find the same numbers does it tell the owner to check the invoice with the supplier before paying.
  • Matches each line to the shop's own products and learns each supplier's shorthand: after one save, "Indo Ch Kn 70g" from that supplier is known as the noodles the shop already stocks.
  • Says on every result which reader produced it (this device or the cloud), how long it took, why it went to the cloud, and what the cloud reads would cost at Google's paid rates.
  • Exports the list, with the owner's selling prices, as a file Rajista's import screen reads, or as a WhatsApp message.

It works in any phone browser. On a computer that can run Chrome's built-in model, reading and matching happen on the device.

How it uses Firebase AI Logic hybrid inference

  1. Device first. Where Chrome's built-in Gemini Nano is available, Snap reads the photo with InferenceMode.ONLY_ON_DEVICE (image input, JSON constrained to one schema). The photo never leaves the computer and the read costs nothing.
  2. The arithmetic decides. A device read is kept only when its numbers prove themselves: every line multiplies out and the lines make the written total. Not a confidence score: a rule the owner can check.
  3. The cloud only when needed. If the device read does not add up, found no prices, listed charges, or has no total to check against, the same photo goes to gemini-3.5-flash-lite with InferenceMode.ONLY_IN_CLOUD, and the screen says why. If that read does not add up either, the quick model reads the photo again while a narrow read checks only the extra charges. gemini-3.6-flash is called only when the quick reads disagree on the lines, or the quick model is busy.
  4. Never fix the paper. Both readers copy numbers exactly. A model asked for a whole invoice can invent a "discount" that makes a wrong total add up, so only the separate charges read can confirm an extra row, and a row's label can only add doubt, never vouch for it.
  5. Private work stays on the device. The product list, selling prices and supplier shorthand live in the browser (IndexedDB) and are never uploaded, because a shop's cost prices are its margins. When name matching is unsure, the on-device model picks the product. That step has no cloud fallback on purpose: the code first checks that Chrome's model is really there, because without it the SDK would answer an on-device request from the cloud.
What Snap does Firebase
Reads invoices on the device, falls back to Gemini in the cloud Firebase AI Logic hybrid inference, Gemini Developer API
Matches lines to products on the device only Firebase AI Logic on-device model
Keeps the project's Gemini quota for this app alone App Check with reCAPTCHA Enterprise
Updates model prices and the naira rate in the cost counter without a release Remote Config

Where it is in the code: src/firebase.ts (Firebase, App Check, AI Logic), src/reader.ts (the hybrid reader), src/flow.ts (what happens after a cloud read), src/devicematch.ts (on-device matching), src/settings.ts (Remote Config and the cost counter).

What we measured

With Chrome's on-device model on a 4-core, 16 GB machine with no graphics card, the minimum Chrome's built-in AI accepts:

Invoice On-device read Result
Printed, 3 lines (26 Nov) Correct, sums cross-checked, 31 s Kept on the device, ₦0
Printed, 4 lines (26 Nov) Skipped a line in each of 10 tries, so the lines never made the total All 10 sent to the cloud: correct in 1.3 to 2.0 s
Handwritten, 3 lines (15 Nov) Misread a quantity (2 for 3), so the lines did not add up Sent to the cloud: correct in 1.6 s
Handwritten receipt, 2 lines, ₦2,365,000 (14 to 15 Nov) Misread the prices, so the lines did not add up Sent to the cloud: correct in 1.5 to 2.7 s
Handwritten, written total ₦109,000 for lines making ₦109,500 Cloud reads only Two reads found the same numbers: flagged as an error on the invoice itself

In every device run in this table, the sums caught each wrong number and a cloud read replaced it.

On the cloud path, the three handwritten samples cost ₦1.24 to ₦3.04 each at Google's paid rates (checked live on 22 November).

Tested on real receipts

Three handwritten receipts from my own shop's receipt book, read through the cloud path that phones use (28 November): all 3 read completely, with every quantity, price and total right, in 3.1 to 4.6 s each. Where a line had no quantity written, Snap said so instead of guessing one.

Challenges we ran into

  • Chrome's on-device model reads short printed invoices well, but it misread handwriting (a 3 read as a 2, prices off by a factor of ten), and on longer invoices it can skip a line. That is why arithmetic, not the model's confidence, decides whether a device read is kept.
  • A cloud read of a wrong invoice could invent a discount that made the total add up. Extra rows are now confirmed only by a separate, narrow read.
  • The stronger cloud model slowed to about a minute per read at busy times. Now the quick model reading twice (about 3 s) settles most invoices, and the stronger one only breaks ties.
  • reCAPTCHA Classic had been deprecated for App Check by the time we set it up, so Snap uses reCAPTCHA Enterprise, with a browser key locked to its own domains.
  • Phones in Nigerian shops cannot run Chrome's built-in model yet, so the cloud path had to be cheap and honest too. The cost counter shows it on every read.

Accomplishments that we're proud of

  • It catches mistakes on real paper. On the first sample the lines make ₦109,500 but the written total is ₦109,000; both reads agree, so Snap asks the owner to check before paying.
  • It reads real shop paper: three handwritten receipts from my own receipt book came out right, line for line, in 3 to 5 seconds each.
  • Every reading is explained: which reader, how long, why the cloud, and the cost.
  • 95 unit tests cover the sum check, reconciling two reads, matching, export and the cost counter.

What we learned

  • On-device AI works best as a first reader whose work can be checked, and arithmetic is the cheapest checker there is.
  • Keep private data where it is used. A shop's cost prices never need to leave the shop.

What's next for Rajista Snap

  • Build Snap into Rajista's product screen, so a new shop's catalogue fills itself from its first week of invoices.
  • Android, with Gemini Nano through Firebase AI Logic on the phones shop owners already carry.
  • Trials with supplier invoices from more Kano shops, starting with Rajista's first customers.

Built during #BuildHybridAI

Everything in the repository was written from 15 November 2026. It reuses two things that existed before: the colours and typeface of the Rajista app, and the column headings of Rajista's product import, so Snap's file opens there directly.

Built With

  • chrome-built-in-ai
  • cloudflare-workers
  • firebase-ai-logic
  • firebase-app-check
  • firebase-remote-config
  • gemini-3.5-flash-lite
  • gemini-3.6-flash
  • gemini-nano
  • indexeddb
  • react
  • recaptcha-enterprise
  • service-worker
  • typescript
  • vite
  • vitest
Share this project:

Updates

Submission history