CASE STUDY · Native Android (Kotlin + Jetpack Compose) · 2026
AI Study Coach
A native Android study companion that turns any document, URL or photo into summaries, flashcards, quizzes and a scheduled study plan, with AI economics that actually scale to a free tier.
Native Android

- AI Study Coach
- Edtech / Study tools (consumer)
- Native Android (Kotlin + Jetpack Compose)
- Kotlin, Jetpack Compose, Material 3, Hilt, Room, Retrofit, FastAPI, PostgreSQL, OpenAI, Firebase Auth, Google Play Billing, ML Kit
- 2026
- Mobile app development
The brief
Most AI study apps fall apart the moment a free user tries the second feature, either the quota model is too generous and burns the operator, or too tight and the user never sees the value. AI Study Coach needed a native Android build with proper Material 3 polish, real spaced repetition, and an AI backend whose unit economics work at a free tier without compromising the experience.
What we did
- Built the Android client natively in Kotlin and Jetpack Compose with Material 3 dynamic colors on Android 12+, MVVM via Hilt, and Room as the local source of truth.
- Built a FastAPI backend in Python on PostgreSQL with quota enforcement, content-hash caching, idempotency keys, and OpenAI GPT-5 Mini routing (with DeepSeek as a configurable fallback).
- Implemented spaced repetition (SM-2 algorithm) for flashcards, four quiz formats (multiple choice, true/false, fill-in-the-blank, matching), and dynamic 3–14 day study plans that scale with content length.
- Wired Firebase Auth (Google + email/password), a custom OTP email-verification flow via Resend with branded HTML, Google Play Billing for the premium subscription, and ML Kit OCR for image-based content import.
- Added gamification (XP, levels, achievements, streaks), a Pomodoro focus timer with foreground service, leaderboards, and a server-rendered admin portal in Jinja2.
How we built it
The architectural problem is AI cost: a free-tier study app that pays for every generation against a per-request OpenAI bill goes bankrupt by the second power-user. The backend treats AI calls as billable resources to defend. Every generation hashes its input (SHA-256 of user, type and content) and serves identical requests from cache without re-billing OpenAI. Every client request carries an idempotency UUID, so a network retry never double-counts against the user's quota. The AI is instructed to return JSON only, validated against Pydantic schemas, with one repair-retry on malformed output before failing gracefully. On the device, Room is the source of truth: AI-generated study sets persist locally the moment they come back, so the app is fully usable offline once a generation completes. The auth flow is guest-first — users can start immediately with no sign-up and upgrade later, with all data preserved via account linking. Custom OTP verification (branded HTML through Resend, 10-minute expiry, 60-second resend cooldown) replaces Firebase's generic email so users never leave the app's visual world.
A study app with AI inside has two failure modes that bankrupt it. The first is treating AI as a free resource and watching one power user burn through a month of margin in an afternoon. The second is throttling so hard that nobody sees the value before they bounce. AI Study Coach threads that needle with a native Android client and a FastAPI backend that treats every AI call as a billable resource worth defending.



Why native Android, not React Native
The product surface is dense: a dashboard with stats, study-set list and detail screens, a flashcard reviewer with flip animations and SM-2 scheduling, a quiz engine with four question formats and a chat tutor, plus folders, analytics, a Pomodoro timer, notifications, social leaderboards and an admin portal. Going native in Kotlin and Jetpack Compose with Material 3 gave dynamic colours on Android 12+, a single typed codebase end to end (Kotlin on the device, TypeScript-shaped Pydantic schemas on the backend), and direct access to Android subsystems: AlarmManager + BootReceiver for streak reminders that survive reboots, ML Kit Text Recognition for OCR import, EncryptedSharedPreferences for token storage, and a foreground service for the Pomodoro timer that keeps running while the app is backgrounded.
AI economics, designed in
The FastAPI backend treats AI as a metered resource. Every generation
request hashes its input — SHA-256 of (user_id, content_type, content) —
and serves a cache hit when the same content rolls back through. Identical
re-runs cost nothing and don't count against the user's quota. Every
client request carries an idempotency UUID, so a network retry never
double-charges. The AI is told to return JSON only, validated against
Pydantic schemas, with one repair-retry on malformed output before a
graceful failure. Quota tiers are enforced at the API layer (1/day
anonymous, 10/day free, unlimited premium) alongside a five-per-minute
rate limit. The result: AI spend is bounded per-user and per-day
regardless of how aggressive the usage pattern gets.
Spaced repetition done properly
Flashcards run on the SM-2 algorithm, the original spaced-repetition schedule. Each card carries a difficulty, an ease factor and an interval in days. After a review, the algorithm computes the next interval based on how the user rated their recall; cards converge to a stable monthly cadence once known and resurface as "due" automatically. The reviewer surfaces this honestly: it shows the current interval (days / weeks / months), the known-vs-review breakdown on completion, and lets the user fall back to an "All cards" mode for cramming when SRS feels too slow.
Guest-first, then upgrade without losing anything
Sign-up friction kills onboarding for a consumer app. Users start immediately as anonymous guests with a single AI generation a day, full access to flashcards, quizzes and study plans, and zero email field. When they're ready to upgrade — usually because they hit the quota or want their study sets backed up to the cloud — account linking moves their existing data onto the registered account without re-creating anything. Email sign-ups go through a custom 6-digit OTP verification flow with branded HTML through Resend instead of Firebase's generic verification email, so the visual world never breaks. Google sign-ins are auto-verified.
Offline by default, sync when online
Room is the source of truth on the device. AI-generated content lands in local storage immediately, so the app is fully usable offline once a generation has completed. For registered users, study sets sync to the backend in the background, and a fresh install signs in and restores everything from the cloud. The chat tutor is a deliberate exception — it needs network for streaming responses — but the rest of the app keeps working at 35,000 feet.
What shipped
A native Android app on Play with a viable free-tier business model underneath: guest-first onboarding, SM-2 flashcards, four quiz formats, dynamic study plans, an AI chat tutor scoped per study set, OCR import from camera or gallery, PDF and URL ingestion, gamification, analytics, a Pomodoro timer that runs as a foreground service, social leaderboards and a server-rendered admin portal. The Next.js marketing site at aicoachstudy.com and the FastAPI backend deploy together from one Docker image on Render.
The result
AI Study Coach ships as a polished native Android app with a viable free tier (10 generations a day, 8K-character input) and a $5.99/month premium tier that unlocks unlimited generations, 20K input, AI chat tutor, advanced analytics and offline mode. Cache hits and idempotency keep AI spend bounded while the SM-2 flashcard engine, four quiz formats and dynamic study plans give power users a real reason to stay. The Next.js marketing site and FastAPI backend deploy together from one Docker image on Render.
SHA-256
Tech stack
- Kotlin
- Jetpack Compose
- Material 3
- Hilt
- Room
- Retrofit
- FastAPI
- PostgreSQL
- OpenAI
- Firebase Auth
- Google Play Billing
- ML Kit
07, START A PROJECT
Want work like this?
Tell us what you're building. We reply within 4 hours during UK business hours.