# jamescardona11/wellness_score_app architecture

> Architecture diagram of the GitHub repository jamescardona11/wellness_score_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jamescardona11/wellness_score_app
- Repository: https://github.com/jamescardona11/wellness_score_app

## Overview

##### Project Type and Purpose
- Type: A mobile front-end application built with Flutter, following Clean Architecture (MVVM style)
- Purpose: Collect user input (income & expenses), compute a financial health score via a domain use-case, log analytics, and render results in two screens (calculator & result).

##### File Structure
- Top-level `lib/` splits into:
– config/    → assets, constants, DI (GetIt), navigation (GoRouter)
– data/      → concrete repository implementations (e.g., MockAnalyticsRepository)
– domain/    → repository interfaces, types (HealthStatus), business logic (HealthScoreUseCase)
– ui/        → presentation layer
- core/        → theme system, shared widgets
- widgets/     → reusable UI controls
- features/    → feature modules (calculator & result) with Cubit state management and screens
- Entry Point: `main.dart` (app initialization, DI registration, GoRouter setup)
- Tests: mirror each layer for coverage.

##### README for Architectural Insights
- Layers: Presentation (UI + Cubit), Domain (UseCase), Data (Repository), External Service (Analytics)
- Cross-cutting: Dependency Injection via GetIt; Navigation via GoRouter; Theming with custom token system
- Business Flow: Input → UseCase → Analytics logging → UI update

a. Main Components:
1) Presentation Layer
– UI Screens: WellnessCalculatorScreen, WellnessResultScreen
– State Management: WellnessCalculatorCubit
– Shared Widgets & Theme
2) Configuration
– DI Container (`di.dart`)
– App Router (`app_router.dart`)
– Assets & Constants
3) Domain Layer
– HealthScoreUseCase
– HealthStatus enum
– AnalyticsRepository interface
4) Data Layer
– MockAnalyticsRepository (implements AnalyticsRepository)
5) External Services
– Analytics backend (e.g., Firebase Analytics or custom service)
b. Relationships and Data Flow:
1) `main.dart` initializes GetIt and GoRouter → injects dependencies into UI
2) User interacts with Calculator UI → triggers methods on WellnessCalculatorCubit
3) Cubit invokes HealthScoreUseCase (domain) with user inputs
4) UseCase computes score, calls AnalyticsRepository.trackEvent(...)
5) MockAnalyticsRepository forwards to external analytics service
6) UseCase returns HealthStatus → Cubit emits new UI state → navigates to WellnessResultScreen
c. Architectural Patterns and Principles:
- Clean Architecture: clear separation of concerns & dependencies point inward (UI → Domain → Data → External)
- MVVM: UI (View) binds to Cubit (ViewModel)
- Dependency Injection: decouples implementations from interfaces
- Single Responsibility: each layer has focused responsibilities
d. Key Technologies & Libraries:
- Flutter/Dart
- get_it for DI
- go_router for navigation
- flutter_cubit (Bloc package) for state management
- Custom theming tokens
- Mockito & flutter_test for testing

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration Layer
    subgraph "Configuration"
        DI["DI Container"]:::config
        Router["App Router"]:::config
        Assets["App Assets"]:::config
        Icons["App Icons"]:::config
        AnalyticsConst["Analytics Constants"]:::config
        TextConst["Text Constants"]:::config
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "UI Features"
            CalcScreen["WellnessCalculatorScreen"]:::presentation
            ResultScreen["WellnessResultScreen"]:::presentation
            Cubit["WellnessCalculatorCubit"]:::presentation
        end
        subgraph "UI Core"
            Bounce["BounceWrapper"]:::presentation
            Snackbar["SnackbarError"]:::presentation
            ThemeSystem["App Theme System"]:::presentation
            ThemeConfig["Theme Configuration"]:::presentation
        end
    end

    %% Domain Layer
    subgraph "Domain Layer"
        UseCase["HealthScoreUseCase"]:::domain
        Status["HealthStatus"]:::domain
        RepoInterface["AnalyticsRepository"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        MockRepo["MockAnalyticsRepository"]:::data
    end

    %% External Service
    subgraph "External Service"
        AnalyticsSvc["Analytics Service"]:::external
    end

    %% Connections
    DI -->|provides| Cubit
    DI -->|provides| UseCase
    DI -->|provides| MockRepo
    DI -->|initializes| Router

    Assets -->|feeds| DI
    Icons -->|feeds| DI
    AnalyticsConst -->|feeds| DI
    TextConst -->|feeds| DI

    Router -->|routes to| CalcScreen
    Router -->|routes to| ResultScreen

    CalcScreen -->|uses| Cubit
    CalcScreen -->|styled by| ThemeSystem
    CalcScreen -->|uses widget| Bounce
    CalcScreen -->|uses widget| Snackbar

    Cubit -->|executes| UseCase
    UseCase -->|calls| RepoInterface
    RepoInterface -->|implemented by| MockRepo
    MockRepo -->|sends data to| AnalyticsSvc

    UseCase -->|returns| Status
    Status -->|emits to| Cubit
    Cubit -->|navigates to| ResultScreen

    ResultScreen -->|styled by| ThemeSystem
    ResultScreen -->|uses widget| Bounce

    ThemeConfig -->|configures| ThemeSystem

    %% Click Events
    click DI "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/config/di/di.dart"
    click Router "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/config/navigator/app_router.dart"
    click Assets "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/config/assets/app_assets.dart"
    click Icons "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/config/assets/app_icons.dart"
    click AnalyticsConst "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/config/constants/analytics_constants.dart"
    click TextConst "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/config/constants/en_text_constants.dart"
    click CalcScreen "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/ui/features/wellness_calculator/wellness_calculator_screen.dart"
    click ResultScreen "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/ui/features/wellness_result/wellness_result_screen.dart"
    click Cubit "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/ui/features/wellness_calculator/cubit/wellness_calculator_cubit.dart"
    click Bounce "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/ui/core/shared_widgets/bounce_wrapper.dart"
    click Snackbar "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/ui/core/shared_widgets/snackbar_error.dart"
    click ThemeSystem "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/ui/core/theme/app_theme.dart"
    click ThemeConfig "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/ui/core/theme/theme.dart"
    click UseCase "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/domain/use_cases/health_score_use_case.dart"
    click Status "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/domain/types/health_status.dart"
    click RepoInterface "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/domain/repositories/analytics_repository.dart"
    click MockRepo "https://github.com/jamescardona11/wellness_score_app/blob/main/lib/data/repositories/mock_analytics_repository.dart"

    %% Styles
    classDef config fill:#D8BFD8,stroke:#000
    classDef presentation fill:#C6EFCE,stroke:#000
    classDef domain fill:#D0E0E3,stroke:#000
    classDef data fill:#FFD8B5,stroke:#000
    classDef external fill:#EDEDED,stroke:#000
```
