Inspiration
Every evening in Indonesia, parents sit down after work to help their children with PR — pekerjaan rumah, tonight's homework. The worksheet is in front of them, but the method school used is not the method they learned decades ago. A search engine gives answers without guidance, and a cloud chatbot means uploading photos of a child's schoolwork — and typing out a child's struggles — to a stranger's server, over a connection that may not hold. I built TemanPR to give parents guidance they can teach from, practice that works offline, and a simple promise: everything about your child stays on your device.
What it does
Set the child's class level (Kelas 1 SD – Kelas 9 SMP), subject, and tonight's topic once, then run one-tap jobs:
- Explain This Worksheet — photograph a worksheet page and get what it asks, step-by-step guidance a parent can teach from, key ideas, and a question to try together. It teaches the method instead of handing over answers.
- Practice Quiz — five practice questions on tonight's topic, with hints and an answer key that stays hidden until the child has tried.
- Explain It Simply — paste a confusing concept and get a plain-words explanation with an everyday example.
- Tonight's Study Plan — a timed plan for the evening, with breaks, fitted to the minutes the family actually has.
- Ask Privately — a parent's sensitive question about their child, answered on-device only. If no on-device model is available, TemanPR runs nothing rather than uploading the question.
Every result shows a served-by badge — ON-DEVICE or CLOUD — read from the AI response itself. Cloud jobs created while offline are queued on the device and run automatically when the connection returns. Everything is stored only in the browser; there is no account and no TemanPR server.
How I built it
TemanPR is a static web app (vanilla HTML/CSS/JS, no build step) using the Firebase AI Logic JS SDK (13.4.0) with the Gemini Developer API. Each job is a hybrid GenerativeModel with its own InferenceMode: worksheet-photo reading and the study plan use PREFER_IN_CLOUD (cloud model gemini-3.5-flash-lite, on-device fallback offline); the practice quiz and simple explanations use PREFER_ON_DEVICE (Gemini Nano via the Chrome Prompt API, cloud fallback); Ask Privately uses ONLY_ON_DEVICE. One JSON schema per job is sent to the cloud as responseSchema and to the device as responseConstraint, so both engines answer in the same shape. The badge renders the SDK's real response.inferenceSource — it is never a guess. App Check (reCAPTCHA Enterprise, with limited-use tokens for replay protection) protects the AI Logic quota. Prompts carry child-safety guardrails: guide the child to the answer, use age-appropriate language, and never diagnose.
Challenges
Hybrid inference only earns its keep when routing is a product decision, not a setting. I mapped each job to a mode by asking two questions: does the cloud's quality genuinely matter here (reading a photographed worksheet — yes), and is this about the child (practice, confusion, worries — keep it on the device). The hardest part was honesty in the UI: when the device model is missing, the fallback must be visible, not silent — hence the badge on every single result, and an Ask Privately that visibly refuses to run rather than quietly uploading.
What I learned
On-device AI changes what an app may ethically ask for. When inference is local, "we never see your data" stops being a policy sentence and becomes an architecture fact — and parents feel the difference immediately.
What's next
Sourcing the cloud model name from Firebase Remote Config so it can be switched without a redeploy, more subjects and class levels, and printable practice sheets.
Built With
- chrome-prompt-api
- css3
- firebase
- firebase-ai-logic
- firebase-app-check
- gemini
- gemini-3.5-flash-lite
- gemini-nano
- html5
- javascript