How LAFINA Works (Technical Q&A Guide)

What this page is for

A study guide for the technical Q&A. It explains the parts of LAFINA that panelists usually ask about, using simple diagrams. It is based on the current app source (v1.0.7), so a few details differ from the original research design in the paper. Those differences are listed in Paper design vs. the built app. When you’re ready, test yourself with Q&A Practice.

LAFINA in one minute

LAFINA is an Android app (React Native + TypeScript) that acts as an AI student companion. It keeps your classes, tasks, notes, reminders, and alarms on the phone, and you can manage them by tapping, typing, or talking. With Online Mode it also chats about anything, answers general and trivia questions, and helps you study.

Remember four ideas and you can answer most questions:

  1. Offline-first. The phone’s own SQLite database is the source of truth. Planning, alarms, reminder calls, and basic voice commands work without internet. Online services (DeepSeek, ElevenLabs, Pinecone) are optional extras.
  2. The AI proposes, the student confirms. When the assistant wants to add, change, or delete something, it shows a review card. Nothing is saved until the student taps Confirm (or says “yes”).
  3. Reminders arrive as a simulated call. Android’s alarm system triggers a full-screen incoming-call screen inside LAFINA. The student answers and speaks “done” or “snooze”, or uses the buttons.
  4. It’s a companion, not only a planner. Online, DeepSeek powers open conversation and study help. Offline, LAFINA still handles small talk and planner commands, and asks for Online Mode for trivia.

The big picture

Student Taps, types, or speaks
React Native app Screens: Home, Schedule, AI, Skills, Profile
Understanding Rule-based parser + optional on-device model (llama.cpp)
Voice Whisper.cpp listens, phone TTS speaks
Android alarms AlarmManager rings reminders and alarms
SQLite on the phone (lafina.db) Tasks, events, reminders, notes, chats, alarms
when online
Optional: LAFINA backend (FastAPI on Vercel) Sign-in, sync, online AI
DeepSeek Online chat replies
ElevenLabs Online voice
Pinecone Handbook search
Purple boxes are optional online services. Everything else runs on the phone.
LayerWhat it doesBuilt with
App / UIScreens, chat, call screen, review cardsReact Native 0.86, TypeScript
Brain (app services)Understands requests, checks them, prepares review cardsTypeScript in src/ai, src/scheduler
Local storageWorking copy of all planner dataSQLite (OP-SQLite), schema version 28
Native AndroidAlarms, microphone, speech, PDF/OCRKotlin + C/C++ (JNI)
Cloud (optional)Account, sync, online AI and voiceFastAPI on Vercel, Neon PostgreSQL

Q: Why is SQLite the source of truth instead of the cloud?

So the app never depends on the internet to save or ring a reminder. Every edit is written locally first. Sync is a background job that sends queued changes later, when the student is signed in and connected.

How a conversation works

This is what happens when a student sends a message in the AI tab, whether typed or spoken.

Student sends a message Typed, or spoken and turned into text by Whisper
Save the message Stored in the chat history in SQLite
Figure out the intent What does the student want? (see next diagram)
What kind of request is it?
change
Change a plan Add, edit, or delete a task, reminder, note, alarm…
question
Ask about plans "What's on my schedule today?"
chat
General chat Greetings, study help, handbook
Show a review card Student can edit, cancel, or confirm
Read local data Answer from SQLite. Nothing is written
Online: DeepSeek reply / Offline: local reply
Save + show the reply Optionally read aloud with text-to-speech
Simplified. Conflicts, memories, and handbook citations are added along the way but are left out here.

Step 1: understanding the message (intent extraction)

LAFINA turns a sentence into a structured intent: the action plus details such as title, date, and time. It tries the cheapest method first.

Fast-path parser (rules) Instant. Reads clear commands like "remind me tomorrow at 5 PM"
Is it confident and clean?
yes
Use it Confidence ≥ 0.85, clean title, not Taglish
no / unclear
Ask the on-device model GGUF model via llama.cpp, if installed
Online Mode on? Also ask DeepSeek For planner commands only. Falls back to local result if it fails
Validate the intent Checks fields and dates. Bad model output becomes plain "chat", which never writes

