Prompt for AI Agent: Build Android Interactive
Math Tutor (High School)
Role
You are a senior Android engineer + product architect. Build a production-ready Android app skeleton
for an interactive high-school mathematics tutor. The app must be non-video, step-by-step
interactive, Arabic-first UI, with Arabic voice explanations, adaptive quizzes, mastery leveling,
spaced repetition review, and exam modes (including “night-before exam” pack). The initial deliverable
is a working app framework with all core systems implemented, but subject content files must be
empty placeholders (so content can be added later).
Platform + Language (fixed)
• Target: Android only
• Language: Kotlin
• UI: XML Views (not Compose) to keep resource usage lower
• Architecture: Clean architecture (presentation/domain/data) + MVVM
• Local DB: Room
• Background reminders: WorkManager
• Notifications: Android Notification APIs
• Math rendering: KaTeX in WebView (preferred) OR MathJax in WebView if KaTeX is problematic
• TTS: Android TextToSpeech using Arabic locale (ar)
• Offline-first: core functionality works offline; sync layer can be stubbed (no server required)
Non-goals
• No online accounts, no cloud backend required.
• No camera OCR/handwriting in v1.
• No LLM/AI model required for solving.
Product Requirements (must implement)
1) Core learning loop
Implement the full loop: - Diagnose → Teach → Practice → Verify → Review
2) Step-by-step interactive solving
• Problems and all intermediate lines are rendered as typeset math (LaTeX).
• User advances by pressing transformation buttons (rules).
• The UI must only show valid next-step actions for the current state.
• Each step produces a Step record:
• before expression AST
• after expression AST
• rule id
1
• Arabic on-screen explanation
• Arabic spoken explanation
• timestamp
3) Math representation
• Store math as an AST (expression tree) internally.
• Provide:
• AST → LaTeX serializer
• AST → Arabic “math speak” string (for TTS)
• Include a math keypad for input (digits, operators, parentheses, fraction, exponent, √, π, trig
functions, etc.).
4) Rule engine + verification
• Implement a deterministic Rule Engine with:
• Rule interface
• applicable(state)
• apply(state)
• explainAr(state)
• speakAr(state)
• Implement Verifier :
• symbolic equivalence where possible (basic simplifications)
• numeric spot-check fallback (3–5 random points, domain-safe)
5) Mastery + leveling
• Micro-skill mastery model per skill (0–100).
• Placement test that maps initial mastery.
• Thresholds:
• <60% guided
• 60–80% mixed
• 80% unlock next
• Error taxonomy:
• sign error
• arithmetic slip
• wrong rule
• invalid transformation
• order-of-operations
• “Mistake drill” routing after repeated error patterns.
6) Quizzes and practice modes
• Practice modes:
• Guided
• Independent
• Mixed Review
• Timed Test
• Each session saves analytics.
2
7) Exam preparation modes
• Exam Mode includes:
• Syllabus map (topic list)
• Timed mixed sets
• Error review
• Formula recall
• Night-before exam mode (single button):
• Top formulas/rules cards
• User’s 3 weakest micro-skills drills
• Mixed mini-exam
• Common traps checklist
• Optional: Morning-of exam warm-up (5–10 min)
8) Reminders
• Schedule daily reminder notifications via WorkManager:
• “Daily 5 minutes”
• exam countdown reminders if exam date set
• Provide settings screen for reminder time, mute, voice rate.
9) Arabic-first UX
• Entire UI in Arabic (RTL), formal Arabic.
• All step explanations and voice in Arabic.
• Provide a language toggle stub (Arabic default; English can be stubbed).
10) Offline-first
• App must run fully offline with local content.
• Sync layer should exist as a stub interface only.
Deliverable: Repository Layout (required)
Generate a complete Android Studio project with the following structure:
MathTutor/
app/
src/main/
[Link]
java/com/example/mathtutor/
core/
math/
ast/
parser/
serializer/
rules/
verify/
speak/
util/
3
data/
db/
repo/
model/
domain/
model/
usecase/
repo/
ui/
main/
lesson/
practice/
exam/
review/
progress/
settings/
components/
di/
res/
layout/
values/
values-ar/
drawable/
xml/
content/
[Link]
skills/
(EMPTY PLACEHOLDER FILES)
lessons/
(EMPTY PLACEHOLDER FILES)
question_banks/
(EMPTY PLACEHOLDER FILES)
exam_packs/
(EMPTY PLACEHOLDER FILES)
formula_cards/
(EMPTY PLACEHOLDER FILES)
Content folder requirement
• Create the content/ folder with subfolders shown above.
• Include only empty JSON/YAML placeholder files plus README explaining expected schema.
• App must load content via a ContentRepository that reads from this folder, but v1 can ship
with minimal demo content embedded in-app only as a developer sample, while real content
remains empty.
Data Models (required)
Implement Kotlin data classes: - Skill (id, nameAr, prereqIds, mastery) - Problem (id, skillId,
promptAst, targetAst, difficulty) - Step (problemId, index, beforeAst, afterAst, ruleId, explainAr,
4
speakAr, isCorrect) - Attempt (problemId, start/end times, mistakes, score) - Session (type, date,
list of attempts) - ExamPlan (examDate, syllabusSkillIds, modeSettings) - ReminderSettings
(enabled, time, voiceEnabled, voiceRate)
Screens (required)
Implement these activities/fragments + XML layouts: 1) Onboarding + Placement Test 2) Home
Dashboard - Continue - Daily Review - Exam Mode - Night-before button 3) Skill Tree screen 4) Lesson
Player screen - Rule card - Step-by-step guided example - Voice toggle + replay 5) Practice screen - math
keypad input - valid rule buttons - hints ladder 6) Review Queue screen 7) Exam Mode screen - timed
sets - syllabus map 8) Night-before Exam screen 9) Progress Analytics screen 10) Settings screen -
reminders - voice rate - offline storage info
Core Components (required)
Math Rendering
• Create MathRendererWebView component:
• renderLatex(latex: String)
• use KaTeX HTML template in assets
TTS
• ArabicTtsManager :
• init
• speak(text)
• stop
• setRate
• handle lifecycle
Rule Engine
• Implement at least 10 example rules (generic, not topic-specific content):
• simplify fraction
• combine like terms
• distribute multiplication
• factor common term
• rationalize denominator (basic)
• trig identity placeholder rule
• move term across equality
• divide both sides
• multiply both sides
• reduce radicals (basic)
• These can be minimal/placeholder implementations but must compile and demonstrate flow.
Verification
• EquivalenceVerifier :
• numeric spot-check implementation
5
• domain guards (avoid division by zero, sqrt negatives)
Spaced Repetition
• ReviewScheduler :
• uses mastery + last-seen
• selects daily queue
Quality Requirements
• Build must compile and run.
• No crashes on rotation.
• Handles RTL properly.
• Storage and DB migrations prepared.
• Minimal dependencies.
• Clean separation between UI, domain logic, and data.
Output Requirements
Produce: 1) The full file/folder tree. 2) All Kotlin source files. 3) All XML layout files. 4) assets/
templates for KaTeX rendering. 5) Sample demo content inside app (small) AND empty placeholders in
content/ . 6) A [Link] with setup and how to add new subject content later.
Notes on Arabic Math Speech
Implement an AST→Arabic speech converter with rules such as: - sin(x) = “ ”… جيب- cos(x) = “جيب
”… تمام- tan(x) = “ ”… ظل- π = “ ”باي- √a = “ ”… الجذر التربيعي لـ- fractions: “... على...” - exponent: “...
أس...”
Final Instruction
Proceed immediately to generate the entire Android project as specified. Ensure the content/ folder
exists with empty placeholders and schema docs so content can be added later without changing the
app architecture.