https://cerebralvalley.ai/e/google-deepmind-bangalore-hackathon/hackathon/gallery?project=7
A privacy-first digital wellbeing Android app that turns your phone-usage data into warm, judgement-free daily reflections — powered by an on-device LLM (Gemma via LiteRT-LM), so your behavioural data never leaves your phone.
Built as a showcase of a modern, multi-module Android architecture: Jetpack Compose · MVI (Orbit) · Hilt · Clean Architecture · Convention Plugins.
| Feature | Description |
|---|---|
| Reflect (start screen) | Onboarding + daily reflection flow: Welcome → Analyzing → Insights. Reads today's usage via UsageStatsManager, enriches it with notification signals, and generates "mirror, not scold" reflection cards with the on-device model — streaming progress live into the UI. |
| Insights / Stats | Week / Month / Year usage trends with a "what's improving" / "room to grow" narrative. Numbers are computed deterministically; only the interpretive prose is (re)written by the model. |
| Story Highlights | An Instagram-style 7-day reel of your usage. Each day gets a deterministic "vibe" (🚀 restless, 🌙 light, 🧠 focused, 🎉 social, 🪷 balanced, ⛈ late-night) rendered as procedural art. On demand, the "Nano Banana 2 Lite" Gemini model generates an AI headline + illustration for the day you're viewing — cached in Room so each day is only generated once. |
| Home | Landing hub for navigation between features. |
- Everything stays on your phone. Usage summaries and reflections are produced entirely on-device — the reflection engine has no network path and no rule-based cloud fallback.
- Notification signals are counts and timings only. Notification content is never stored or exposed.
- The only network call is Story Highlights' optional image/headline generation via the Gemini API — and only for the single day being viewed. With no API key configured, it transparently falls back to on-device analysis and procedural art.
Multi-module Clean Architecture with a strict inward dependency rule and per-feature api modules for navigation decoupling:
app → application host: owns the NavHost, splash screen, DI root
│
├── feature/
│ ├── reflect (+ api) → onboarding + daily reflection (Welcome → Analyzing → Insights)
│ ├── insights (+ api) → usage trends & stats
│ ├── stories (+ api) → 7-day Story Highlights reel
│ └── home (+ api) → landing hub
│
├── navigation → Navigator abstraction + ObserveNavigation (features never touch NavController)
├── core → design system (theme, icons, mascot, breathing guide), MVI BaseViewModel, ApiResult
├── model → pure domain layer: contracts (UsageRepository, ReflectionEngine, StoriesRepository…) + models
├── repository → data layer: all implementations (usage stats, LLM, Room, Retrofit, notifications)
│
└── build-logic → Gradle convention plugins (composite build)
Key rules:
modelis the pure domain layer — interfaces and data classes only. Features depend on contracts, never onrepositoryimplementations. Hilt binds them at theapplevel.- Feature
apimodules expose only a type-safe destination (e.g.StoriesDestination), so features can navigate to each other without depending on each other's implementation. - Navigation is inverted: features emit navigation events through the injected
Navigator; onlyMainActivityowns the realNavHostand translates events (including system-settings intents) into actions.
Every screen follows the same unidirectional pattern via a shared BaseViewModel<STATE, SIDE_EFFECT> (core/mvi):
initialState()+ one-timeinitData()on first observation- State mutates only inside
intent { reduce { ... } } - One-shot events (navigation, toasts) via
postSideEffect(...) - UI observes
stateFlow/sideFlow; screen args are read throughSavedStateHandlehelpers
- Reflections: Gemma 4 E2B in single-file
.litertlmformat, run through the LiteRT-LM runtime (com.google.ai.edge.litertlm). The multi-GB model file is not in the APK — see Provisioning the on-device model. - Story Highlights:
NanoBananaClient(Retrofit + Moshi + OkHttp) calls the Gemini API for headline + image generation, constrained to the fixedStoryVibevocabulary so every day always has a drawable visual even offline. Results are cached in Room.
| Layer | Choice |
|---|---|
| Language | Kotlin 2.2 (K2), coroutines + Flow |
| UI | Jetpack Compose + Material 3 |
| Presentation | MVI via Orbit MVI |
| DI | Hilt (Dagger) |
| Navigation | Navigation Compose with type-safe (kotlinx.serialization) destinations |
| Persistence | Room (story cache), DataStore Preferences (settings) |
| Networking | Retrofit + Moshi + OkHttp (Story Highlights only) |
| On-device AI | LiteRT-LM (Gemma 4 E2B, .litertlm) |
| Build | Gradle convention plugins (composite build-logic), version catalog (libs.versions.toml) |
| Tooling | Fastlane, Timber, JUnit + Orbit test + coroutines-test |
Min SDK 21 · Target/Compile SDK 34 (on-device LLM requires API 24+).
- Android Studio (Ladybug or newer recommended), JDK 17
- An Android device or emulator (API 21+; API 24+ for on-device reflections)
git clone <repo-url>
cd base-app
# Assemble a debug APK
./gradlew assembleDebug
# Or build + install + launch on a connected device via Fastlane
bundle install
bundle exec fastlane android devAdd your key to the git-ignored local.properties:
GEMINI_API_KEY=your_key_hereIt is injected as a BuildConfig field and never committed. Without a key the app still works — stories fall back to on-device analysis and procedural art.
The Gemma .litertlm model file is provisioned out of band (it's too large for the APK). The runtime looks for it at, in order:
- App-private storage:
files/llm/gemma-4-E2B-it.litertlm - Dev location via adb:
adb push gemma-4-E2B-it.litertlm /data/local/tmp/llm/Without the model, reflections still show the day's deterministic facts — just without the AI-interpreted insight cards.
The app guides you through granting two special accesses in system Settings:
- Usage access (
PACKAGE_USAGE_STATS) — required to read screen time / unlocks / app opens - Notification access (NotificationListenerService) — optional, enriches reflections with per-app notification counts
./gradlew test- ViewModel tests use Orbit's test framework with fakes (
FakeNavigator, repository fakes) — seefeature/reflect/src/testandfeature/insights/src/test. - Repository logic is unit-tested in
repository/src/test.
- Create
feature/<name>andfeature/<name>/api, and register both insettings.gradle.kts. - Apply the convention plugin:
id("base.android.feature.compose")— it wires Compose, Hilt, Orbit, and the standard dependencies in one line. - Expose a serializable destination in the
apimodule; add thecomposable<YourDestination>entry to theNavHostinMainActivity. - Extend
BaseViewModel<State, SideEffect>and follow the existing Intent / State / SideEffect / Route file layout (any existing feature is a template).
This project is provided as-is for learning and reference purposes.