Skip to content

Happiffy/Happify-Mobile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“± Happify-Mobile β€” Flutter Companion App

Detect Early. Support Meaningfully. Grow for Life.

Framework Language State Navigation Auth CI License Hackathon


The Flutter companion app of Happify β€” mood tracking, journaling, mindfulness, an AI voice companion, anonymous community support, professional care, and companion-device management, all in one pocket-sized, accessible client.

🌐 Frontend Β· ☁️ Backend Β· 🧠 AI Β· πŸ“± Mobile Β· πŸ”Œ IoT


πŸ“Œ Overview

Happify-Mobile is the on-the-go client of the Happify ecosystem. Everything the web dashboard offers is available here too β€” plus voice conversations with the AI companion, mindfulness exercises, and direct management of a paired Happify Companion (IoT) device β€” packaged as a single Flutter codebase targeting Android and iOS.

Happify-Mobile's role in the ecosystem: "A friend who is here to listen β€” wherever the user is, not just at a desk."

Like the web frontend, the mobile app never calls Happify-AI directly. Every request β€” mood entries, journals, voice turns, community posts, referrals β€” goes through Happify Backend, which brokers AI access, enforces auth, and persists everything.

Framework Flutter 3.38 (stable)
Language Dart ~3.10
State Management flutter_bloc (Cubit-based)
Navigation go_router with auth-aware redirects
Auth Firebase Auth (Email/Password + Google)
Networking Dio (ApiClient, shared across repositories)
Notifications Firebase Cloud Messaging
Audio record, audioplayers, flutter_tts
Distribution Signed Android APK/AAB via GitHub Actions

🌐 Happify Ecosystem

Happify-Mobile talks to the same backend as the web app β€” mood, journal, community, care, and device-pairing data are shared across both clients in real time.

Repository Role Link
🌐 Happify-FE Web dashboard β€” mood, journal, community, care Happiffy/Happify-FE
☁️ Happify-BE Node.js API, PostgreSQL, Firebase, WebSocket hub Happiffy/Happify-BE
🧠 Happify-AI FastAPI service β€” journal reflection, risk detection, voice processing Happiffy/Happify-AI
πŸ“± Happify-Mobile Flutter app for mood tracking, journaling, and care access on the go (this repo) Happiffy/Happify-Mobile
πŸ”Œ Happify-IOT Voice-companion device paired and managed from this app Happiffy/Happify-IOT

System architecture:

graph TD
    MB["πŸ“± Happify-Mobile (this repo)"] -->|REST + Firebase ID token| BE["☁️ Happify-Backend"]
    FE["🌐 Happify-Frontend"] -->|REST + WebSocket| BE
    MB -->|pairing + telemetry| DEV["πŸ”Œ Happify-IOT device"]
    DEV -->|runtime credential| BE

    BE --> PG[("πŸ—„οΈ PostgreSQL")]
    BE --> FB["πŸ”₯ Firebase (Auth + FCM)"]
    BE -->|voice / journal| AI["🧠 Happify-AI"]
    FB -->|push notifications| MB

    style MB fill:#58CC02,color:#fff,stroke:#46A302
    style BE fill:#1CB0F6,color:#fff,stroke:#168CC7
    style AI fill:#CE82FF,color:#fff,stroke:#A760D2
    style DEV fill:#FF9600,color:#fff,stroke:#D97A00
Loading

Principles this app is built around:

  • Privacy by design β€” Community participation is alias-based, and location/heatmap data stays coarse and anonymous.
  • Safety first β€” Voice and journal risk signals are computed by Happify-AI via the backend; the app surfaces them, it never decides on its own.
  • Human support matters β€” Care chat, referrals, and emergency contacts are one tap away from the home shell.
  • Accessible by default β€” Built-in text scaling, high contrast, reduced motion, and screen-reader-oriented settings, applied globally via MediaQuery overrides in main.dart.
  • Secure operations β€” Firebase config files (google-services.json, GoogleService-Info.plist) and the Android upload keystore are Git-ignored and injected only at CI release time.

