System Architecture & Methodology
Development Methodology
The project follows an Agile, phase-based process. Each feature (planner, native reminders, voice, AI, sync, Call LAFINA, Ask USTP, study skills) was built, tested, and refined in its own phase, with automated checks (type checking, linting, and Jest tests) before each release.
Architecture at a Glance
LAFINA is a hybrid system. The phone does the core work, and a backend adds optional online features.
The Layers
Layer 1: Presentation React Native
React Native 0.86 with TypeScript. It provides the five main areas (Home, Schedule, AI, Skills/Tools, Profile), the chat screen and review cards, the reminder call screen, and Call LAFINA. Students can choose from 12 light and dark themes.
Layer 2: Application Services
TypeScript modules that act as LAFINA’s brain:
- Conversation orchestrator: decides whether a message is a planner change, a question about the student’s plans, or general conversation.
- Intent pipeline: rule-based fast-path parser, then an optional on-device model, then DeepSeek when online.
- Review and validation: turns proposed changes into review cards and checks for schedule conflicts.
- Scheduler: reminder delivery, snoozes, recurrence, and recovery after reboots.
- Memory, Ask USTP retrieval, and study skills.
Layer 3: Local AI and Android Native Offline
- Speech-to-text: Whisper.cpp (
tiny.en, quantized) with Silero VAD, through a C/C++ JNI module. - Understanding: a rule-based parser, plus an optional GGUF model run by llama.cpp (SmolLM2, Gemma 3, or Qwen 2.5, chosen by the student).
- Text-to-speech: the phone’s own speech engine through
react-native-tts. - Alerts: Android
AlarmManager, a full-screen call activity (including over the lock screen), and recovery receivers. - Documents: PDFBox for COR PDFs and ML Kit for photo OCR.
Layer 4: Local Storage Source of truth
One SQLite database (OP-SQLite, schema version 28, 36 tables) stores the planner, chats, memories, alarms, delivery state, the sync outbox, and the offline handbook index (FTS5 full-text search).
Layer 5: Optional Cloud
The LAFINA backend (Python FastAPI on Vercel, with Neon PostgreSQL) provides accounts, personal sync, and access to online AI. Provider API keys live only on the server. The app talks to DeepSeek, ElevenLabs, and Pinecone through the backend. For live voice, the backend issues a short-lived signed session.
Privacy by Design
Without an account, nothing leaves the phone. With an account, the app sends only what each feature needs. For example, planner details go to DeepSeek only when the question is about your own plans.
Online vs. Offline
| Capability | Offline | With Online Mode |
|---|---|---|
| Tasks, notes, calendar, alarms | ✅ Full | ✅ Plus sync across devices |
| Reminder calls | ✅ Phone voice + Whisper | ✅ Can continue into a live online conversation |
| Planner commands | ✅ Rules + on-device model | ✅ Plus DeepSeek understanding |
| Small talk | ✅ Built-in replies | ✅ Natural conversation |
| Trivia, explanations, study help | ❌ Asks you to turn on Online Mode | ✅ DeepSeek |
| Ask USTP | ✅ Local knowledge pack with sources | ✅ Friendlier answers from retrieved sources |
| Call LAFINA | ✅ Offline call (Whisper + phone TTS) | ✅ Live voice (ElevenLabs + DeepSeek) |
For step-by-step flows with diagrams, see How LAFINA Works.