Files
heidi/docs/clone-a-language-app.md

14 KiB

Cloning Heidi into a sibling language app

Last verified: 2026-11-25

How to make a second app from this one that teaches a different language or variety: French for people arriving in Romandie, say, under its own name. The steps are in the order they have to happen. Every path below exists in this repository; none of the facts about hosts, ports or the org is repeated here (they live in bitbaum/fleet and in Loki's serve file, and this doc points at them).

The three layers

A clone changes two of them and none of the third.

Layer What it is Where it lives A clone
Packages behaviour every bitbaum app shares @bitbaum/* in package.json; package-plan.json says which file binds which changes nothing
Config small typed values that name this product lib/config/, lib/course/registry.ts, lib/variety/active.ts, lib/situations/active.ts, lib/i18n/locales.ts, the environment edits a handful of lines
Content the language itself and the words on the pages lib/variety/packs/ (with packs/glosses/ and packs/authored/), lib/situations/packs/, lib/i18n/dictionaries/, content/essays/, lib/listening/, lib/research/ is written new

The engine between config and content (lib/variety/, lib/domain/, app/) reads a pack through a typed contract and does not know which language it is teaching. That is tested: lib/variety/packs/uk.ts is a second, deliberately small pack, and the contract suites (lib/variety/check.test.ts, lib/variety/declared.test.ts, lib/situations/contract.test.ts) run over every pack, so a Zurich assumption in the engine fails there. lib/variety/leak.test.ts reads the engine's string literals for names of the variety and for words of the taught language, and holds both counts to a baseline that may only fall. The baseline for names is empty; the one for words holds two rows that are not the taught language (a sentence recognisers invent over silence, and the identifier use), each with its reason in the test.

A clone is one way to get a second language. The other is a second course in this repository: lib/course/registry.ts lists courses, every stored record names its course, and item ids are unique across courses (HEIDI.md §4, "Courses"). Only one course is listed and nothing chooses between courses yet, so today a second language still means the steps below.

What stays in packages

Do not copy or re-implement any of this in the clone. If one of them cannot do what the new language needs, extend the package and release it.

Need Package
accounts, sign-in screens, account mail @bitbaum/accountkit, @bitbaum/mail-kit
chat window, composer, dictation field, layout audit helpers @bitbaum/chatkit
model calls and streaming @bitbaum/ai-kit
search box @bitbaum/searchkit
speech in and out @bitbaum/speechkit
dates and times @bitbaum/whenkit
roadmap and changelog documents @bitbaum/bip-kit
rate limits @bitbaum/limitkit for the rules, the headers and the in-memory window that counts anonymous callers. Its store interface is synchronous, so the counter for signed-in callers is the app's own (lib/domain/limit-counter.ts, one table)

package-plan.json is the list to keep true: review it before building anything, and keep its bindings pointing at real files.

Steps

1. Name it and create the repository

  1. Pick the name and check it is free (the org's naming procedure, in bitbaum/fleet).
  2. Create the repository from this one, keeping history out: copy the tree, start a fresh git init. Keep AGENTS.md's generated block; the fleet re-syncs it.
  3. Register the app where the fleet reads it (the registers named in bitbaum/fleet AGENTS.md). Until it is registered it has no host.

2. Brand: four values

All config. After this the product has its new name everywhere the code writes one.

File What to change
lib/config/site.ts ASSISTANT_NAME (the product's name: page titles, share cards, the manifest, account mail and the name the assistant answers to in a group all read it), the default of SITE_URL, CONTACT_EMAIL, SOURCE_URL, and SITE_TIME_ZONE (the zone a speaking round is scheduled in when its host's browser names none)
lib/config/landing.ts headline, the one line on the share image
app/icon.svg the mark; then node scripts/build-icons.mjs regenerates app/favicon.ico, app/apple-icon.png and public/apple-touch-icon.png
lib/config/og-image.ts, app/globals.css colours, if the clone has its own palette

NEXT_PUBLIC_SITE_URL in the environment overrides SITE_URL per deployment.

3. Which language is taught: one line each

File What to change
lib/course/registry.ts the one entry of COURSES: a permanent id, the pack's tag, and entry (sibling when the learner comes from a close language, zero when from nothing)
lib/variety/active.ts put the new pack in SHIPPED_PACKS; VARIETY is resolved from the registry
lib/situations/active.ts list the new situation packs in ALL (they are filtered by VARIETY.tag)
lib/variety/authored.ts map the new pack's tag to its hand-written questions (step 6); a pack without an entry gets none

4. Which languages the site speaks

lib/i18n/locales.ts: LOCALES, DEFAULT_LOCALE, LOCALE_NAMES, LOCALE_TAGS and the menu order. The site's languages and the language it teaches are separate axes: a French app for German speakers keeps de and drops gsw.

Every language in LOCALES needs a file in lib/i18n/dictionaries/. They are typed against de.ts, so a missing key is a build error and not a silent fallback. Dropping a locale means deleting its file and its line in lib/i18n/index.ts.

5. Write the variety pack (content, the real work)

lib/variety/packs/<tag>.ts, typed by VarietyPack in lib/variety/pack.ts. Start from uk.ts (small) and read gsw-zh.ts (complete). In the order the product leans on them:

Field What it carries
tag, name, endonym, region, family identity; tag is a BCP 47 tag and ends up in lang attributes
bridges the language the learner already knows, and how it relates
learner who this is for and which skill comes first; the front door reads priority[0]
correspondences the sound and spelling shifts worth showing on the share card and the home page
rules, leaks what makes a form wrong for this variety; this is what "every answer is checked" means, so an empty list is an unchecked product
orthography whether there is a standard spelling (decides if a variant is an error), the locale its text is case-folded by, and, only without a standard, the respellings that are one word written two ways
grammar, vocabulary, explains the reference pages and most of the exercises
articles, persons, personOf, vocabularyGroups the pack's own closed sets: its articles and which one a bridge article reads as, the person labels its paradigms use and the grammatical person behind each, its word groups in display order. An entry may only use what is declared here; a variety without articles leaves articles out
bridges[].writing, toneExample the lines of the model's prompt that are about this language
bridges[].rephraseAs on a bridge the product can write and check: the key of the chat's "say it in the written standard" move. Without it the chat offers only the tone moves
capabilities, speech what a computer can honestly do with this language: transcription, synthesis (speech.voices ranks the device voices that may read it, each with the claim the page makes), and what the page must refuse to claim
level on a word, a line or a topic only for an entry: "zero" course: the CEFR band each item's level is read from. A sibling course measures the distance from the sibling and ignores it

A person label, a word group, a voice claim and a rephraseAs key are keys the dictionaries render (practice.persons, vocabulary.groups, voice.claim, chat.moves), so each new one needs its word in every interface language; tests name the missing one.

Every entry that is a claim about the language needs a source in lib/research/sources.ts; the vocabulary's sources are named in the pack (vocabularySources).

6. Situations and exercises (content)

  • lib/situations/packs/<tag>-<domain>.ts, typed by SituationPack: the scenes and the lines said in them, each with its provenance.
  • lib/variety/packs/authored/<tag>/: hand-written questions, registered for the pack in lib/variety/authored.ts. lib/domain/practice/templates/README.md explains the format. Questions generated from the pack (articles, forms, vocabulary) need nothing written.

6a. Meanings in the reader's language (content, optional)

lib/variety/packs/glosses/<course>.<locale>.ts, typed by GlossSet in lib/variety/gloss.ts and registered in packs/glosses/index.ts. A gloss is keyed by the bridge form the course gives as the meaning, in three sections (vocabulary, phrases, authored), and the set states who wrote it and whether anybody reviewed it. A course without a set for a language shows meanings in the bridge language there, and the question «how good is your German?» is not asked. pnpm run glosses:coverage prints what is covered; packs/glosses/glosses.test.ts refuses a key no entry carries.

7. The words on the pages (content)

  • lib/i18n/dictionaries/*.ts: interface copy, including the account, reminder and confirmation mail (mail) and the names of the three levels for both kinds of course (progressBy.levels for a sibling course, progressBy.levelsFromZero for a zero one). The product name and the name of the language appear inside sentences here; they are prose, not placeholders, so this is a rewrite per language and not a search and replace.
  • lib/config/: paper.ts, roadmap.ts, changelog.ts, sectors.ts, investors.ts, economics.ts, problems.ts, roles.ts. These are about this project. Start the changelog and roadmap empty (ROADMAP.md and CHANGELOG.md at the root are the copies the fleet reads, and lib/config/records.test.ts keeps them equal); rewrite or remove the rest.
  • content/essays/, registered in content/essays/index.ts.
  • lib/listening/sources.ts: where the language can be heard.
  • lib/research/: sources.ts (the bibliography) and language-tech.ts (the evidence behind /technology).
  • lib/config/privacy.ts: the data flows and vendors. They are facts about the deployment, so re-check each one; lib/config/privacy.test.ts compares the declared storage keys with the ones the code uses.

8. Storage names

Browser storage keys and the locale cookie carry this product's name (heidi.* in lib/browser/stores.ts, and the heidi_locale cookie set where a bare path is redirected to a language). The stores that hold course progress are listed once, in lib/course/stored.ts, each with the .v1 key it had before courses existed; a new product has no such history and can drop the legacy entries. Two apps on different hosts do not collide, so renaming is optional; if you do, change them in one commit with the privacy page's where values.

9. Environment and database

.env.example lists every variable with what it switches on; the app runs with none of them and hides what is not configured. A clone needs its own DATABASE_URL and BETTER_AUTH_SECRET, and OWNER_ACTOR_IDS or OWNER_EMAILS if somebody is to read /api/owner/numbers (the numbers and the server's errors; 404 for everybody else). It applies the migrations in drizzle/ unchanged, then adds one of its own: progress_devices, certificates and entitlements have a course column whose default is this repository's course id (drizzle/0015_course.sql), and a clone changes that default to its own.

10. Prove it, then ship

pnpm install
pnpm run verify            # type-check, lint, every test incl. the pack contracts
pnpm run build
pnpm run dev               # in another terminal, for the audits below
pnpm run audit:responsive  # every page, every language, phone widths
pnpm run audit:overlays
pnpm run audit:language    # lang attributes match the language on the page
pnpm run audit:speaking    # a real microphone, a real upload

A new language changes word lengths, so the layout audit finds things review does not. Then open a pull request; the fleet's sweep merges and deploys it.

What is not cheap yet

Stated so nobody discovers it on the day:

  • The product name inside dictionary sentences. About a hundred sentences per language name the product or the taught language in running text. Turning them into placeholders would need grammatical case in seven languages, so they are rewritten, not configured.
  • Pages whose prose is about Zurich. /method, /paper, /about and the organisations page argue for this product in this city. They are content to write, not strings to translate.
  • Two test files assert Zurich facts (lib/variety/zurich-name.test.ts, lib/variety/neighbours.test.ts). They belong to the Zurich pack; a clone replaces them with the equivalents for its own variety.
  • The hand-written questions, including how the clock is said (lib/variety/packs/authored/gsw-zh/clock.ts), are one course's content, kept with its pack. They are written new, not configured.
  • A second course in the same deployment. The registry, the stored records, the item ids, the rate-limit keys and the level names are ready for one; choosing a course in the interface and a wider primary key on progress_devices are not built.