Inspiration

Most students study by rereading. It feels productive, and it is one of the least effective things you can do. Rereading, highlighting and summarising were rated low utility in Dunlosky et al.'s review of ten study techniques, while practice testing and spaced practice were the two rated high. Everyone knows the feeling of closing a textbook, thinking "I know this", and then blanking on the exam.

I kept coming back to an old idea: you don't really know something until you can teach it. Research on learning by teaching backs it up, especially when you teach from memory instead of from your notes. But a student can't always find a person who will sit and listen to them explain Chapter 7 at 11 pm.

So I gave them a pupil: a cartoon goldfish. A goldfish is the right character for the job because it forgets everything. That is a feature. The fish forgetting is the reason to come back and explain it all again, which is exactly the spaced retrieval practice the research recommends.

The hackathon's theme, hybrid AI, turned out to fit the idea closely. A big cloud model is the right tool for reading a chapter and writing a fair exam. A small on-device model is the right tool for being a pupil, and its weakness is actually useful: a small model only gets the answer right if your explanation is clear.

What it does

Goldfish is an iPhone study app where you learn a chapter by teaching it to a goldfish named Finn.

  1. Add a chapter. Paste text or import a PDF. Gemini in the cloud reads it and writes a hidden exam: concepts, plus practice, final and "Your Turn" questions. Code validates every question before it is stored.
  2. Teach Finn. You write one short explanation per concept in "the Bowl", with a word limit. Pasting is blocked, and any sentence copied from the chapter is flagged and doesn't count.
  3. Finn takes the exam using only what you wrote. Apple's on-device model plays Finn, so it's free, instant and works offline. Re-quiz after every edit.
  4. See exactly why Finn got it wrong. If Finn picks a wrong answer, Goldfish highlights the sentence of yours that misled him (a mix-up). If your lesson never covered the point, it says so (a gap). The correct answer stays hidden until a question has been missed twice.
  5. Finn forgets overnight. When a chapter is due, the Bowl opens empty and you re-teach from memory (Fresh Water), then answer questions Finn never saw (Your Turn) by typing your recall first, choosing, and saying how sure you are.
  6. Your own answers decide mastery, not Finn's score. A concept is mastered after correct unaided answers on three different days.

Around that loop: spaced reviews fitted to your exam date, a forgiving "fire" streak that turns to embers instead of resetting, a Report Card written by the cloud, Orla (a second goldfish who has read your deck and answers with a hint, a question back and a passage to reread, never the answer), and teach-offs where two friends teach the same chapter and see whose explanation worked, idea by idea. Only scores are shared. Lessons never leave the phone.

How the hybrid AI is split

Job Where it runs Why
Write the hidden exam Gemini (cloud), JSON schema Needs long context and strong reasoning
Play Finn, answering from your lesson alone Apple's on-device model, Gemini Flash-Lite as fallback Free and offline. A small model is a good pupil because it needs clear explanations
Check each exam question is fair On-device only Runs in the background while you read
Write the Report Card Gemini (cloud) Summarises the whole session
Orla's hint On-device first, cloud as backup Searching needs no model. A short grounded hint fits the small model

Every fish answer carries a badge, "On this iPhone" or "Cloud", and each quiz shows a running count, so the hybrid split is visible instead of hidden.

How I built it

  • SwiftUI app, iOS 26+, generated from an XcodeGen project.yml, with Firebase as the only dependency.
  • Firebase AI Logic hybrid inference for every model call, through one hybrid session with Apple's on-device model as primary and Gemini as the secondary (all in App/Services/FirebaseModels.swift). Firebase App Check protects the cloud calls, Remote Config holds model names and limits, and anonymous Firebase Auth plus Firestore power the optional friends features.
  • A pure-Swift core package (GoldfishCore). Prompt building, reply parsing, grading, the own-words check, exam validation, scheduling, mastery rules and teach-off scoring all live in a Foundation-only package with 185 unit tests, so the logic can be tested in seconds without a phone.
  • Grading is done by code, not by a model. This is the key design decision. Finn's answer counts only if he quotes a sentence from the student's lesson that satisfies

$$q \in L \;\wedge\; 3 \le |q|_{\text{words}} \le 30 \;\wedge\; \text{key}(o) \in q$$

