Inspiration
Students in Saudi Arabia study for school and for two national exams, Qudrat and Tahsili. Good practice questions are scarce, and most AI study tools need an account, a subscription, or an API key a student does not have. We wanted a study companion that is free, private, and works from the student's own textbook, on the phone they already own.
About Qudrat and Tahsili. These are Saudi Arabia's two national standardized tests, run by the National Center for Assessment (Qiyas). Nearly every secondary-school student who wants to go to university takes them:
- Qudrat (General Aptitude Test) measures verbal and quantitative reasoning.
- Tahsili (Scholastic Achievement Admission Test) measures what the student learned in math, physics, chemistry and biology across the secondary grades.
Most Saudi universities rank applicants by a composite of the high-school GPA, the Qudrat score and the Tahsili score, with weights each university sets. That makes these exams decisive for admission. Good practice material is mostly paid, and Revisal gives students thousands of practice questions for free, offline.
What it does
- Review any curriculum: the student adds a textbook or summary as a PDF, names its units by pages, and picks a unit and 1-10 questions. AI writes four-option multiple-choice questions spread across the unit's sections and skills. Refresh brings questions never asked before.
- Qudrat and Tahsili banks: 6,011 bundled questions that work offline, with no repeats until the whole bank is done.
- Explain: under every question, the AI explains why the correct answer is right, only when the student asks. A small label shows whether it was answered on this iPhone or by Gemini in the cloud.
- Results by skill, every answer next to the correct one, and Retry my mistakes.
- Arabic and English: the interface follows the phone's language.
- Private: no account and no server of our own. Data stays on the phone.
How we built it (how we used Firebase AI Logic)
Revisal is a SwiftUI app. Its AI goes through one hybrid engine, FirebaseHybrid.swift:
- On-device first. If Apple Intelligence is available (
SystemLanguageModel.default.isAvailable), the prompt is in a language the on-device model supports (supportsLocale), and it fits the 4,096-token context, the request runs on the iPhone through Apple's Foundation Models framework. Explaining an English question is the typical case: private, free and offline. - Cloud fallback through Firebase AI Logic.
- Long unit text, Arabic content (which the on-device model does not support yet) and phones without Apple Intelligence go to Gemini through Firebase AI Logic.
- On iOS 27 this uses
ai.geminiLanguageModel(name:)inside the same Foundation ModelsLanguageModelSessionAPI, so one API serves both paths. - JSON question writing and multimodal input (scanned PDF pages, figures in bank questions) use
generativeModelwithInlineDataPart. - A busy or rate-limited model is retried, then replaced by a second Gemini model.
- Graceful failure. If the on-device model fails, or returns JSON that does not parse, the same request falls back to the cloud automatically.
- Supporting Firebase products.
- App Check is enforced for AI Logic; the build uses a debug token, as the rules allow.
- Remote Config holds the cloud model names and an on-device switch, so none is fixed in the binary.
- No-Mac CI.
- The app is built on GitHub Actions (
xcode-27runner). The Firebase config and the App Check token come from repository secrets and are never committed. - A second workflow runs the real app in the iOS simulator, makes live Firebase calls, and records the demo footage.
- The app is built on GitHub Actions (
What we built during the submission period (existing app, significantly updated)
Revisal existed before the hackathon (v1.0, Nov 2026). AI then worked only through API keys the student pasted. During #BuildHybridAI (v1.1) we added:
- The built-in hybrid AI: on-device Apple Foundation Models with Gemini cloud fallback, through Firebase AI Logic. No key needed any more.
- App Check and Remote Config.
- English explanations for English questions, so they qualify for on-device inference.
- A complete English interface, with the layout following the phone's language.
- A Built-in AI section in Settings (on-device availability) and an engine label above each answer.
- The demo-recording CI workflow.
Core value of the existing app
A free, open-source study app for students: bundled national-exam banks (6,011 questions), curriculum review from any PDF, and per-skill results, all on the phone with no account. The hybrid AI removes its biggest barrier: students no longer need to create and paste an API key.
Challenges we ran into
- Arabic is not yet supported by the on-device model. We route by detected language, so Arabic goes to Gemini and English can stay on the device.
- The on-device context is 4,096 tokens. Whole textbook units go to the cloud, and short, focused requests like explanations go to the device.
- Free-tier limits. A busy or exhausted model moves to a second Gemini model instead of failing.
- No Mac. Every build, test and recording runs on GitHub Actions.
Accomplishments that we're proud of
- Zero setup: install and start studying, with no account and no key.
- One code path, two engines: the engine that answered is visible to the student.
- Bilingual: the interface is fully Arabic and English, without breaking the existing Arabic experience.
What we learned
Hybrid inference is most useful when routing is explicit. It should be decided by language, length and modality, not just by whether a model exists. Showing the user which engine answered builds trust.
What's next for Revisal
- On-device question writing for short English summaries.
- Structured output (
@Generable) on the device. - Arabic on the device as soon as Apple's model supports it.
Testing instructions for judges
- Install
Revisal-unsigned.ipafrom the release link with Sideloadly and a free Apple ID (iOS 17+). - With the phone in English, open Settings. The Built-in AI section shows "Ready with no key" and whether Apple's on-device model is available on your phone.
- Curriculum: add any English PDF, add a unit, then tap Start review. Questions are written by Gemini through Firebase.
- Answer a question, then tap Explain. On an iPhone with Apple Intelligence (iOS 26+), an English question is answered on the device; otherwise by Gemini. The label says which.
- Qudrat / Tahsili: start a review from the bundled banks (offline). These questions are Arabic, so Explain uses the cloud.
The source is all in the repository. The runtime Firebase calls are in ios/Revisal/AI/FirebaseHybrid.swift.