Try it: https://fumi-letters.web.app (desktop Chrome with Gemini Nano for the on-device path; any browser works with the cover-by-hand cloud path). Three fictional sample letters are built in.

Inspiration

Japan is home to 4.28 million foreign residents, a record high (Immigration Services Agency, June 2026). Every one of them gets letters from the city office, the pension service and their health insurer, written in dense official Japanese: resident tax paid in four instalments, insurance premiums, pension reminders that end with a warning about seized assets. Missing one costs late fees or worse.

Today people photograph these letters and paste them into chat apps or translators, and with them their name, address and My Number, the national ID number that Japanese law protects. I wanted the help without the leak: an app that reads the letter where it already is, on your own device.

What it does

Take a photo of a letter, or try one of the samples. Fumi:

  • reads the letter on your device with Gemini Nano in Chrome
  • finds and covers your name, address, My Number, insurance, pension and account numbers and phone numbers, replacing each with a numbered label such as [NAME 1] or [PHONE 1]
  • tells you what the letter is, what to do, the deadline (with a countdown and a one-tap calendar reminder) and the amount, in one of 10 languages (English, Chinese, Vietnamese, Korean, Tagalog, Portuguese, Nepali, Indonesian, Spanish, Burmese)
  • explains the official terms in the letter and answers follow-up questions ("Can I pay this at a convenience store?")
  • shows a privacy panel: what ran on the device, what was sent to the cloud if anything, the exact text that was sent, and how long each step took.

How I built it: Firebase AI Logic hybrid inference

Fumi routes each step by how sensitive its input is.

  1. Read the photo: ONLY_ON_DEVICE, image and text in. Plain text out instead of JSON: on Gemini Nano that was several times faster and more complete. A tall page is read in two halves, cut along an empty line of paper so no printed line is split. If the sender's office or phone number did not come through, the bottom of the page gets a second, closer look.
  2. Find personal data: ONLY_ON_DEVICE with a JSON responseConstraint. Fixed patterns double-check (phone, postal and My Number formats, values after any 番号 label, names before 様, addresses), and implausible picks by the model (an amount, a month, the office's own name) are rejected so the facts the reader needs stay visible.
  3. Explain: PREFER_ON_DEVICE when Gemini Nano writes the reader's language (English, Spanish, Japanese). For other languages ONLY_IN_CLOUD, but only after the reader has seen exactly what would be sent and confirmed, or chosen to keep everything on the device and read it in English. Nothing reaches the cloud unless it passes a last pattern check.
  4. Check the facts: the deadline and amount printed next to their labels (納期限, 納付額) win over the model's answer, Japanese era dates (令和9年1月5日) are converted by code and written next to the original before any model sees the text, and the sender must appear in the letter.

More details:

  • No local model? Fumi never sends the photo as it is. The reader blacks out their details on a canvas first, and only the covered copy is read in the cloud. The same path is offered if the on-device model cannot read a photo.
  • Labels, not data. The labels and the real values stay in the tab. When an explanation needs one, like the office phone number to call, the real value is filled back in on screen only and marked.
  • App Check with reCAPTCHA Enterprise (enforced) protects the Gemini endpoints.
  • Remote Config holds the cloud model, a fallback model used when the first is busy, slow or retired, and a curated glossary of official terms that grounds every explanation, on the device and in the cloud.
  • Every answer is labelled with its inferenceSource: On device or Cloud. The on-device model is warmed up when the page opens, and Chrome's one-time model download can be started from the app.
  • Stack: React 19, TypeScript, Vite, Tailwind CSS 4, the Firebase JS SDK (firebase/ai, App Check, Remote Config) and Firebase Hosting. 34 unit tests cover redaction, the fact checks, era dates, joining the two halves of a page and the calendar file.

Challenges I ran into

  • Gemini Nano on a 6 GB laptop GPU. Asking for JSON while reading the photo was slow and skipped the letter's title and footer. Splitting the work into plain-text reading and a short JSON pass, cutting the page in halves along whitespace and warming the model up brought reading down from about 40 seconds to 10 to 19.
  • Small models and numbers. Nano copied examples from my prompt and once answered "January 5th, 2026" for 令和9年1月5日 (2027). I removed examples from prompts, convert dates in code and check every key number against the letter.
  • Covering too much is a failure too. The model once labelled the amount due as an account number, which hid the most important fact. Plausibility checks now keep amounts, months and the office visible.
  • Cloud models move. The model I planned to use is closed to new projects, and newer ones were overloaded while I tested, so the model name lives in Remote Config with a fallback and a timeout.

Accomplishments that I'm proud of

  • The photo and the full text of a letter never leave the device, and the reader can check that in the app.
  • A phone number can be useful and private at the same time: the model sees [PHONE 1], the reader sees the number.
  • Measured on a laptop with an RTX 2060: reading 10 to 19 s, finding personal data 4 to 6 s, explaining on the device 16 to 19 s or in the cloud 3 to 7 s.

What I learned

On-device models change the design question from "what can the model do" to "what is each piece of data allowed to touch". Small models read well and write decently, but code should own the facts.

What's next for Fumi

  • Android, where letters are actually photographed, with the same routing through Firebase AI Logic hybrid inference.
  • More letter types (school, immigration, utilities) and reminders before each deadline.
  • The interface itself in the reader's language.

Built With

Share this project:

Updates

Submission history