Reference architecture for on-device AI inference on Android — clear boundaries between UI, inference, and optional cloud fallback.
Demonstrates how to structure on-device ML without coupling Compose UI to a specific model runtime:
| Layer | Responsibility |
|---|---|
| UI | SummarizeScreen — input, loading state, result |
| Inference boundary | OnDeviceSummarizer interface |
| Implementation | LocalTextSummarizer (deterministic, no network) |
Swap LocalTextSummarizer for:
- Gemini Nano (AICore on supported Pixel devices)
- ML Kit GenAI APIs
- ONNX Runtime Mobile / TensorFlow Lite
Compose UI → OnDeviceSummarizer (interface) → Model runtime (pluggable)
No API keys required for the sample. Processing runs entirely on-device.
./gradlew assembleDebug
./gradlew testDebugUnitTest- android-platform-starter — platform template
- sliide-kmp-user-management — KMP architecture reference
MIT — see LICENSE.