# hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc architecture

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

- Interactive diagram: https://gitdiagram.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc
- Repository: https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc

## Overview

##### Project Overview
- Purpose: This is a cross-platform Flutter movie app built using Clean Architecture with an MVVM pattern. It demonstrates several state management approaches (setState, Provider, Riverpod, BLoC) and interacts with a REST API for fetching movie data, along with local state management for things like favorites and theme preferences.

##### File Structure
- Presentation Layer:
- Located in “lib/screens” and “lib/widgets”.
- Screens such as movies_screen.dart, movie_details.dart, favorites_screen.dart, and splash_screen.dart represent the visible UI.
- Widgets (e.g., favorite_btn, movies_widget, genre list) provide reusable UI components.
- Domain & Model Layer:
- “lib/models” contains core domain entities like movies_model.dart and movies_genre.dart.
- Data & Service Layer:
- “lib/repository” (movies_repo.dart) acts as an abstraction for data operations.
- “lib/service” includes api_service.dart (REST API communication), init_getit.dart (dependency injection), and navigation_service.dart.
- State Management:
- MVVM is implemented with variations for different state management techniques. The folder organization along with the README pointers shows that state handling is decoupled into view models (implicitly managed within screens and possibly via providers, Riverpod or BLoC classes).

- User Interface Layer
- ViewModel Layer (or Controller layer in MVVM)
- Domain Layer
- Data Layer
- Dependency Injection & Navigation
- External Systems:

- Relationships & Data Flow:

##### Highlighting Architectural Patterns and Design Principles
- MVVM Pattern: Clearly separate the UI (View) from the business logic (ViewModel) and the Domain/Data layer.
- Clean Architecture: Illustrate dependency direction (i.e., inner layers, such as Models and Repository, do not depend on outer layers like UI).
- State Management Variants: Optionally annotate notes that explain how different state management techniques (setState, Provider, Riverpod, BLoC) are interchangeable in this MVVM structure.
- Cross-Platform Considerations: Although not the main focus, denote that the core Flutter app is platform-agnostic while separate directories (android, ios, etc.) handle platform-specific build concerns.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Configuration Layer
    subgraph "Configuration Layer"
        DI_Node["Dependency Injection"]:::di
        NS["Navigation Service"]:::di
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "Screens"
            MS["Movies Screen"]:::ui
            MD["Movie Details Screen"]:::ui
            FS["Favorites Screen"]:::ui
            SS["Splash Screen"]:::ui
        end
        subgraph "Widgets"
            MW["Movies Widget"]:::ui
            FB["Favorite Button Widget"]:::ui
            GLW["Genres List Widget"]:::ui
            MEW["Error Display Widget"]:::ui
            CI["Cached Image Widget"]:::ui
        end
    end

    %% State Management Layer (MVVM)
    subgraph "State Management Layer (MVVM)"
        VM["ViewModel/State Manager"]:::logic
    end

    %% Domain Layer
    subgraph "Domain Layer"
        MM["Movies Model"]:::domain
        MG["Movies Genre Model"]:::domain
        AC["UI/App Constants"]:::domain
    end

    %% Data & Service Layer
    subgraph "Data & Service Layer"
        MR["Movies Repository"]:::service
        AS["API Service"]:::service
    end

    %% External Systems
    subgraph "External Systems"
        REST["REST API Server"]:::external
    end

    %% Relationships
    DI_Node -->|"injects"| VM
    DI_Node -->|"injects"| MR
    DI_Node -->|"injects"| AS
    DI_Node -->|"injects"| NS

    MS -->|"userAction"| VM
    FB -->|"userAction"| VM
    MW -->|"display"| VM

    VM -->|"dataFetch"| MR
    MR -->|"apiCall"| AS
    AS -->|"apiRequest"| REST

    REST -->|"apiResponse"| AS
    AS -->|"dataResponse"| MR
    MR -->|"stateUpdate"| VM

    VM -->|"mapsData"| MM
    MR -->|"uses"| MM

    %% Styles
    classDef ui fill:#CCEEFF,stroke:#333,stroke-width:2px;
    classDef logic fill:#D5E8D4,stroke:#82B366,stroke-width:2px;
    classDef domain fill:#FFF2CC,stroke:#D6B656,stroke-width:2px;
    classDef service fill:#F8CECC,stroke:#B85450,stroke-width:2px;
    classDef di fill:#E1D5E7,stroke:#9673A6,stroke-width:2px;
    classDef external fill:#F5F5F5,stroke:#999,stroke-width:2px;

    %% Click Events
    click MS "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/screens/movies_screen.dart"
    click MD "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/screens/movie_details.dart"
    click FS "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/screens/favorites_screen.dart"
    click SS "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/screens/splash_screen.dart"
    click MW "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/widgets/movies/movies_widget.dart"
    click FB "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/widgets/movies/favorite_btn.dart"
    click GLW "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/widgets/movies/genres_list_widget.dart"
    click MEW "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/widgets/my_error_widget.dart"
    click CI "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/widgets/cached_image.dart"
    click MM "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/models/movies_model.dart"
    click MG "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/models/movies_genre.dart"
    click AC "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/tree/setstate_mvvm_final_code/lib/constants"
    click MR "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/repository/movies_repo.dart"
    click AS "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/service/api_service.dart"
    click DI_Node "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/service/init_getit.dart"
    click NS "https://github.com/hadikachmar3/advanced_flutter_mvvm_with_provider_riverpod_bloc/blob/setstate_mvvm_final_code/lib/service/navigation_service.dart"
```
