How dexterhere04/stress_analyser_app works
1. Overall shape
- This is a Flutter cross-platform app with a shared Dart codebase in lib/ and generated/native platform runners in android/, ios/, macos/, linux/, windows/, and web/.
- The repository is not just a standard UI app: it includes Android-native integrations for keyboard input and notification access, which are central to the product.
2. Primary domain
- The app appears to be a stress/typing/notification analysis tool (“destresser”).
- It collects three main signal types:
- Typing metrics
- Notification sentiment
- Derived stress readings / trends
- These signals are then presented in dashboards, history views, and detail screens.
3. Dart application layering
- The Dart code is organized into a fairly clean presentation / data / core split.
- lib/core contains shared constants, theme, and small utilities.
- lib/data contains persistence models, database access, repositories, and service classes.
- lib/presentation contains viewmodels and UI screens/widgets.
- lib/providers.dart is likely the composition root where dependencies and state objects are wired together.
4. Presentation layer
- UI is composed of:
- home_screen.dart as the app entry surface
- screens for dashboard, history, notifications, and typing
- reusable widgets such as a stress gauge, trend chart, stat cards, and notification list items
- Viewmodels (dashboard_viewmodel.dart, notification_viewmodel.dart, typing_viewmodel.dart) likely expose app state to the screens and coordinate refresh/update logic.
- This layer is where raw data becomes user-facing summaries and charts.
5. Data and persistence layer
- lib/data/database/ includes app_database.dart, generated app_database.g.dart, and tables.dart, indicating a structured local database, likely SQLite-based.
- Models such as typing_metrics.dart, notification_sentiment.dart, and stress_reading.dart represent the persisted/aggregated domain entities.
- Repositories (typing_repository.dart, notification_repository.dart, stress_repository.dart) encapsulate read/write access and keep persistence details out of the UI.
6. Service layer
- Services such as typing_service.dart, notification_listener_service.dart, sentiment_service.dart, and keyboard_setup_service.dart sit above repositories and below viewmodels.
- These services are the main orchestration boundary between:
- platform events or user behavior,
- analysis/processing,
- and local persistence.
- sentiment_service.dart likely transforms notification text into a sentiment/stress signal before it is stored or displayed.
7. Android-native subsystem
- The android/app/src/main/kotlin/com/example/destresser/ tree contains the most important platform-specific logic:
- FlorisImeService.kt
- KeystrokeLogger.kt
- NotificationListener.kt
- keyboard support classes under ime/keyboard/
- This indicates the app includes a custom Android input method editor (IME) or keyboard component and a notification listener service.
- These Android services are key data sources feeding the Flutter side.
8. Cross-boundary data flow
- The likely flow is:
- Android keyboard and notification events are captured in native services
- those events are passed into Flutter-facing services or persisted locally
- repositories store normalized records in the local database
- viewmodels aggregate data into dashboard/history-friendly summaries
- screens render the resulting metrics and trends
- This is an offline/local-first architecture; there is no visible backend or remote API in the repo.
9. Android app structure and role
- Android manifests and XML resources define the IME/service permissions and configuration.
- MainActivity.kt is likely a minimal Flutter host, while the real Android behavior lives in the IME and listener classes.
- floris_ime.xml suggests keyboard configuration, reinforcing that Android is not just a wrapper but a functional subsystem.
10. iOS, desktop, and web boundaries
- iOS/macOS/Linux/Windows/web directories appear to be standard Flutter platform runners with mostly generated scaffolding.
- No equivalent native data-collection subsystem is visible for those platforms, so the app’s core differentiator is probably Android-specific.
- On non-Android targets, the app likely functions as the Flutter UI shell with limited or no native input/notification capture.
11. Theming and shared utilities
- lib/core/theme/app_theme.dart centralizes app styling, while lib/core/constants/app_constants.dart and lib/core/utils/date_utils.dart provide shared helpers.
- These support consistent UI presentation and common formatting across dashboard/history screens.
12. Architecture boundary summary for a diagram
- A useful diagram would show three major areas:
- Android native capture layer: keyboard + notification listener + IME
- Flutter application layer: services, repositories, database, viewmodels, screens
- Local persistence layer: database tables and generated access code
- The app’s central loop is: capture behavior and notifications → analyze/normalize locally → persist → visualize in Flutter UI.
Main entry points: providers.dart Providers · typing_repository.dart Typing repo · notification_repository.dart Notification repo · main.dart App entry
Components 31
Android native capture
Android-specific keyboard and notification capture services.
- Main activity · Minimal Android entry point that hosts the Flutter app.
android/app/src/main/kotlin/com/example/destresser/MainActivity.kt - Notification listener · Captures notification events from the Android system.
android/app/src/main/kotlin/com/example/destresser/NotificationListener.kt - IME service · Custom keyboard/input method service for keystroke capture.
android/app/src/main/kotlin/com/example/destresser/ime/FlorisImeService.kt - Keystroke logger · Records typing activity from the IME layer.
android/app/src/main/kotlin/com/example/destresser/ime/KeystrokeLogger.kt - Keyboard manager · Coordinates keyboard/editor state inside the custom IME.
android/app/src/main/kotlin/com/example/destresser/ime/keyboard/KeyboardManager.kt - Editor instance · Tracks active editor context for keyboard interactions.
android/app/src/main/kotlin/com/example/destresser/ime/keyboard/EditorInstance.kt
Flutter app
Shared Dart application layer for orchestration and UI.
- App entry · Initializes the Flutter app and shared dependencies.
lib/main.dart - Providers · Wires repositories, services, and viewmodels together.
lib/providers.dart - Typing service · Turns typing events into structured typing metrics.
lib/data/services/typing_service.dart - Notif service · Receives notification events and prepares them for analysis.
lib/data/services/notification_listener_service.dart - Sentiment service · Derives sentiment and stress signals from notification content.
lib/data/services/sentiment_service.dart - Keyboard setup · Configures Android keyboard integration from the Flutter side.
lib/data/services/keyboard_setup_service.dart - Dashboard VM · Aggregates stress, trend, and summary state for the dashboard.
lib/presentation/viewmodels/dashboard_viewmodel.dart - Typing VM · Exposes typing history and metrics to the UI.
lib/presentation/viewmodels/typing_viewmodel.dart - Notification VM · Exposes notification analysis and history to the UI.
lib/presentation/viewmodels/notification_viewmodel.dart - Home screen · Top-level application surface and navigation shell.
lib/presentation/views/home_screen.dart - Dashboard · Shows stress gauge, trends, and summary cards.
lib/presentation/views/screens/dashboard_screen.dart - History · Displays historical readings and trend exploration.
lib/presentation/views/screens/history_screen.dart - Notifications · Shows analyzed notification items and insights.
lib/presentation/views/screens/notifications_screen.dart - Typing · Shows typing metrics and related summaries.
lib/presentation/views/screens/typing_screen.dart
Local data
Database, repositories, and domain models for offline storage.
- App database · Structured local database used for offline persistence.
lib/data/database/app_database.dart - Tables · Database table definitions for persisted domain records.
lib/data/database/tables.dart - Typing repo · Persists and queries typing metrics.
lib/data/repositories/typing_repository.dart - Notification repo · Persists and queries notification sentiment records.
lib/data/repositories/notification_repository.dart - Stress repo · Persists and queries derived stress readings.
lib/data/repositories/stress_repository.dart - Typing metrics · Stored typing measurements and derived statistics.
lib/data/models/typing_metrics.dart - Notif sentiment · Persisted notification sentiment and analysis output.
lib/data/models/notification_sentiment.dart - Stress reading · Derived stress score or trend record.
lib/data/models/stress_reading.dart
Platform runners
Generated Flutter host shells for non-Android platforms.
- Android runner · Android Gradle app wrapper around the Flutter entry point.
android/app/src/main/AndroidManifest.xml - iOS runner · Standard iOS Flutter host application.
ios/Runner/AppDelegate.swift - Desktop runners · Generated Linux, macOS, and Windows Flutter host shells.
linux/runner/main.cc
Connections 37
- Main activity → App entry: launches · Android hosts the Flutter application.
- Notification listener → Notif service: feeds · Native notification events are handed to the Flutter service layer.
- IME service → Keystroke logger: logs · The IME captures typing events through the keystroke logger.
- IME service → Keyboard manager: coordinates · Keyboard state is managed inside the IME.
- Keyboard manager → Editor instance: tracks · The manager maintains active editor context.
- App entry → Providers: initializes · App startup wires dependencies through providers.
- Providers → Typing service: provides · Dependency wiring makes typing processing available.
- Providers → Notif service: provides · Dependency wiring makes notification processing available.
- Providers → Sentiment service: provides · Dependency wiring makes sentiment analysis available.
- Providers → Keyboard setup: provides · Dependency wiring makes keyboard setup available.
- Typing service → Typing repo: stores · Typing service persists metrics through the repository.
- Notif service → Sentiment service: analyzes · Notification content is converted into sentiment signals.
- Sentiment service → Notification repo: stores · Analysis output is persisted through the repository.
- Keyboard setup → IME service: configures · Flutter-side setup supports the Android IME.
- Typing repo → App database: uses · Repository reads and writes via the local database.
- Notification repo → App database: uses · Repository reads and writes via the local database.
- Stress repo → App database: uses · Repository reads and writes derived readings in the local database.
- App database → Tables: defines · Database schema is defined by table declarations.
- Typing repo → Typing metrics: maps · Repository handles typing metric records.
- Notification repo → Notif sentiment: maps · Repository handles notification sentiment records.
- Stress repo → Stress reading: maps · Repository handles stress reading records.
- Dashboard VM → Stress repo: reads · Dashboard aggregates stress data for summaries.
- Dashboard VM → Typing repo: reads · Dashboard may include typing-related summary data.
- Dashboard VM → Notification repo: reads · Dashboard may include notification-related summary data.
- Typing VM → Typing repo: reads · Typing viewmodel exposes stored typing metrics.
- Notification VM → Notification repo: reads · Notification viewmodel exposes stored sentiment data.
- Home screen → Dashboard: navigates · Home screen surfaces the dashboard view.
- Home screen → History: navigates · Home screen surfaces history exploration.
- Home screen → Notifications: navigates · Home screen surfaces notification analysis.
- Home screen → Typing: navigates · Home screen surfaces typing metrics.
- Dashboard → Dashboard VM: binds · Dashboard UI binds to dashboard state.
- History → Stress repo: shows · History view presents persisted stress trends.
- Notifications → Notification VM: binds · Notification UI binds to notification state.
- Typing → Typing VM: binds · Typing UI binds to typing state.
- Android runner → App entry: hosts · Android app shell hosts the Flutter code.
- iOS runner → App entry: hosts · iOS shell hosts the shared Flutter code.
- Desktop runners → App entry: hosts · Desktop shells host the shared Flutter code.