Inspiration

An exit ticket is 3 to 5 short questions at the end of a class. It helps only if the teacher reads it before the next class. Tiza is designed for math teachers of grades 4 to 8 who work on paper, with 30 to 40 students per class and an unreliable school connection.

Paper matters because a written answer shows how a student went wrong, which a bubble does not: 2/5 for 1/2 + 1/3 means adding the numerators and the denominators. Tiza reads those slips and puts each student in one group, before the next class.

Two constraints shaped the design. The connection: slips can be captured offline, and a computer with Gemini Nano reads them on the device. And the students' privacy: cloud models see answer boxes and groups, never students.

What it does

The device reads, the cloud thinks, the code decides.

Tiza has two apps on one Firebase project: a web app (React) and an iPhone app (SwiftUI), both with an English and a Spanish interface. A ticket goes through seven steps:

  1. Prepare (cloud). The teacher gives a topic, a grade and a language. A cloud model drafts 4 or 5 questions, each with an answer type and its correct answer, plus the ticket's misconceptions and an error map: which predictable wrong answer reveals which misconception. The teacher edits and approves. Nothing prints without approval.
  2. Print (web). One slip per student, three per A4 sheet. Two QR codes on each slip carry the ticket and the seat number, never the name, and serve as registration marks. The name is printed locally.
  3. Capture (iPhone app, browser camera or file upload). The app straightens the photo, crops the answer boxes and builds the boxes view: all the boxes of the slip in one image. Offline, the slip waits in Firestore's local cache, and the Capture page already counts it: "12 of 14 handed in." (Offline capture comes from the code; it was not part of the measurements.)
  4. Read (hybrid). Each box gets two independent readings: Gemini Nano twice on a computer with Chrome, or two different Gemini models in the cloud. A value is accepted only when both agree.
  5. Review (one tap). The boxes that were not settled reach the teacher, grouped by question: "What does it say?", with the readings as buttons.
  6. Diagnose (code, and the cloud for the unforeseen). Code compares each value with the correct answer and the error map, and puts each student in one group. Wrong answers that the map did not foresee go to a cloud model as anonymous text, and the model suggests a misconception, which the teacher confirms, changes or rejects. Each answer count opens the crops behind it ("Show the answers"), as long as the images are kept: at least 7 days by default after the slip is resolved.
  7. Act. A reteach plan for each group (cloud), a note for each student (on the device only), and a message for the families (on the device, or in the cloud if there is no local model).

Every AI output carries a label: "On a device", "In the cloud", or, in the demo only, "Recorded reading". Opening it shows "Why this route" and "What was sent".

The iPhone app photographs the slips, has their boxes read in the cloud, and shows the review, the results and the notes, which Apple's on-device model writes on the iPhone. Writing and printing tickets, classifying unexpected answers and writing the reteach plan belong to the computer.

How we built it

One project, two apps, one core. All of Tiza's AI goes through Firebase AI Logic. The web app (firebase 13.3.0) calls Gemini Nano with ONLY_ON_DEVICE and Gemini models with ONLY_IN_CLOUD, and uses PREFER_ON_DEVICE only for the family message. The iPhone app (firebase-ios-sdk 12.19.3) uses Apple's Foundation Models through a local-only session for the notes and a hybrid session for the family message, and Gemini in the cloud for reading. The rules both apps follow (answer normalization, consensus, routing, retries, the diagnosis, the slip layout and QR payload, the task registry) live in a TypeScript core, shared/, with a Swift port, TizaCore. Both platforms must pass the same JSON vectors.

Routing by measured capability. A computer with Gemini Nano reads the slips on the device, Nano + Nano. The iPhone and a browser without a local model read in the cloud, or wait for the computer. Writing the ticket, classifying unforeseen wrong answers and the reteach plan go to the cloud. Comparing with the error map is code. The student note is written only on the device and stored encrypted.