where $L$ is the lesson, $q$ is the quoted sentence and $\text{key}(o)$ is the key term of the option Finn chose. Anything else counts as "not taught". A model can't talk its way into a point it didn't earn, which turns most "the model just knew the answer" leaks into honest gaps.

  • Spaced review. Chapters come back 1, 3, 7 and 14 days after first teaching. With an exam date set, the next gap is roughly 15% of the days remaining, clamped to a range:

$$g \approx \min!\big(14,\ \max(1,\ 0.15\,d)\big), \qquad d = \text{days until the exam}$$

  • Retrieval for Orla without a model. Her search runs on the phone by combining BM25 keyword ranking (with stemming) and Apple's sentence embeddings, joining the two rankings so a student can ask in their own words instead of the textbook's.
  • A Fish Check. A hidden Diagnostics screen runs 20 cell-biology questions against a good lesson, a lesson with a fact missing, one with a fact wrong, and an empty lesson, to measure whether the on-device model answers from the lesson rather than from what it already knows.
  • Everything is original. Finn is an 8-bit sprite whose pixels are generated from code, the sound effects are synthesised by a script, and the screens follow a purple, Poppins-based education UI kit.

Challenges I ran into

  • No Mac, no phone loop. I wrote Swift on a Windows laptop with no Swift toolchain, compiled on a remote Mac over SSH, and sideloaded an unsigned .ipa with a free Apple ID (which expires after 7 days). Apple's on-device model can't even run on a cloud Mac. I designed around the constraint: logic in a testable core package, every model call behind a protocol, and a scripted stand-in fish so screens could be driven in the Simulator.
  • An experimental API with a 4,096-token window. Hybrid inference is marked experimental, on-device requests are text-only, and structured output on-device was not yet documented for Swift. So Finn's replies use a plain-text format with our own parser, and the lesson size, Bowl limit and long documents (split at headings into several chapters) are all sized to that window.
  • Small models know things. The central risk of the product is a fish that answers from its own knowledge instead of the student's lesson. That is why the quote check, the key-term rule and the Fish Check exist.
  • Making failure feel safe. There are no hearts, no dying fish and no failure buzzer. A mix-up is a curious wobble and a gap is a bubble.
  • Hiding the answer is a design problem. If feedback just shows the right answer, students paste it into the Bowl and skip the learning. Answers stay hidden until the second miss, final questions are held out, and mastery comes from the student's unaided answers.
  • Scope. Between decks, Orla, friends, sounds and teach-offs, it was easy to build features faster than I could test them on a real phone. We set a feature freeze and put the core loop first: compiled, tested and demo-ready.

Accomplishments that I'm proud of

  • A genuinely hybrid design where each tier does the job it's best at, and the user can see which one answered.
  • Feedback that points at the exact sentence the student wrote, which is what makes a miss teachable.
  • A grader that is code, not a vibe: deterministic, testable and explainable.
  • A study loop built on named techniques (retrieval practice, spacing, teaching from memory, calibrated confidence), with an evidence table in the repo that is honest about which claims are strong and which are contested.
  • Privacy by default. Lessons never leave the phone, friends are optional and anonymous, and turning friends off deletes the profile and shared chapters.
  • A fully original character, sound set and UI, all generated from source in the repo.

What I've learned

  • Weak models can be better pupils. Constraining a small model to "only what you were taught" and verifying the quote in code turned its limitations into the product's teaching signal.
  • Put the checkable logic in a pure package. With a slow build loop, 185 core tests were worth more than any amount of careful reading.
  • Cloud and device tiers can check each other. The cloud writes the exam and the phone tests whether each question is fair.
  • Be honest about the evidence. The research gives strong backing to retrieval and spacing and weaker, mixed backing to teaching a fictional audience. I didn't claim that Goldfish improves grades, because no study of this app exists.

What's next for Goldfish

  • Publish the Fish Check results and run the short-answer Grading Check on the iPhone, then switch graded recall on for everyone only if it passes.
  • Second opinion: let the cloud re-grade the phone's typed-answer grades when you're back online and show how often the two tiers agree.
  • A small pilot: classmates use Goldfish on one chapter and reread another, then take the same quiz a week later.
  • A focus timer with teach-back checkpoints, scanned-PDF support through on-device text recognition, and subjects beyond fact-heavy text.
  • A TestFlight release once I have a paid developer account.

Built With

  • apple-foundation-models
  • apple-intelligence
  • cloud-firestore
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-remote-config
  • gemini
  • github-actions
  • ios
  • naturallanguage
  • pdfkit
  • swift
  • swift-package-manager
  • swiftui
  • xcodegen
Share this project:

Updates

Submission history