The possible intents include create_task, create_reminder, create_time_block, create_note, create_alarm, their update/delete versions, snooze, acknowledge, query_schedule, query_notes, list_alarms, chat, and out_of_scope.

Step 2: routing (who is allowed to write?)

Every intent belongs to one of three routes. The list is fixed in code, so a new intent cannot be added without choosing its route.

RouteExamplesWrites data?
Reviewed changecreate / update / delete tasks, reminders, notes, alarmsOnly after Confirm
Read only”What’s on my schedule?”, “List my alarms”Never
Conversationgreetings, study questions, handbook questionsNever

Step 3: the review card (confirm before saving)

Assistant prepares a proposal Shows title, date, time, and any schedule conflict
Student decides
edit
Edit Fix details, card updates
cancel
Cancel Nothing is saved
confirm
Confirm Saved to SQLite + queued for sync

A few low-risk actions skip the card and apply right away, with an Undo offer: completing a task, acknowledging or snoozing a reminder, and pinning or re-categorizing a note.

Q: Why not let the AI save things directly?

Language models can misunderstand dates and times. A review card lets the student catch mistakes before they become wrong reminders. It also keeps the AI from deleting data on its own: deletion is never prepared from the model’s words alone.

Online vs. offline conversation

OfflineOnline (signed in + Online Mode)
UnderstandingRule parser + optional on-device modelSame, plus DeepSeek extraction for planner commands
RepliesBuilt-in local replies for supported commandsDeepSeek, streamed word by word
Multi-step helpNoChat agent: DeepSeek can look up the planner (up to 4 steps) and prepare one review card. The tools run on the phone
HandbookLocal search of the USTP handbook packRetrieved passages + DeepSeek answer, with citations

Q: Does the cloud see my whole schedule?

No. Planner details are only sent when the question is about the student’s own plans. When the chat agent needs data, DeepSeek asks for it with a tool call, and the tool runs on the phone and sends back only what that question needs.

How the reminder call works

When a reminder is due, LAFINA does not just show a notification. It shows a simulated incoming call: a full-screen call screen inside the app. It is not a real telephone call and does not use a phone number.

Reminder time arrives Android AlarmManager fires, even if the app is closed
Safety checks Right owner? Still pending? Task not already done?
Phone rings with the call screen Answer or Decline
answer
Answered LAFINA speaks the reminder
decline / missed
Declined or no answer Auto-snooze
Listen for a reply Microphone + Whisper.cpp on the phone
What did the student say?
acknowledge
"Done" / "Okay" Reminder acknowledged
snooze
"Give me 10 minutes" Snoozed for that time, rings again later
unclear
Not understood Asks again. After 3 tries: auto-snooze
Acknowledging a call does not complete the task. The task stays pending until the student marks it done.

Key details:

  • Trigger: Android AlarmManager registers each reminder. Recovery code re-registers pending alarms after a reboot or timezone change.
  • Listening: Whisper (ggml-tiny.en-q5_1) runs on the phone. A keyword matcher turns the transcript into acknowledge or snooze (with minutes), e.g. “five more minutes” becomes snooze 5.
  • Buttons always work. If the microphone or speech model is not available, the call switches to Acknowledge / Snooze buttons.
  • Missed calls: declining or not answering auto-snoozes. Once the snooze limit is reached, the reminder is marked missed. A repeating reminder still schedules its next occurrence.
  • Online voice option: if the student is online with online voice enabled, LAFINA first says the reminder, then hands the call to the online conversation (see below).

Q: What if the phone is locked or the app is closed?

The alarm is registered with Android itself, so the app does not need to be open. Android wakes LAFINA and shows the call screen over the lock screen. Exact timing still depends on the phone’s permissions and battery settings, which is why Profile has an Alarm & Reminder Health screen with a test alarm.

How Call LAFINA works

Call LAFINA is different from a reminder call. The student starts it, to talk to LAFINA hands-free like a phone call. It has two modes, and LAFINA picks one when the call starts.

Student taps Call LAFINA
Signed in? Online Mode on? Internet available?
all yes
Online call ElevenLabs voice + DeepSeek
any no
Offline call Whisper.cpp + local parser + phone TTS
The mode is decided once at the start. A running call never switches by itself.

Online call

