Inspiration
About 3.9 million people from other countries live in Japan, and the mail they receive from city offices, tax offices, schools and landlords is written in formal Japanese that even learners with good everyday Japanese struggle with. I study foreign languages at a university in Japan, and I know that a translated paragraph still leaves the reader asking which sentence is the deadline. I wanted a tool that returns an action instead of a translation.
What it does
You choose your language, upload a photo of a letter or paste its text, and press one button. The page shows:
- Plain Japanese: short sentences, simple words, mostly hiragana.
- Your language: a natural translation into English, Simplified Chinese, Vietnamese, Korean, Portuguese, Spanish, Filipino or Nepali.
- What to do: up to three actions, each with a deadline. If the letter states none, it says "No deadline stated".
The two languages sit side by side so a Japanese coworker or landlord can check the same screen. The interface is available in Japanese and English, and without an API key the page runs a demo mode, so judges can try it immediately. A demo video of up to three minutes shows a real letter going through the page.
Check against the original. A fourth panel lists every amount, date, time and phone number in the letter with ✓ (still in the plain Japanese and the to-do list) or ⚠ (missing). A date or an amount that the output has but the letter does not is also marked ⚠, because the model may have invented it. This panel uses no AI: check.js applies fixed rules after normalizing full-width digits and kanji numerals (一万二千五百円, 十二月二十五日, 午後3時). For a photo, Gemini also returns a word-for-word transcription, and the check runs against that.
How we built it
The project started after the hackathon began and is one HTML page plus a small rule file (check.js). The page sends the photo and a system prompt to the Gemini API in a single request. Gemini reads the image directly, so there is no OCR step, and a JSON response schema (easy, native, todo[{what, when, note}], original) makes the output safe to render. The prompt tells the model to shorten sentences, replace hard words, never add information that is not in the letter, and write "No deadline stated" when there is no date. The API key is held in the tab's session storage and goes only to Google, so there is no backend to run or secure and no letter passes through my own server. The repository is public under the MIT license with a README, and the page can be copied to any static host.
AI assistance: Claude Code helped write and review the code. The product idea, the prompt and the screen design are mine.
Challenges we ran into
Making the model's output dependable inside a user interface was the main challenge. Free text forced the page to guess where each part began, so I used a response schema. Invented details were the other risk: a wrong date in a bureaucratic letter does real harm, so the prompt forbids inference. I also had to make the app approachable for non-technical users, which led to the one-button flow, the side-by-side layout and the offline demo mode. Last, I chose to keep everything in the browser so that schools and city offices could use it without sending residents' letters to a server I run.
Testing
A wrong deadline or amount is the most expensive mistake this app can make, so the tests target exactly that. tests/letters.json has twelve letters of the kinds people bring to an international-exchange counter (health insurance, resident tax in four installments, a school trip, a pension notice, bulky-garbage pickup, a health check, a garbage-day change), each paired with a model output. Five outputs are wrong on purpose: three tax installments dropped, a rain date dropped, a deadline invented for a letter that has none, 12,400 yen copied as 1,240, a phone number left out. node --test (16 tests) requires the checker to flag exactly those and nothing in the seven correct outputs. A browser test (Playwright) runs the page with the Gemini reply mocked and checks the panel for pasted text, a photo and the demo. Writing the cases set the scope of the rules (real letters use kanji numerals, full-width digits and 午後 times), and they are why the schema gained the original field: without it a photo could not be checked at all.
What the check cannot do: it catches a dropped or changed number, not a wrong meaning ("pay" translated as "you will be paid" passes), and for a photo it compares with Gemini's own transcription, so a digit misread from the photo is not caught. Pasting the text avoids the second problem.
Accomplishments that we're proud of
- The result answers "what must I do, and by when?" rather than only translating.
- A zero-backend design with a public MIT-licensed repository.
- A demo mode with prepared results in English, Simplified Chinese and Vietnamese that works offline.
- A bilingual interface so that both the reader and the helper can follow it.
What we learned
A schema plus an explicit "do not invent" rule turns a language model into a component that a user interface can rely on. Translation and understanding are separate problems, and the useful output was the extracted action with its date. Putting the original-language text next to the simplified version makes an AI result easy for a human to verify.
What's next
Furigana and read-aloud, more languages, city-specific vocabulary lists, a follow-up question box, and a pilot at an international-exchange counter to measure accuracy on real letters.
Built With
- css
- gemini-api
- google-ai-studio
- html
- javascript