Lesson 1: The Big Picture

Goal of this lesson

Be able to describe LAFINA in 30 seconds, list its main features, and explain the context and architecture diagrams.

What LAFINA is

LAFINA is an AI student companion for Android. It holds a student’s academic life (classes, tasks, events, time blocks, reminders, alarms, and notes) in a database on the phone. The student can manage it by tapping, typing, or talking. LAFINA also chats, helps with studying, answers USTP questions with sources, and calls the student when a reminder is due.

A separately maintained Electron PC client shares the same backend and account, so a student’s synced records follow them between phone and PC.

Feature map

AreaWhat the student can doWorks offline?
HomeToday’s timeline, “Up Next” countdown, quick actions, customizable layout✅
ScheduleClasses, events, time blocks, week and month views, recurring schedules, conflict checks, .ics import and export, Philippine holidays✅
AI (Chat)Plan by text or voice, ask about your plans, small talk✅
Open conversation, trivia, explanations, Chat agent, streamed replies🌐 Online Mode
Ask USTPHandbook and campus questions with sources✅ local pack, 🌐 nicer answers online
SkillsPomodoro, flashcards, GWA calculator, to-dos, notes, alarms✅
AI quizzes, summaries, Lesson Q&A, documents, meeting notes🌐
CallsReminder calls (LAFINA calls you), Call LAFINA (you call LAFINA)✅ offline call, 🌐 live voice
ProfileAccount, sync, themes, voice settings, Memory, Alarm & Reminder Health, AI engine choice✅ (sync needs 🌐)
Floating LAFINAOptional bubble that opens Quick Chat over other apps (off by default)✅

The context diagram (Level 0)

A context diagram shows the whole system as one box (“Process 0”) and only the external entities it exchanges data with. Data stores like SQLite and Neon are inside the box, so they don’t appear.

Student Guest or signed-in, on Android or the PC client
0. LAFINA Apps + local services + shared backend. Review → Confirm → Save
DeepSeek Gets prompts + context, returns replies and proposed actions
Pinecone Gets handbook queries, returns passages + sources
ElevenLabs Gets speech text and authorized mic audio, returns audio + transcripts
Simplified. Arrows mean 'exchanges data with'.
LAFINA context diagram (Level 0)
Official context diagram: Process 0 with Student, DeepSeek, Pinecone and ElevenLabs. Open full size ↗

How to read it:

  • Student → LAFINA: account details, planner entries, questions and voice, COR and calendar files, confirmations and preferences.
  • LAFINA → Student: sync status, saved plans, answers with sources, alerts and spoken replies, import previews and generated files.
  • The three AI providers are optional. Core guest planning never touches them.

System architecture

Student
Android app React Native + TypeScript. SQLite, Whisper, rules, AlarmManager
Desktop app Electron PC. Its own SQLite + sync queue
Internet (HTTPS + JWT) Only when signed in / Online Mode
LAFINA-backend FastAPI on Vercel. Auth, sync, online chat + RAG, speech sessions, documents
Neon PostgreSQL: accounts + synced data
DeepSeek Online assistant
Pinecone Handbook retrieval
ElevenLabs TTS + live voice
Purple boxes are optional online services. Everything else runs on the device.
LAFINA system architecture
Official system architecture: clients, shared backend, data and AI services. Open full size ↗

The layers inside the Android app

LayerResponsibilityWhere in the code
PresentationScreens, navigation, themes, onboarding, product tour, call UIApp.tsx, src/ui
Application servicesConversation, intent parsing, review cards, scheduling, skillssrc/ai, src/scheduler, src/skills
Local persistenceOne OP-SQLite database, migrations, stores, sync outbox, search indexessrc/storage
Android / nativeKotlin bridges and receivers. C/C++ JNI for Whisper and the local model. PDF and OCRandroid/app/src/main
Cloud boundaryCloud client, sync worker, voice session APIsrc/cloud, src/sync

Two important details

  • Live voice is special: the backend only authorizes a session. The phone then streams audio directly to ElevenLabs over a signed WebSocket.
  • Provider API keys stay on the backend. The app never contains DeepSeek, Pinecone or ElevenLabs secrets.

Technology stack

AreaTechnology
Mobile UIReact Native 0.86, React 19.2, TypeScript 5.9 (strict), Hermes
NativeKotlin 2.1, JDK 17, C/C++ JNI, CMake, Android NDK 27
Database@op-engineering/op-sqlite 16.2, SQLite migrations, FTS5 search
Speech recognitionwhisper.cpp + Silero VAD
UnderstandingRule-based fast-path parser + optional llama.cpp GGUF model
Speech outputreact-native-tts (phone voice). ElevenLabs online
AlertsAndroid AlarmManager, receivers, full-screen call activity
COR / filesPDFBox Android, ML Kit text recognition, document picker
Calendarrrule (recurrence), ical-js-parser (.ics)
BackendPython FastAPI on Vercel, Neon PostgreSQL
Online AIDeepSeek, Pinecone, ElevenLabs
TestingJest, React Native Testing Library, ESLint, Prettier, TypeScript

Check yourself

  • Explain LAFINA in two sentences, including the word “companion” and “offline-first”.
  • Name the three external AI services and what each one does.
  • Why don’t SQLite and Neon appear as external entities in the context diagram?
  • What does the backend do for live voice, and what does it not do?
  • Name three features that need Online Mode and three that don’t.