Inspiration

Many of my relatives moved from Türkiye to Germany in the 2000s, and I built Letterwise in the light of what they went through. For them the letterbox was a source of dread. A letter from a German office arrived in official language, with a deadline, and a word-for-word translation did not say what to do next.

The obvious fix today is to paste the letter into a chatbot. But these letters carry exactly what a newcomer can least afford to leak: full name, home address, tax and case numbers, date of birth, bank details, residence status.

So a newcomer has two imperfect choices. A tool that runs on the device is private, but understands only what a small model covers. A cloud chatbot understands almost any letter, but sees everything. Letterwise splits the work instead: each step runs where it is allowed to see what it sees.

What it does

  1. Hide. Gemini Nano, running in Chrome on the device, finds personal details and swaps them for placeholders such as [NAME_1]. Pattern rules for six letter languages catch IBANs, phone, tax and case numbers and dates of birth as a safety net that needs no model.
  2. Check. You see the text that will be sent and can hide or un-hide anything.
  3. Explain. A cloud Gemini model explains the hidden version in one of 17 languages: what the letter is, what is wanted, deadlines, warnings, and the official words worth knowing.
  4. Verify. Every deadline and step comes with the sentence of the letter it rests on. The device checks that the sentence is in the letter word for word and that the date written there matches the date the cloud gave. A changed date is flagged.
  5. Plan. The letter becomes a to-do list: the papers you have to prepare and the steps to take, each with its due date. A date is used only if the device found it in the letter. One click downloads a calendar file with reminders 7, 3 and 1 days before, and the list is saved in the browser and shown again when you come back.
  6. Reply. Say what you want in your own language and Letterwise drafts the reply in the letter's language, with a translation.
  7. Warn. Gift-card payments or threats of arrest are flagged as a possible scam, with no steps for paying.

How built it

Letterwise is a React + TypeScript web app on the Firebase AI Logic hybrid inference SDK. The inference mode of each task follows from what it is allowed to see.

Task Mode Why
Find personal data ONLY_ON_DEVICE Reads the raw letter, so there is deliberately no cloud fallback.
Read a photo of a letter ONLY_ON_DEVICE A photo cannot be redacted first.
Quick gist ONLY_ON_DEVICE Works offline and before anything is sent.
Explain the letter ONLY_IN_CLOUD Needs stronger reasoning and many languages; receives hidden text only.
Draft a reply PREFER_IN_CLOUD The input is already hidden, so falling back to the device is safe.

Two checks stop a hidden detail from leaving: the page refuses a request that still contains one, and a service worker reads every outgoing request and refuses it a second time.

Other Firebase products: App Check (reCAPTCHA Enterprise), Remote Config for the routing policy and a cloud kill switch, Anonymous Authentication, Firestore for a routing log without content, and Hosting.

Measured

npm test runs 24 tests. npm run bench measures the rules-only check on invented letters in six languages. On 72 development letters it hides 452 of 452 private details. On 24 held-out letters it hides 109 of 136 (80.1%): every number, birth date, phone, email and bank account, but 44% of names and 71% of addresses. Report the held-out figure because it shows why the on-device model and the reader's own review both exist.

Challenges

  • The on-device model has a small context window, so letters are split into chunks and a detected item is kept only if it is literally in the letter.
  • Deadlines must survive hiding while dates of birth must not, so a date is hidden only when the letter labels it as a date of birth.
  • A model can state a deadline the letter does not contain. Requiring a quote and checking it on the device turns that into a visible flag.

What we learned

Hybrid inference is most convincing when the split is a product decision: the device handles what is private, the cloud handles what is hard, and the device checks the result.

What's next

Android and iOS versions on the same routing policy, more letter languages, and country-specific glossaries.

Built With

Share this project:

Updates

Submission history