Skip to content

Moes-AI/gemma-3n-impact-challenge

Repository files navigation

Tree of Trust: Secure, On-Device AI with Gemma 3N

Team Member: Greg Mousseau

Summary

Tree of Trust is a mobile application that creates a safe, private space for personal reflection and AI-powered conversation by running Google's Gemma 3N model directly on the user's device. In an era where online data is perpetually at risk, our solution ensures that a user's thoughts and queries are protected, with roots firmly planted in on-device processing.

🔐 The Privacy Promise

Your thoughts never leave your phone. Period.

  • 100% on-device inference using Gemma 3N
  • No internet connection required after initial setup
  • No cloud APIs, no data collection, no telemetry
  • Chat history stored locally with user control

The Problem: A Crisis of Trust

Online, privacy is an illusion. Every major tech company has suffered massive data breaches. Users are justifiably wary of sharing sensitive information with cloud-based AI systems. This fear creates a significant barrier to using AI for personal, meaningful tasks like mental health support, journaling, or creative brainstorming.

Our Solution

Tree of Trust provides a sanctuary for private thoughts:

  • Therapeutic AI Companion — Empathetic, supportive conversations
  • 100% Offline — Works without internet after model is loaded
  • User-Controlled Data — Clear your history anytime
  • Beautiful UX — Calm, focused interface designed for reflection

Tech Stack

  • Framework: React Native + Expo
  • AI Model: Google Gemma 3N (2.9GB, int4 quantized)
  • Inference: MediaPipe LLM via react-native-llm-mediapipe
  • State: Zustand with AsyncStorage persistence
  • Build: EAS Build (cloud) for bundling large model

Getting Started

Prerequisites

  • Node.js 18+
  • pnpm (or npm/yarn)
  • Expo CLI: npm install -g expo-cli
  • EAS CLI: npm install -g eas-cli
  • Expo account (free): https://expo.dev/signup

Installation

# Clone the repo
git clone https://github.com/Moes-AI/gemma-3n-impact-challenge.git
cd gemma-3n-impact-challenge

# Install dependencies
pnpm install

# Download the Gemma 3N model (2.9GB)
# Place it at: assets/models/gemma-3n-E2B-it-int4.task
# Model available from: https://www.kaggle.com/models/google/gemma-3n

Building with EAS (Recommended)

Local builds fail due to the 2.9GB model file. Use EAS Build instead:

# Login to Expo
eas login

# Configure EAS for your project
eas build:configure

# Build for Android (development client)
eas build --platform android --profile development

# Or build a preview APK
eas build --platform android --profile preview

The build runs on Expo's cloud servers which handle large assets properly.

Running Locally (Development)

For development without the model:

# Start Metro bundler
pnpm start

# Run on Android (requires dev client from EAS)
pnpm android

Project Structure

rn/
├── src/
│   ├── App.tsx              # Navigation setup
│   ├── screens/
│   │   ├── ChatScreen.tsx   # Main therapeutic chat
│   │   ├── ModelLoadingScreen.tsx
│   │   └── SettingsScreen.tsx
│   ├── components/
│   │   ├── MessageList.tsx
│   │   ├── ChatInput.tsx
│   │   └── VoiceInput.tsx
│   ├── stores/
│   │   └── chatStore.ts     # Zustand + persistence
│   └── utils/
├── GemmaBridge/
│   └── js/index.ts          # Native module interface
├── assets/
│   └── models/              # Gemma 3N model goes here
└── android/                 # Native Android code

Demo Video

Watch on YouTube

Why On-Device Matters

Cloud-based AI requires sending your most private thoughts to distant servers. Even with encryption, data breaches happen. With Tree of Trust:

  1. No network = No leak — Airplane mode works fine
  2. No servers = No breach risk — Nothing to hack
  3. No logging = No regrets — Speak freely

Future Roadmap

  • Voice input with on-device speech recognition
  • iOS support
  • Conversation export (encrypted)
  • Custom persona/therapist styles
  • Mood tracking integration

License

MIT

Acknowledgments

  • Google Gemma team for the incredible on-device model
  • Kaggle for hosting the Gemma 3N Impact Challenge
  • MediaPipe team for the LLM inference framework