How a value is accepted. In the local recipe, Nano reads each box's crop on its own, and then reads the boxes view in one call. In the cloud recipe, gemini-3.1-flash-lite reads the boxes view and gemini-3.5-flash-lite reads the reversed view: the same box crops in reverse order, without position labels. The readers get only each box's answer type, never the question or the correct answer. A value is accepted only when the two readings agree after normalization: 3,25 and 3.25 are the same decimal. Even then the box goes to the teacher if it is a word box with a Nano reading, if a printed border shows in the crop, or if it is an improper fraction without a whole part, such as 81/2. In the cloud recipe, two readings by the same model do not count: the box stays "Pending, retrying" until another model reads it. A disputed box goes to review; in the local recipe, when images may go to the cloud, a third cloud reading of its crop only puts its answer first among the options (arbiter_auto_accept is false). A cloud call has a 60 s deadline, and a reading is tried up to 4 times, after waits of 1, 4 and 15 minutes, along its fallback list. No box is ever accepted on one reading.

Explicit routes, no silent fallback to the cloud. Reading calls ask for "only on device" or "only in cloud", never "prefer on device". When a local call fails, the slip goes back to the queue and the router decides again. The student note is an individual task: its only route is the device, and assertRouteAllowed refuses any other.

Privacy by architecture. The photo stays on the device that took it. Models see only answer boxes, without the question, the QR codes, the seat number or the name. The roster is encrypted on the device with the class key (AES-256-GCM). The key goes from the computer to the phone through a QR code on the screen, or through a recovery code that the teacher prints or copies by hand, and never reaches Firebase. "Only my devices" sends no image to a cloud model, and a project-wide Remote Config switch, cloud_images_enabled, does the same for every app.

Firebase, service by service. Auth: Google sign-in, and anonymous sign-in for the demo. Firestore: each teacher's data under users/{uid}, isolated by the rules; the reading queue between devices, where a device claims a slip with a lease and readings are only appended; work without a connection through the persistent cache; box images as bytes, in documents under 1 MB each. Remote Config: live, project-wide switches and the model fallback lists. App Check: reCAPTCHA Enterprise on the web, and the debug provider on iOS, because App Attest needs a paid Apple account. Hosting: the web app as a PWA. No Cloud Functions, no Cloud Storage, no billing.

Measured in the repository. The web app's /lab pages run the measurements, and every number in the README names its sample and points to its source: a result file or a section of docs/startup-validations.md.

Challenges we ran into

  • Two readings can agree and both be wrong. On set A, both Nano readings agreed on the same wrong word in 2 of the 8 word boxes ("gato" read "sato", "rojo" read "roo"). In the local recipe, a word box with a Nano reading is now never accepted on its own.
  • Mixed numbers. In set B, both cloud models read mixed numbers such as "8 1/2" as "81/2". The improper-fraction rule was added on 24 Nov, after set B was measured. Applied to the same readings, the cloud recipe had 3 silent errors in medir instead of 10.
  • Two boxes fool every reader. In "3,61" the final 1 has a long hooked flag, and it was read "3,67" in 14 of its 15 readings. In "77%" the first 7 has a closed top, and Nano read "97%" in 8 of 8 readings. No composition of these readers removes these two errors, and sending every decimal and percentage to review would cut the cloud recipe's acceptance in medir from 69.1% to about 46%.
  • SDK edges. In a browser without Chrome's on-device API, the installed web SDK would send an ONLY_ON_DEVICE request to the cloud, so Tiza checks for the SDK's on-device adapter before each on-device call and fails closed. On iOS, Firebase SDK 13.0.0 removed the sessions with Apple's model, so the app stays on 12.19.x.
  • No second local reader on the iPhone. Apple Vision OCR got 77.5% on the printed slip and returned nothing for 18 of the 24 single-character boxes. Vision only finds the QR codes, and the iPhone reads slips in the cloud.
  • The free tier. Per project and per model: 500 requests per day for gemini-3.5-flash-lite and for gemini-3.1-flash-lite, and 15 per minute for gemini-3.5-flash-lite, shared by all teachers and judges. The model the design had planned for the tiebreak, gemini-3.8-flash, gave no reading on the free tier on 16, 17 or 20 November, and every model tried failed or did not answer at some hour.
  • Nano under load. During the set B local run, Nano stopped answering after 20 to 25 minutes of continuous reading, several times.
  • Photos that decode differently. TizaCore's port of the web's refined crop fit gave the same result on 175 of the web's 184 photos. The other 9 are iPhone photos (Display P3) whose JPEG decoding differs. On a photo that iOS does not refine, every box goes to review.

