LEXIProduct design
Why LEXI has no AI connection and uses a copy/paste step instead
LEXI never calls a model. It writes a plain-language prompt you can take to any AI tool, then validates the JSON you paste back, field by field, before anything is saved. This is the trade-off, and how the boundary works.
LEXI helps learners of Chinese, Japanese and Korean build their own vocabulary. You capture a word in a second; later, LEXI turns it into a full entry in three languages. A language model is very good at that second step. LEXI still never calls one. This article explains why, and how the copy/paste step that replaces the model call works.
File names below are in the LEXI repository; decisions are numbered as in its technical specification, TSD.md.
The job: turn a word into an entry
LEXI works in two stages on purpose. First you capture: type or paste 咖啡, 图书馆, 朋友 into the Inbox, one per line, and move on. Later you enrich: LEXI turns each capture into a concept that holds a Chinese, a Japanese and a Korean entry, each with its written form, its reading (pinyin with tone marks, kana, Revised Romanisation), a meaning, notes, example sentences, and links to related words.
Writing all of that by hand is slow. A large language model can draft it in seconds. The question is where that model call should happen.
Why not just call a model
The obvious design is a button: "Enrich", which sends the words to an AI API and saves what comes back. LEXI's specification rules it out from the first page: LEXI "should remain useful without a server, account, or model API."
Three things follow from that rule.
- Your words are yours. Vocabulary can say a lot about a person: their job, their partner's language, where they are moving. The specification is explicit that this data "may be private and must not be transmitted silently". A button that quietly sends your list to a third party is exactly what that sentence forbids.
- No key to keep. A model API needs a secret key. In a browser-only app that key would either be visible to every visitor or need a server to hide it, and LEXI's live data is designed to sit in your browser, in IndexedDB, with no server required.
- Any model you like. Learners already use different AI tools. A boundary that works with any of them doesn't tie LEXI to one provider's prices, limits or outages.
When optional accounts were added later (decision D-031), the rule was restated: the account adds sync between devices, and "AI APIs remain excluded".
The boundary, step by step
Instead of an API call, LEXI draws a visible line between your data and any AI tool, and lets you carry the work across it.
- Select a batchpick captured words in the Inbox
- Copy the promptLEXI writes it; you choose where it goes
- Run it anywhereany AI tool, or none at all
- Paste the answerJSON goes back into LEXI
- Validate and previewevery field checked, nothing saved yet
- Applyone transaction, on your confirmation
The only things that leave LEXI are the words you selected, and only because you copied them. Nothing is sent in the background.
A prompt written for people and models
The prompt LEXI writes is plain prose, not a blob of JSON (decision D-016). It describes the task in sentences, lists the words with their capture IDs, names every field it needs, says which pronunciation script to use for each language, lists the allowed relationship types, and ends with the exact JSON shape the answer must take.
Two reasons are recorded for that choice. A model follows a described task and a word list more reliably than a serialised payload, and pasting a page of JSON into a chat box is awkward for a person. Only the answer is JSON, because the answer has to be parsed.
The prompt also asks for honesty. One of its rules is "Never invent a meaning. If you do not know, put it in uncertain." Anything the model is unsure about comes back in an uncertain list instead of being presented as fact.
To make links between words useful, the prompt includes up to 300 Chinese words you already have and asks for two to five relationships per word, preferring words in the batch and then words already stored (D-020).
Checking what comes back
Whatever you paste is treated as untrusted input. The specification says so in as many words, and domain/enrichment.ts does the checking before anything is written.
- The envelope. The answer must say it is a
lexi-enrichmentdocument,schemaVersion1. A different format or a newer version is refused with a specific error (LEXI-JSON-001,LEXI-JSON-002) rather than guessed at. - The captures. Every result must point at a capture ID that exists in your LEXI. An answer can't invent a word you never captured.
- Every field. Each result needs at least one language entry; language codes must be supported ones; relationship types must exist in LEXI's registry. The checks are written with zod, so a failure names the exact field and row.
One small decision says a lot about designing for models rather than against them:
// A model writes an explicit null for "nothing to say" far more often than it omits
// the field, and the two mean the same thing to us. Null is therefore read as absent,
// or as empty text where the field is expected to be present. Rejecting it would fail
// a whole batch over a field that carries no information either way.
const modelText = z.preprocess((value) => (value === null ? "" : value), z.string());
Strict where it protects your data, forgiving where it costs nothing.
If the answer passes, LEXI shows a preview: how many concepts, entries, examples and links it will create. Nothing is saved until you press Apply. Then applyEnrichment in application/enrichment.ts writes everything inside one IndexedDB readwrite transaction, so a batch is saved completely or not at all.
What it costs
The copy/paste step is not free. It is an extra few seconds: copy, switch to your AI tool, paste, come back. The quality of the draft depends on the tool you choose, and LEXI can't retry automatically when an answer is wrong. It can only tell you exactly what is wrong.
In return, LEXI needs no API key, no server for enrichment and no provider. It keeps working when any one AI service is down or changes its terms. And at every point you can see exactly what leaves your device, because you are the one who carries it.