Inspiration

At the end of every term, a class teacher in Kenya writes a report remark for each of 30 or more learners, works out which groups are struggling, and decides what to do about it. AI could take most of that load. But a remark is built from a child's levels and the teacher's notes about that child, and pasting that into a cloud chatbot means sending a child's data to a server the school has never heard of.

Firebase AI Logic's hybrid inference made a different design possible: run the parts that touch a child on the teacher's own laptop, and send the cloud only what it is actually needed for. Staffroom is built on one rule:

A task that touches learner data runs on the device or not at all.

Most hybrid apps fall back to the cloud when the device can't run a prompt. For a child's data, that fallback is a leak. Staffroom refuses instead, says why, and logs every request in a ledger the teacher can read.

What it does

The teacher enters each learner's levels and a short note (or loads the invented sample class). Then:

  1. Reports: Staffroom drafts every report remark on the laptop with Gemini Nano in Chrome.
  2. Support: it finds the groups struggling with the same topic, and sums up their common difficulty in one phrase, also on the laptop.
  3. The outbound preview: before anything leaves, the teacher sees all the text that will be sent: a curriculum question built from the curriculum pack, plus that one phrase. A roster guard (plain code, no model) checks it against the class list. If a learner's name is in it, "Ask the cloud" switches off and says why.
  4. The plan: the cloud answers the curriculum question with a two-week remedial plan.
  5. Parent notes: back on the laptop, Staffroom joins the plan to each learner's levels and writes a note to each parent.
  6. The Privacy ledger: every request, where it ran, and for the cloud the exact text sent.

How I built it

Seven tasks use all four hybrid inference modes:

Task Mode Why
Report remark ONLY_ON_DEVICE Holds a learner's levels and note
Group difficulty ONLY_ON_DEVICE Reads notes on several learners
Parent note ONLY_ON_DEVICE Joins the plan to one learner
Mark-sheet photo ONLY_ON_DEVICE Prompt and parser exist; no screen yet
Remedial plan ONLY_IN_CLOUD Needs curriculum knowledge the small model can't be trusted for
Starter activity PREFER_IN_CLOUD Better from the cloud, still useful offline
A level in plain words PREFER_ON_DEVICE Simple rewording, harmless if it falls back

The rule is enforced in code, not by convention:

  • resolveMode is the only place a task's mode is decided. A learner-data task resolves to ONLY_ON_DEVICE under every setting; Remote Config can change the other tasks, never these.
  • Every inference goes through one runner. A cloud-capable request must carry an outbound message, the prompt must equal the text that was checked, and the roster guard must pass, or the engine is never called.
  • If the SDK's inferenceSource ever reports a cloud run for an on-device-only request, the result is thrown away and logged.
  • An on-device-only model is created with no cloud settings at all.
  • Names never enter a prompt, even on the device: prompts say [NAME] and code fills the name in afterwards.

Firebase: Firebase AI Logic (getGenerativeModel with InferenceMode, structured output on the device), App Check with reCAPTCHA Enterprise, Remote Config with live updates (a school's "strict" policy switches the cloud off in an open app with no reload), Firestore and anonymous Auth for a shared library of plans that holds no learner data, and Hosting. React, Vite and TypeScript on the front end; the class lives in IndexedDB; a service worker lets the app open with no connection.

Tests: 142 unit tests and 142 browser checks run with a simulated engine, including a keyboard-only run of the whole loop. Real-model results are logged separately, because a simulated engine can't prove quality, speed, or where a model really ran.

What I measured

On a MacBook Air M2 (8 GB RAM) with Chrome 157 stable and the real engine:

  • Remarks: 30 of 30 written on the laptop; median 4.1 s each once the model is warm; 27 of 30 usable without editing, by my reading. About 90 s for all 30 on the live site.
  • No requests while remarks are written: with wifi on, an in-page observer saw 0 requests during a batch of 30. The page does make background requests when idle (reCAPTCHA and the Remote Config stream), so I don't claim "no network at all".
  • The whole loop on the live site: 41 runs on the laptop, 1 in the cloud, 1 sent and not answered, 0 learner tasks sent to the cloud.
  • With no on-device model (Safari): the learner tasks stopped with "Did not run"; the open tasks ran in the cloud; 0 learner tasks sent.
  • Offline: the starter activity (PREFER_IN_CLOUD) fell back to the laptop and said "On this laptop".

What teachers said

Four primary school teachers in Kenya tried Staffroom on the live site, on my laptop, with the invented sample class only. They liked it, and three of the four got to a parent note without my help.

All four told me the screens were hard to use: long remarks and notes sat in small boxes they had to scroll inside, and boxes side by side didn't line up. I measured every screen and fixed what they found: text boxes now grow to fit their text, the class notes wrap in a wider column, and cards and columns side by side end at the same height. With real-model remarks on the live site, 0 of 30 remark boxes now cut off their text; before the fix, all 30 did.

Challenges

  • Grounding on the free tier. The plan was meant to come with Google Search sources. On the Gemini Developer API free tier, grounding isn't available for current models, so the request is refused (HTTP 429). Staffroom tells the teacher, offers to ask again without sources, and marks that answer "No web sources". Both sends are in the ledger.
  • A small model drifts. Each note is about a whole learner, so the Fractions group's notes also held decimal mistakes, and the on-device summary drifted to decimals in 2 of 3 live runs. Code now keeps only the sentences that name the group's topic; after that, 3 of 3 live runs stayed on Fractions.
  • Honest failure is a feature. In a browser with no on-device model, the hybrid SDK would happily run things in the cloud. Making the app stop, explain itself, and still offer the tasks that are safe to send took more design than the happy path.
  • Shipping safely. A pre-deploy check caught the App Check debug token in the production build; the build now fails if it is ever in dist/. A stale service worker kept returning browsers on an old build until the HTML was served no-cache.

What I learned

Hybrid inference is most interesting not as "cheaper when possible" but as a boundary: deciding, task by task, what may leave the device, and proving it. inferenceSource and a ledger turned out to be as important as the model calls themselves.

Limitations

Desktop Chrome only. English only for on-device writing. The on-device model needs a capable laptop, which many teachers don't have. The name check can't catch a nickname or misspelling it has never seen, so the teacher reads the text before sending. Data on the laptop is not encrypted. Every remark, plan and note is a draft the teacher edits and approves. Running on the laptop reduces where a child's data goes; it doesn't remove a school's duties under Kenya's Data Protection Act. This is not legal advice.

AI assistance

Claude wrote some of this code under my direction, part of the starter (core modules, first screens, tests, build script) and some later screens, prompts and tests. I set the rules, wrote parts of the code, reviewed every pull request, tuned the prompts on the real on-device model and ran every real-device test above. Everything was built during the submission period, from 16 Nov 2026.

All learner data shown is an invented sample class.

Built With

Share this project:

Updates

Submission history