Accomplishments that we're proud of

  • Every number names its sample. On set B medir (27 printed slips × 4 photos: 540 rows, 130 written boxes and 5 blank, written by one adult, the author), the cloud recipe accepted 373 rows (69.1%) with 3 silent errors, and the local recipe, Nano + Nano, 358 (66.3%) with 12. On R2 (120 rows), Nano accepted 112 with 2 silent errors, and the cloud pair 119 with 0.
  • The demo class. The 12 sample photos (60 boxes), read in the cloud through the product: 58 accepted, 2 blank, 0 to review, and all 60 match the protocol. That reading is the demo's recorded reading.
  • The two apps on the same slips. The web read 14 slips of the sample ticket with Nano, 10 of them captured by the iPhone 16: 56 accepted, 5 blank, 9 to review (including the 2 slips captured from a screen), and no silent error in Nano's readings of slips 1 to 12. Read in the cloud from the iPhone, the 12 sample photos gave 52 accepted, 2 blank, 6 to review and 0 silent errors.
  • On the device, also offline. With the network off, the web's local recipe read set A sheet 1 with all 42 readings on the device (in local development), and both iPhone sessions answered on the device. A student's note to the family, through Firebase AI Logic on an iPhone 16 with a local-only session, was written on the device 10 times out of 10, with a median of 1366.5 ms.
  • No key in Firebase. In the live check between the web and the iPhone, no key appeared in Firestore.
  • Tests. 893 in shared/, 1094 in web/ and 19 in scripts/ (commit f152b86); in ios/TizaCore, 405 tests in 49 suites with swift test on macOS, and 404 on the iOS 26.2 simulator (commit b69d069).
  • No billing. No Cloud Functions, no Cloud Storage: Tiza runs on the free tier of the Gemini Developer API.

What we learned

  • Agreement is not correctness. Both cloud models see the same crops, so a crop that looks like another value can fool both: in set B, 14 rows (6 boxes) have both cloud readings equal and wrong.
  • Route by what was measured. Apple Vision OCR got 77.5% on the printed slip, so it is not used to read answers. With reading 2 in the cloud, the local recipe had 4 silent errors instead of 12, but accepted 58.7% of rows instead of 66.3% and could no longer read offline, so the local recipe stays Nano + Nano.
  • A rule made from a set's errors is not a held-out result. In set B ajuste, the cloud recipe's 0 silent errors in 58 written boxes would admit up to about 5.2%, but that 0 comes after a rule made from set B's errors.
  • Zero silent errors gives a bound, not a guarantee. By the rule of three, 0 silent errors in N accepted admits up to about 3/N: on set A, Nano's 0 silent errors outside word in 30 accepted boxes admit up to about 10%.

What's next

What is still open, as the README's Limits section states it:

  • Children's handwriting was not measured, and nothing here is a claim about it. R2, set B and set D were written by one adult, the author; set A adds a second adult, on grid paper.
  • The acceptance criterion is not met. The design asks for 0 silent errors among accepted values in set B medir. The recipes had 12 (Nano + Nano), 4 (Nano + cloud) and 3 (cloud).
  • The automatic tiebreak is off and not measured. The third reading only orders the teacher's options.
  • Cloud failure handling was not measured. The switch to another model of a fallback list, and review after the retries run out, were not seen live.
  • Notes written on the device are drafts. In the demo-video take (12 notes by Apple's on-device model in an English class), some repeated a sentence many times, misstated a count, or named a mistake that is not on the ticket; nothing is sent until the teacher shares it.
  • The iPhone app is not distributed. Without a paid Apple developer account there is no TestFlight or App Store build. It uses App Check's debug provider, and its times come from Debug builds.
  • Marker writing is only in set B ajuste, so the medir numbers say nothing about it.

Built With

  • apple-foundation-models
  • apple-vision
  • chrome
  • cloud-firestore
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firebase-remote-config
  • gemini-3.1-flash-lite
  • gemini-3.5-flash-lite
  • gemini-developer-api
  • gemini-nano
  • google-sign-in
  • node.js
  • pwa
  • react
  • recaptcha-enterprise
  • swift
  • swiftui
  • typescript
  • vite
  • vitest
  • xcode
Share this project:

Updates

Submission history