skip to content
← back to all projects

studybuddy

On-device RAG study app for React Native.

React NativeExecuTorchSkiaSQLite
JunJulAugSepOctNovDecJanFebMarAprMay

sample data · 6,545 card reviews · busiest Fri, Apr 3

Elevator pitch

Drop in a PDF, get spaced-repetition flashcards back, and chat with the document — with the embedding model and the LLM both running on the phone via react-native-executorch. Nothing leaves the device.

What it is

A React Native app with three loops:

  1. Ingest loop. A PDF is extracted and chunked (~512 tokens, 64 overlap), each chunk embedded on-device by MiniLM-L6-v2 (384-dim) and stored in SQLite as a Float32 BLOB.
  2. Card-gen + chat loop. Representative chunks are sampled with k-means over the embeddings (topic coverage, not just page order), and Llama 3.2 3B generates structured Q/A + cloze cards from them; near-duplicate questions are dropped by cosine similarity. Chat does top-k retrieval over the same vectors and answers with page-cited evidence.
  3. Review loop. Cards are scheduled with FSRS-4.5 (a TypeScript port). The heatmap on the portfolio tile is the daily-review view.

All of it runs without a network once the models are downloaded. The phone is the server.

Status

Field Value
Repo github.com/mateokadiu/studybuddy
Status beta (v0.1)
Platforms iOS + Android via React Native (Expo dev client)
Models Llama 3.2 3B Instruct 4-bit (default; swappable to Phi-3.5 mini / Gemma 2 2B / Llama 3.2 1B) + all-MiniLM-L6-v2 embeddings

The problem I was solving

Notes apps make me file things. They don’t make me learn things. Anki is the gold standard for the review loop but every card is hand-authored — there’s no path from “I read 200 pages” to “I now have 30 well-tuned cards covering it”.

The bet: combine retrieval-augmented card generation with spaced repetition, and run it entirely locally because the documents are personal and I don’t want them in someone’s cloud.

Key decisions

  1. On-device only. Once that’s the spec, every other decision falls out: small quantised models, embeddings as BLOBs in SQLite, no auth surface, no sync.
  2. ExecuTorch (react-native-executorch). Runs both the LLM and the embedder behind one native module, accelerated on the Apple Neural Engine and Android NNAPI, with a catalog of models that are licensed for commercial use. Model files are SHA-256 verified on download.
  3. FSRS-4.5, not SM-2. FSRS is what Anki ships as its default scheduler and models retention better than SM-2; it’s pure math, so it stays a tested pure function.
  4. Mock-model dev path. By default the app runs against deterministic mock embeddings and canned LLM output, so every screen can be driven end-to-end without a 2.5 GB download.
  5. Skia for visualisations. The review heatmap and retention curve draw on the UI thread at 60fps.

Numbers

  • ~20 tok/s for Llama 3.2 3B on flagship phones (iPhone 15 Pro, Galaxy S24+)
  • 384-dim MiniLM vectors → 1,536 bytes per chunk
  • ~100 Vitest cases, ~500ms run
  • 0 bytes of personal data leaves the device