Local checks first Signed in, Online Mode, consent, internet, microphone permission
Backend grants a short-lived voice session Signed connection. API keys stay on the server
Live audio streams to ElevenLabs Speech to text, then voice reply
DeepSeek writes the reply Connected through the LAFINA backend
Needs your data? Tool call to the phone Reads the planner or prepares a review card locally
Student ends the call Transcript saved to chat

Offline call

The offline call works like a walkie-talkie: one speaker at a time (half-duplex), so LAFINA never hears her own voice as the student.

LAFINA speaks Phone text-to-speech. Microphone is off
Microphone listens Silero VAD detects when you stop talking (~0.7 s pause)
Whisper.cpp writes down the words On the phone
LAFINA responds Same rules as chat: answer, or show a review card
Back to "LAFINA speaks" Repeat until the call ends
Ends when the student taps End, after 3 silent listens in a row, or after 20 minutes.

Q: Does LAFINA always listen in the background?

No. There is no wake word and no always-on microphone. The microphone opens only during a call or push-to-talk the student started, and only after microphone permission is granted.

How sync works (short version)

Student saves a change
Write to SQLite + add to outbox In one transaction, so they cannot get out of step
Signed in and connected?
no
Wait Keep the change for later
yes
Send to backend Receive changes from other devices, record conflicts

Seven record types sync: profile, tasks, events, time blocks, reminders, notes, and custom categories. Alarm clocks stay on the phone where they were created. Guest mode works without an account and never syncs.

Paper design vs. the built app

The original research pages describe the first design. The app changed during development. If a panelist asks about a difference, these are the honest answers.

TopicOriginal designCurrent appWhy it changed
Reminder callReal outgoing phone call via telephonySimulated in-app call screenNo phone number or carrier needed, and it works offline
Text-to-speechKokoro-82MPhone’s built-in TTS (react-native-tts) offline, ElevenLabs onlineKokoro is not used. System TTS is lighter and already on the phone
UnderstandingSmolLM2 reads every replyRule-based parser first. On-device model (SmolLM2, Qwen 2.5, Gemma 3) only when neededRules are instant and predictable. The model adds latency and RAM
During a reminder callSmolLM2 judges intentKeyword matcher for acknowledge / snoozeA ringing call has to respond fast
ScopeOffline only, closed-domain scheduler, no chit-chatAI student companion: offline planner core + online conversation, trivia, study skills, Ask USTP, syncStudents use a companion every day. Online features add value but are never required

Likely panel questions

Is LAFINA a chatbot?

It’s an AI student companion. Online, it chats, answers general and trivia questions, and helps with studying through DeepSeek. Underneath is a task-oriented planner that works offline. Whatever the conversation, any change to the planner still goes through a review card.

What happens with no internet?

Tasks, notes, calendar, alarms, and reminder calls all keep working. Voice commands work after the offline speech model is set up. Only open-ended AI chat, online voice, document generation, and sync need internet.

How does it understand Taglish or casual phrasing?

The rule parser handles clear commands. When it sees Taglish or colloquial scheduling phrases, it does not trust itself and asks the on-device model (or DeepSeek, if online). The result is always validated before it is used.

What stops the AI from making a wrong change?

Three layers: (1) the intent is validated, and invalid output becomes plain chat, which never writes; (2) every change becomes a review card the student must confirm; (3) deletes are never prepared from model output alone.

Where is the data stored, and is it private?

On the phone in SQLite. Nothing goes to the cloud unless the student signs in. Online features send only what that request needs, and provider API keys stay on the backend server, not in the app.

Does answering the reminder call mark the task as done?

No, on purpose. Acknowledging only means “I heard it”. The student still marks the task complete, so a reminder answered while half-asleep doesn’t hide unfinished work.

Quick numbers to remember

FactValue
PlatformAndroid 11+ (API 30), React Native 0.86
Local databaseSQLite, schema version 28, 36 tables
Synced record types7
Offline speech modelWhisper tiny.en (q5_1), plus Silero VAD
Intent “confident” threshold0.85
Reminder call retries before auto-snooze3
Chat agent steps (online)Up to 4
Offline call limits20 min max, ends after 3 silent listens
BackendFastAPI on Vercel + Neon PostgreSQL

For more depth, see System Architecture, AI Models, and the Glossary. For many more practice questions with hidden answers, go to Q&A Practice.