✨ Features

  • πŸ” Authentication β€” Firebase email/password and Google sign-in, session restoration on launch, and guest mode when Firebase isn't configured.
  • 🧭 Onboarding & Consent β€” Illustrated intro slides, a guided account setup flow, and an explicit consent review screen before protected features unlock.
  • 😊 Mood Tracker & Analytics β€” Daily mood check-ins with trend charts and voice-conversation mood patterns.
  • πŸ““ Daily Journaling β€” Private reflections synced to the backend, enriched with AI-generated mood, risk level, and reflection text.
  • πŸŽ™οΈ AI Voice Companion β€” Record a voice turn, see the live transcript, detected mood/risk, and play back the generated spoken reply.
  • 🧘 Mindfulness β€” Breathing, grounding, and meditation exercises with per-activity progress tracking.
  • πŸ«‚ Anonymous Community β€” Alias-based posts, comments, and support reactions in a moderated peer space.
  • 🀝 Professional Care β€” Request referrals, browse providers, and chat live with an accepted psychologist (/care, /care/chat/:sessionId).
  • πŸ”Œ Companion Device Management β€” Pair a Happify Companion device, inspect telemetry, manage firmware/OTA status, and send haptic/display commands.
  • πŸ“ Consent Center β€” Granular consent toggles for AI processing, voice processing, device emotion observation, and heatmap contribution.
  • β™Ώ Accessibility Controls β€” Text scale, high contrast, reduced motion, and screen-reader optimization, applied app-wide.
  • πŸ”” Push Notifications β€” FCM token registration and per-category notification preferences (care chat, referrals, mood reminders, wellbeing updates).
  • πŸ†˜ Emergency Contacts β€” Add, edit, and mark a primary emergency contact directly from the profile.

πŸ› οΈ Tech Stack

Layer Technology Purpose
Framework Flutter 3.38 (stable) Cross-platform UI for Android and iOS
Language Dart ~3.10 Null-safe, strongly typed application code
State Management flutter_bloc + equatable Cubit-per-feature pattern (mood, journal, care, community, companion, consent, home, profile)
Navigation go_router Declarative routing with an auth-aware redirect guard
Networking dio Shared ApiClient wrapping every backend call
Authentication firebase_auth, google_sign_in, sign_in_button Email/password and Google sign-in
Push Notifications firebase_messaging Foreground/background FCM handling
Voice record, audioplayers, flutter_tts Recording, playback, and text-to-speech for the AI companion
Maps flutter_map + latlong2 Anonymous heatmap / location-aware views
Rich Content flutter_html Rendering journal/community HTML content
Media image_picker Attaching images to journals, posts, and chat
UI google_fonts, phosphor_flutter, iconify_flutter, colorful_iconify_flutter Typography and iconography matching the Happify design system
Local Storage shared_preferences, path_provider Settings persistence and file paths
Location geolocator Location access for heatmap contribution
Testing flutter_test Widget/design-system regression tests
Distribution flutter_launcher_icons, GitHub Actions App icon generation and signed Android release builds

πŸ“ Project Structure

Happify-Mobile/
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ main.dart                  # Entry point, GoRouter routes + auth redirect guard
β”‚   β”‚
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ app_services.dart      # ApiClient (Dio), AuthController, AppSettings,
β”‚   β”‚   β”‚                          # SpeechService, PushService β€” the app's service layer
β”‚   β”‚   β”œβ”€β”€ happify_repository.dart # Shared REST calls (profile, preferences, media, etc.)
β”‚   β”‚   β”œβ”€β”€ di/app_scope.dart       # InheritedWidget wiring for services
β”‚   β”‚   β”œβ”€β”€ theme/                  # happify_colors.dart, happify_theme.dart
β”‚   β”‚   └── widgets/                 # Shared buttons, emoji icons, quokka badge, etc.
β”‚   β”‚
β”‚   └── features/                    # One folder per domain, each with bloc/ + data/
β”‚       β”œβ”€β”€ home/                     # Dashboard shell and entry
β”‚       β”œβ”€β”€ mood/                      # Mood tracking and analytics
β”‚       β”œβ”€β”€ journal/                    # Daily journaling
β”‚       β”œβ”€β”€ companion/                   # Device pairing, telemetry, firmware/OTA
β”‚       β”œβ”€β”€ community/                    # Anonymous peer community
β”‚       β”œβ”€β”€ care/                          # Referrals and live care chat
β”‚       β”œβ”€β”€ consent/                        # Consent management
β”‚       β”œβ”€β”€ profile/                         # Profile, password, notifications, psychologist application
β”‚       β”œβ”€β”€ onboarding/                       # Account setup flow
β”‚       β”œβ”€β”€ media/                             # Image upload repository
β”‚       └── *_pages.dart                       # Route-level page composition per module
β”‚
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ mascot/                    # App icon + quokka artwork
β”‚   └── illustrations/             # Onboarding and auth illustrations
β”‚
β”œβ”€β”€ android/                       # Android project (signing config injected at CI time)
β”œβ”€β”€ ios/                           # iOS project (Runner target)
β”œβ”€β”€ .github/workflows/android.yml  # CI: analyze on every PR, signed release on tag/dispatch
β”œβ”€β”€ test/                          # Widget and design-system regression tests
β”œβ”€β”€ .env.example
└── pubspec.yaml

