Lafina is a privacy-focused, 100% on-device AI secretary built with React Native. It uses local LLMs and Speech-to-Text models to help you manage your calendar through natural voice commands and simulated incoming calls.
- On-Device LLM: Powered by
SmolLM2-135Mviallama.rn. - Offline STT: Powered by
Whisper Tinyviawhisper.rn. - Pre-crafted Responses: Context-aware reminder scripts generated during task creation.
- In-Call Interaction: "Barge-in" UI that lets you talk to the AI while simulate-calling.
- Background Persistence: Checks for scheduled tasks even when the app is closed.
This section outlines all necessary documentation for the project, including current implementations and future roadmap items.
- Installation Guide
- Prerequisites (Node.js, JDK, Android Studio/Xcode, Watchman)
- Environment Setup (Android
ANDROID_HOME& iOSCocoaPods) - Critical: Model Assets Download Links & Placement (
assets/models/) - Step-by-step generic "Build & Run" commands
- Project Structure / Architecture Overview
- Explanation of
src/services(Singleton patterns:DatabaseService,LLMService,VoiceService) - Explanation of
src/screensvssrc/componentsvssrc/navigation - State Management philosophy (
zustandstores) - Data Flow Diagram (Audio -> STT -> LLM -> TTS)
- Explanation of
- AI & LLM Service (
LLMService.ts)- Configuration options for
llama.rn(Context size, Threads, GPU/NPU delegates) - Prompt Engineering Templates (System Prompts used for specific tasks)
- Benchmarks (Inference speed on target devices)
- Configuration options for
- Voice Pipeline (
VoiceService.ts/VADService.ts)- VAD Threshold Tuning Guide (How to adjust sensitivity)
- STT Model nuances (
whisper.rnquantization trade-offs) - TTS Engine configuration (System voice vs Kokoro ONNX)
- Database & Persistence (
DatabaseService.ts)- SQLite Schema Documentation (Tables:
tasks,events,logs) - Migration Strategy (How to handle schema updates)
-
op-sqliteoptimization settings
- SQLite Schema Documentation (Tables:
- Background Tasks (
BackgroundService.ts)- OS-specific constraints (Android Battery Optimization / iOS Background Fetch)
-
react-native-background-actionsconfiguration - Notification Channel setup
- Call Simulation (
CallManager.ts)- State Machine diagram (Idle -> Ringing -> Active -> Ended)
-
react-native-callkeepintegration details (Native UI vs Custom UI) - Audio Session Management (How to handle interruptions)
- Smart Calendar (
CalendarScreen.tsx)-
react-native-calendarscustomization guide (Theming, Custom Renderers) - Agenda logic explanation
-
- Developer Tools
- How to use
DevConsoleScreen - Enabling/Disabling Logs in production
- How to use
- TypeScript Types
- Documentation of
Task,Event,ChatMessageinterfaces
- Documentation of
- Navigation Params
-
RootStackParamListdefinitions
-
- Theming System
- Design System tokens (Colors, Typography)
- Dark/Light mode implementation details
- Onboarding & Permissions
- Permission Flow implementation (Rationale > Request > Result)
- Testing Strategy
- Unit Testing Guide (Jest)
- E2E Testing Guide (Maestro/Detox)
- Release & Deployment
- Android
keystoremanagement & Singing configs - ProGuard rules explanation
- iOS Provisioning Profiles & TestFlight upload steps
- Android
- Cloud Sync (Planned)
- Firestore Schema (Parallel to SQLite)
- Sync Conflict Resolution Strategy
Before you begin, ensure you have the React Native Environment set up for your OS.
- Node.js (v18+)
- Android Studio (for Android) / Xcode (for iOS)
- CocoaPods (iOS only)
Follow the Official React Native Guide to set up your development environment for Android (primary) or iOS.
We have created a script to automatically download all required models and link them to your project.
Run the following command:
npm run setupThis script will:
- Create
assets/models/directory. - Download all required models (LLM, Whisper, VAD, Kokoro, Voices).
- Automatically run
npx react-native-assetto link them.
If you prefer to download manually or npm run setup fails, you can download all model files from this Google Drive folder:
π Download All Models (Google Drive)
Directory Structure:
Lafina-AI/
βββ assets/
β βββ models/
β βββ SmolLM2-135M-Instruct.gguf
β βββ ggml-tiny.en.bin
β βββ silero_vad.onnx
β βββ kokoro-v0_19.onnx
β βββ af_bella.bin <-- (If downloaded as 'voices.bin', RENAME to 'af_bella.bin')
β βββ cmudict.txt
Individual Source Links:
| Component | Filename | Source / Download Link | Purpose |
|---|---|---|---|
| LLM | SmolLM2-135M-Instruct.gguf |
HuggingFace (Q8_0) | Natural Language Processing & Intent Extraction |
| STT | ggml-tiny.en.bin |
HuggingFace (Whisper) | Speech-to-Text Transcription |
| VAD | silero_vad.onnx |
HuggingFace (Coqui Mirror) | Voice Activity Detection (Silent filtering) |
| TTS Model | kokoro-v0_19.onnx |
HuggingFace (thewh1teagle) | Text-to-Speech Synthesis |
| TTS Style | af_bella.bin |
HuggingFace (ONNX Community) | Specific Voice Style (Bella) |
| Dictionary | cmudict.txt |
GitHub (CMU Source) | Phoneme dictionary for TTS |
Then Link Assets:
npx react-native-asset-
Clone and Install Dependencies:
npm install # OR yarn install -
Link Assets: Run this to bundle the models into the native application:
npx react-native-asset
-
Android Specifics: Open the
/androidfolder in Android Studio and wait for Gradle sync to complete. If you encounter theVersionNumbererror, see Troubleshooting. -
iOS Specifics:
cd ios && pod install && cd ..
-
Start Metro & Run:
# Terminal 1 npm start # Terminal 2 npm run android # OR npm run ios
ConversationService.ts: The orchestrator. Fast-tracks audio -> text -> intent -> reply.LLMService.ts: Manages thellama.rncontext and system prompting.AudioService.ts: Wraps Recording andwhisper.rntranscription.VoiceService.ts: Abstracted Voice Engine (supports System TTS and future Kokoro ONNX).CallManager.ts: Handles incoming call simulation and in-call audio routing.DatabaseService.ts: Local storage viaop-sqlite.
If the build fails with Could not get unknown property 'VersionNumber', it's because onnxruntime-react-native uses a deprecated Gradle API.
Fix:
Open node_modules/onnxruntime-react-native/android/build.gradle and comment out the following block (around line 250):
// if (VersionNumber.parse(REACT_NATIVE_VERSION) < VersionNumber.parse("0.71")) {
// extractLibs "com.facebook.fbjni:fbjni:+:headers"
// extractLibs "com.facebook.fbjni:fbjni:+"
// }Ensure you have rebuilt the app with npm run android after adding the Kotlin files. If the error persists, check MainApplication.kt to ensure VADPackage() is added to the list.
- Android 14+ Permissions: Ensure
ACCESS_FINE_LOCATIONandPOST_NOTIFICATIONSare granted if background triggers fail. - Model Loading: If the app crashes on start, verify that the
.gguffile exists insrc/assets/models/and was correctly linked viareact-native-asset. - Audio Conflicts: If you hear no sound during calls, check the
CallManagerlogs to ensureInCallManagerstarted correctly.
Private Project - Lafina-AI Team.