PageTeacher — Devpost

Inspiration

Students still learn from printed textbooks that often don't exist as files, and many study offline or on shared devices where privacy matters. Teachers spend evenings turning a chapter into a lesson plan and a script. Existing AI tutors expect a PDF upload, a constant connection, and sending everything to a server.

We wanted a tutor that starts from the paper in front of you, does the short, private work on your own device, and only goes to the cloud when the work is actually too big for the device.

What it does

PageTeacher turns a printed page, or a typed topic, into a narrated lesson. It is English-only.

Learn a page: Photograph one printed page, or use the built-in sample page. You get key points and a 3-question quiz, then narrated slides that explain the page. As each bullet is read aloud, it lights up on the slide and its sentence lights up in the page text. Answer a quiz question wrong, and only the slide that question came from is re-taught.

Ask privately: Ask about the page or the current slide. Tick Private, and the question is answered only on-device. If no local model is available, the app says so and sends nothing.

Explain any topic: Type a topic or question in English. A short search plan runs on-device, the app pulls the matching Wikipedia articles, and the cloud writes a narrated slide talk. Each slide gets a Wikimedia Commons picture with author, license, and a link. The device's own voice reads it aloud, and an on-device quiz checks understanding.

Prepare a class: Teachers photograph up to 10 pages of a chapter. The cloud writes a lesson plan, board notes, class questions, homework, and a full script. They edit it as plain text, rehearse it as narrated slides using exactly the edited text, rewrite it simpler or for exam review, and export it as Markdown.

Works offline: The bookshelf, lessons, and explainers come from Firestore's local cache. On-device work keeps working offline; cloud steps fail fast with a clear message instead of hanging.

How we built it

One Expo (React Native + TypeScript) codebase for Web and Android, built on Firebase AI Logic.

Every AI call goes through one router (src/ai/router.ts) with an explicit mode, and the UI shows the source that actually ran as an On device / Cloud badge, read from the SDK's inferenceSource, never guessed. The AI activity screen logs every call: task, requested mode, where it actually ran, latency, and why.

Task Mode
Key points, keywords, quiz, slide questions, topic quiz, topic search plan PREFER_ON_DEVICE
Private question ONLY_ON_DEVICE
Page photo understanding (figures, formulas, layout) ONLY_IN_CLOUD
Slide lectures, chapter plan + script, script rewrite, topic slides PREFER_IN_CLOUD

On Web we use the Firebase Web SDK (firebase/ai) with Chrome's Prompt API (Gemini Nano), SDK ≥ v12.5.0, desktop Chrome ≥ 139, with initializeDeviceModel() called after a user tap. On Android we use @react-native-firebase/ai, which has no hybrid mode, so Android is cloud-only in this version and is always badged Cloud.

Other Firebase products: App Check (enforced, with single-use tokens), Anonymous Authentication, Firestore with persistent cache and owner-only rules, Remote Config for lecture style, and Hosting. Abuse is limited in three layers: enforced App Check, a server-side per-user quota (about 10 requests per minute needed), and an in-app limit of 12 AI requests per minute and 150 per day per device; Private on-device requests are not counted.

Narration uses the device's system voice (Web Speech API on Web, expo-speech on Android). No voice model runs on a server. Topic text is from Wikipedia (CC BY-SA, linked) and pictures from Wikimedia Commons (credited and linked).

Challenges we ran into

On-device inference is small and strict: single-turn text only, input + output around 4,000 tokens, output target around 256 tokens, foreground only. Long pages had to be split, and only the relevant segment is sent. Every task also had to request structured JSON on both paths, validate it, and retry once, so raw model text never reaches the UI.

Private mode needed a guard, not just a mode flag. When the browser has no Prompt API, firebase/ai would send every request to the cloud, even ONLY_ON_DEVICE. So the web router refuses ONLY_ON_DEVICE before any request in that case, and discards any on-device-only result that did not actually come from the device. That behaviour is covered by regression tests.

Android was a second problem: the React Native Firebase AI package exposes no InferenceMode or inferenceSource, so real on-device on Android needs a separate native bridge. We built the ML Kit OCR module for the private text path, but it is not yet compiled, and the Android on-device bridge itself is still P1 and unverified on a real device, so we did not claim it.

Accomplishments that we're proud of

The hybrid routing is real and visible, not a README claim: badges on every result, an activity log that shows where each call actually ran, and a Private mode that errors instead of silently falling back to the cloud.

The two loops actually work end to end on Web: a student can go from a photo to key points, quiz, narrated slides, and a targeted re-teach of one wrong slide; a teacher can go from 10 pages to an editable, rehearsable script and a Markdown export.

The topic explainer is the most complete piece: an on-device search plan, Wikipedia grounding, cloud-written slides, credited Commons pictures, system-voice narration, and an on-device quiz, all saved so it works offline later.

The sample page, private-question error, topic explainer, and lecture voice are also verified on an Android 16 emulator, with the badge correctly showing Cloud.

What we learned

Hybrid inference is a routing and honesty problem, not just a model choice. The interesting work is deciding what is small and private enough for the device, what is too long for it, and what to do when the device says no — and then showing that decision to the user.

We also learned to design to the on-device budget first. Splitting pages, capping output, and validating structured JSON on both paths made the cloud path better too.

Finally, a smaller, verifiable demo beats a bigger, unverified one. Keeping the scope to what we could actually test on Web and on the Android emulator made the product easier to explain and easier to trust.

What's next for PageTeacher

  • Verify a real On device badge on the demo Chrome with Gemini Nano downloaded, and verify the Android on-device bridge on a real Gemini Nano device before claiming Android on-device anywhere.
  • Compile and test the ML Kit OCR private path on Android, and finish verifying re-teach and the offline bookshelf.
  • A mistake book and flashcards built from the quiz results and key points you already have, so wrong answers turn into spaced re-tests instead of disappearing.
  • Per-slide pictures chosen with image understanding, and classroom sharing of explainers.

Built With

Share this project:

Updates

Submission history