Each feature module follows the same shape: a Cubit (bloc/*_cubit.dart) holding an immutable State (bloc/*_state.dart), backed by a Repository (data/*_repository.dart) that calls HappifyRepository/ApiClient, with a top-level bloc_<feature>_page.dart composing the UI.


βš™οΈ How the App Works

Startup and auth-aware routing (main.dart):

flowchart TD
    A[App launch] --> B[Initialize Firebase]
    B --> C[Load AppSettings from SharedPreferences]
    C --> D[AuthController.initialize β€” restore Firebase session]
    D --> E[SplashPage]
    E --> F{Session restoring?}
    F -->|yes| E
    F -->|no| G{canUseProtectedFeatures?}
    G -->|yes| H["/app β€” Happify Shell"]
    G -->|no, onboarding done| I["/welcome"]
    G -->|no, first launch| J["/onboarding"]
    H --> K{consentReviewed?}
    K -->|no| L["/consent β€” must review before continuing"]
    K -->|yes| H
Loading

A voice companion turn:

sequenceDiagram
    participant U as User
    participant M as Happify-Mobile
    participant BE as Happify-BE
    participant AI as Happify-AI

    U->>M: Tap record, speak
    M->>M: Capture audio (record package)
    M->>BE: POST /voice/turns (audio + Firebase ID token)
    BE->>AI: POST /api/process-audio
    AI-->>BE: transcript, response, mood, risk_policy, audio_url
    BE-->>M: Structured voice turn result
    M->>M: Display transcript + mood/risk badges
    M->>M: Play response audio (audioplayers / flutter_tts)
Loading

Companion-device pairing:

sequenceDiagram
    participant U as User (Mobile)
    participant M as Happify-Mobile
    participant BE as Happify-BE
    participant D as Happify-IOT device

    U->>M: Start pairing from /companion
    M->>BE: POST /devices/pairing-sessions
    BE-->>M: pairingSessionId + short code
    U->>D: Enter code on device / device polls session
    D->>BE: Claim pairing session (device claim secret)
    BE-->>M: WebSocket / poll: pairing completed
    M->>BE: GET /devices/:id (telemetry, firmware, status)
    BE-->>M: Device state
Loading

πŸ—ΊοΈ Application Routes

Path Description
/ Splash screen β€” Firebase session restoration
/onboarding First-launch illustrated intro
/welcome Sign-in entry point
/login Β· /register Β· /forgot Email/password and Google authentication
/setup Post-registration account onboarding
/consent Mandatory consent review before protected features
/app Main Happify shell (home, mood, journal, mindfulness, profile tabs)
/companion Companion-device pairing and management
/voice AI Voice Companion
/care Β· /care/chats Β· /care/request Β· /care/chat/:sessionId Referrals, care-chat list, new request, live chat
/contacts Β· /contacts/new Β· /contacts/edit Emergency contact management
/profile/edit Β· /profile/password Β· /profile/psychologist Profile editing, password change, psychologist verification
/notifications Notification preference settings

GoRouter's redirect callback (in main.dart) centrally enforces: unauthenticated users are bounced to /welcome, authenticated-but-not-yet-consented users are forced through /consent, and already-authenticated users are redirected away from /login//register//welcome straight into /app.


πŸ” Environment Variables

Flutter reads configuration through --dart-define / --dart-define-from-file, not a bundled .env file. Create a local .env from .env.example for reference:

BE_API_URL=https://happify-be-production.up.railway.app
Variable Description
BE_API_URL Base URL of Happify Backend β€” the only backend the app talks to

The mobile app deliberately does not define an AI_SERVICE_BASE_URL β€” AI access is always brokered by Happify Backend.

Firebase configuration is provided through the official native files, not environment variables:

  • Android β†’ android/app/google-services.json
  • iOS β†’ GoogleService-Info.plist, added to the Runner target in Xcode

Both are Git-ignored. Without them, the app still opens in guest mode, but authentication and push notifications are unavailable.


πŸš€ Getting Started

Prerequisites

  • Flutter 3.38.9 (stable channel)
  • Dart 3.10.8
  • Android Studio or Xcode for your target platform
  • A reachable Happify Backend instance
  • Firebase project configuration for the target platform(s)

Installation

git clone https://github.com/Happiffy/Happify-Mobile.git
cd Happify-Mobile
flutter pub get

Run on the Android Emulator

Create .env.emulator:

BE_API_URL=http://10.0.2.2:4000
flutter run --dart-define-from-file=.env.emulator

10.0.2.2 is the Android emulator's alias for the host machine's localhost.

Run on a Physical Device

flutter run --dart-define=BE_API_URL=https://your-backend.example

Local Release Build

flutter build apk --release --dart-define-from-file=.env
flutter build appbundle --release --dart-define-from-file=.env

Verification

flutter analyze
flutter test
flutter build apk --debug --dart-define-from-file=.env

πŸ€– CI/CD β€” Android Release Pipeline

.github/workflows/android.yml runs on every pull request and push to main, plus a dedicated signed-release job:

flowchart LR
    A[PR / push to main] --> Q["quality job:<br/>flutter pub get + flutter analyze"]
    T["Tag mobile-v* or<br/>manual dispatch"] --> Q
    Q --> R{Release job triggered?}
    R -->|yes| V[Validate secrets +<br/>BE_API_URL is HTTPS]
    V --> M[Materialize keystore +<br/>google-services.json from secrets]
    M --> B[flutter build apk/appbundle --release]
    B --> S[Verify APK/AAB signatures<br/>match the expected keystore]
    S --> U[Upload artifacts]
    U --> G{Tag push?}
    G -->|yes| REL[Publish GitHub Release<br/>with APK + AAB + SHA256SUMS]
    G -->|no| END[Artifacts only]

    style Q fill:#58CC02,color:#fff
    style S fill:#1CB0F6,color:#fff
    style REL fill:#FFC800,color:#000
Loading

The release job requires five repository secrets β€” ANDROID_KEYSTORE_BASE64, ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS, ANDROID_KEY_PASSWORD, GOOGLE_SERVICES_JSON_BASE64 β€” and an optional BE_API_URL repository variable/secret (defaults to the production API). It also asserts the decoded google-services.json belongs to the correct Firebase project (happify-990c2) and Android package (com.happify.app.mobile_happify) before building.


πŸŽ“ Project Context

Built for

Garuda Hacks 7.0 β€” International Hackathon Competition

AI-Powered Mental Wellness Platform

Happify-Mobile is the on-the-go client of Happify, a privacy-aware digital wellbeing ecosystem built around early detection, meaningful support, and lifelong emotional growth:

Layer Component Role
🌐 Web Happify-FE Mood tracking, journaling, anonymous community, care workflows
☁️ Backend Happify-BE API, PostgreSQL, Firebase, WebSocket hub, safety & moderation
🧠 AI Happify-AI Journal reflection, risk detection, voice processing
πŸ“± Mobile Happify-Mobile (this repo) Flutter app for on-the-go mood tracking and care access
πŸ”Œ IoT Happify-IOT Voice-companion device paired from this app

πŸ‘₯ Team

Outstanding BINUSIAN Team β€” Garuda Hacks 7.0

Name Role
Andrian Pratama Full-stack Developer
Khalisa Amanda Sifa Ghaizani IoT Engineer
Michella Arlene Wijaya Radika Product Developer
Stanley Nathanael Wijaya Product Developer

πŸ“„ License

This project is licensed under the MIT License β€” free to use, modify, and distribute.

MIT License

Copyright (c) 2026 Happify β€” Garuda Hacks 7.0

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.

"Detect early. Support meaningfully. Grow for life."


Garuda Hacks


Made with 🌱 for Garuda Hacks 7.0

Releases

Packages

Contributors

Languages