Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Riverbloom 🌱

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.


✨ What the app does

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.

Privacy model

  • 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.

🏗 Architecture

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:

  • model is the pure domain layer — interfaces and data classes only. Features depend on contracts, never on repository implementations. Hilt binds them at the app level.
  • Feature api modules 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; only MainActivity owns the real NavHost and translates events (including system-settings intents) into actions.

MVI with Orbit

Every screen follows the same unidirectional pattern via a shared BaseViewModel<STATE, SIDE_EFFECT> (core/mvi):

  • initialState() + one-time initData() on first observation
  • State mutates only inside intent { reduce { ... } }
  • One-shot events (navigation, toasts) via postSideEffect(...)
  • UI observes stateFlow / sideFlow; screen args are read through SavedStateHandle helpers

On-device AI

  • Reflections: Gemma 4 E2B in single-file .litertlm format, 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 fixed StoryVibe vocabulary so every day always has a drawable visual even offline. Results are cached in Room.

🛠 Tech stack

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+).


🚀 Getting started

Prerequisites

  • Android Studio (Ladybug or newer recommended), JDK 17
  • An Android device or emulator (API 21+; API 24+ for on-device reflections)

Build & run

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 dev

Configure the Gemini API key (optional — Story Highlights)

Add your key to the git-ignored local.properties:

GEMINI_API_KEY=your_key_here

It 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.

Provisioning the on-device model (optional — AI reflections)

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:

  1. App-private storage: files/llm/gemma-4-E2B-it.litertlm
  2. 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.

Runtime permissions

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

🧪 Testing

./gradlew test
  • ViewModel tests use Orbit's test framework with fakes (FakeNavigator, repository fakes) — see feature/reflect/src/test and feature/insights/src/test.
  • Repository logic is unit-tested in repository/src/test.

📦 Adding a new feature module

  1. Create feature/<name> and feature/<name>/api, and register both in settings.gradle.kts.
  2. Apply the convention plugin: id("base.android.feature.compose") — it wires Compose, Hilt, Orbit, and the standard dependencies in one line.
  3. Expose a serializable destination in the api module; add the composable<YourDestination> entry to the NavHost in MainActivity.
  4. Extend BaseViewModel<State, SideEffect> and follow the existing Intent / State / SideEffect / Route file layout (any existing feature is a template).

📄 License

This project is provided as-is for learning and reference purposes.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages