How rahulop11/appumangly works
1. Purpose and Runtime
Umangly is a cross-platform Flutter/Dart mental-wellness client combining mood/diary tracking, mindfulness content, AI companions, and camera-based emotion/smile features. The primary application entry point is lib/main.dart; it builds for Android, iOS, web, Linux, macOS, and Windows.
2. Client Navigation and Feature Surfaces
Flutter screens form the feature-oriented presentation layer, including dynamic/home flows, authentication, mood selection, diary, meditation, smile camera, and companion chat. Key user-facing orchestration paths include:
• lib/screens/dynamic_home_screen.dart
• lib/screens/emotion_check_screen.dart
• lib/screens/virtual_friend_chat_screen.dart
Authentication-specific screens are under lib/screens/auth/login_screen.dart and lib/screens/auth/signup_screen.dart.
3. Firebase Identity and User Data Boundary
Firebase is the cloud system of record for authenticated user data, with generated app initialization options and Firestore access controls. App services should isolate Firebase reads/writes from screen code; the rules file defines the authorization boundary.
• lib/firebase_options.dart
• lib/services/diary_service.dart
• firestore.rules
The committed Android configuration indicates Firebase services are provisioned for Android: android/app/google-services.json.
4. Mood, Diary, and Analytics Pipeline
Users select or derive emotional state, persist diary/mood-related records, then consume aggregation and insight views. Typed domain models separate diary, mood, meditation, smile, and companion concepts from UI/service implementations.
• lib/models/mood_models.dart
• lib/models/diary_models.dart
• lib/services/mood_analytics_service.dart
Primary presentation endpoints are lib/screens/mood_selection_screen.dart, lib/screens/diary_screen.dart, and lib/screens/diary_analytics_screen.dart.
5. AI Companion Integration
The virtual-friend layer supports distinct AI providers/personas: Gemini for Meera and Dialogflow-oriented flows for Arav, with an offline fallback path. Screen code should call the service abstraction rather than provider APIs directly.
• lib/services/virtual_friend_service.dart
• lib/services/gemini_ai_service.dart
• lib/services/dialogflow_service.dart
Offline continuity is represented by lib/services/offline_virtual_friend_service.dart; companion data contracts live in lib/models/virtual_friend_models.dart.
6. Emotion and Smile Detection Boundary
Emotion recognition is separated from the Flutter UI through detection services and camera/webview screens. The repository also contains independently runnable Python/OpenCV-oriented implementations, making this a client-to-local/HTTP detector integration boundary rather than a purely Dart model.
• lib/services/emotion_detection_service.dart
• lib/services/offline_emotion_detection_service.dart
• web_emotion_detection/emotion_api.py
Relevant UI routes are lib/screens/smile_camera_screen.dart and lib/screens/emotion_webview_screen.dart. Model assets include assets/models/mock_emotion_model.tflite.
7. Mindfulness Media and Rewards
Meditation, breathing, affirmations, ambient audio, TTS, and smile rewards are local client workflows backed by service abstractions and typed meditation/smile models. Audio/content providers are external-service boundaries where configured.
• lib/services/audio_service.dart
• lib/services/freesound_api_service.dart
• lib/services/smile_rewards_service.dart
Core feature routes include lib/screens/meditation_screen.dart, lib/screens/breathing_exercise_screen.dart, and lib/screens/affirmation_screen.dart.
8. Platform Integration
Flutter owns most behavior, while Android adds WebView navigation and permission handling for embedded emotion-detection experiences:
• android/app/src/main/kotlin/com/example/umangly/MainActivity.kt
• android/app/src/main/kotlin/com/example/umangly/CustomWebViewClient.kt
• android/app/src/main/kotlin/com/example/umangly/WebViewPermissionHandler.kt
Native runners in ios/, web/, linux/, macos/, and windows/ are platform shells rather than separate application architectures.
Main entry points: dynamic_home_screen.dart Feature screens · virtual_friend_service.dart Virtual friend service · smile_camera_screen.dart Camera and webview UI · mood_selection_screen.dart Mood and diary views
Components 21
Flutter client
- App bootstrap · Builds the cross-platform client.
lib/main.dart - Feature screens · Home, auth, mood, diary, and mindfulness routes.
lib/screens/dynamic_home_screen.dart - Companion chat
lib/screens/virtual_friend_chat_screen.dart - Mood and diary views · Selection, entry, and analytics views.
lib/screens/mood_selection_screen.dart - Mood and diary models
lib/models/mood_models.dart - Mood analytics · Aggregates persisted mood and diary records.
lib/services/mood_analytics_service.dart
Firebase boundary
- Diary data service · Isolates diary reads and writes from screens.
lib/services/diary_service.dart - Firebase · System of record for authenticated user data.
lib/firebase_options.dart - Firestore rules · Defines Firestore access controls.
firestore.rules
AI companions
- Virtual friend service · Routes persona requests without exposing providers to UI.
lib/services/virtual_friend_service.dart - Gemini / Meera
lib/services/gemini_ai_service.dart - Dialogflow / Arav
lib/services/dialogflow_service.dart - Offline companion
lib/services/offline_virtual_friend_service.dart
Emotion detection
- Camera and webview UI
lib/screens/smile_camera_screen.dart - Emotion detection service · Bridges Flutter UI to detector implementations.
lib/services/emotion_detection_service.dart - Python emotion API · Independently runnable OpenCV-oriented detector.
web_emotion_detection/emotion_api.py - Android WebView integration · Handles embedded navigation and permissions.
android/app/src/main/kotlin/com/example/umangly/MainActivity.kt
Mindfulness media
- Meditation and breathing UI · Meditation, breathing, and affirmation workflows.
lib/screens/meditation_screen.dart - Audio service
lib/services/audio_service.dart - Freesound API
lib/services/freesound_api_service.dart - Smile rewards
lib/services/smile_rewards_service.dart
Connections 21
- App bootstrap → Feature screens: starts
- Feature screens → Mood and diary views: navigates to
- Feature screens → Companion chat: navigates to
- Feature screens → Camera and webview UI: navigates to
- Feature screens → Meditation and breathing UI: navigates to
- Mood and diary views → Diary data service: persists records
- Mood and diary views → Mood analytics: requests insights
- Diary data service → Mood and diary models: maps records
- Mood analytics → Mood and diary models: aggregates
- Diary data service → Firebase: reads and writes
- Firestore rules → Firebase: authorizes access
- Companion chat → Virtual friend service: sends chat
- Virtual friend service → Gemini / Meera: Meera requests
- Virtual friend service → Dialogflow / Arav: Arav requests
- Virtual friend service → Offline companion: fallback
- Camera and webview UI → Emotion detection service: submits capture
- Camera and webview UI → Android WebView integration: uses embedded detector
- Emotion detection service → Python emotion API: detects emotion
- Meditation and breathing UI → Audio service: plays media
- Audio service → Freesound API: fetches content
- Camera and webview UI → Smile rewards: awards smiles