# kzjn10/flutter_bloc_movie architecture

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

- Interactive diagram: https://gitdiagram.com/kzjn10/flutter_bloc_movie
- Repository: https://github.com/kzjn10/flutter_bloc_movie

## Overview

##### Main Components

a. Client Layer (UI Components):
- Main UI screens (HomePage, DetailPage)
- Widget hierarchy (Slideshow, MovieList, MovieGallery, Category)

b. BLoC Layer (Business Logic):
- Three main BLoCs:
- MoviesListBloc
- MoviesDetailBloc
- MoviesImageBloc
- BaseBloc as a parent/abstract class

c. Data Layer:
- Repository
- MovieApiProvider (API Service)
- Model classes hierarchy (starting with BaseModel)

d. External Services:
- TMDB API (The Movie Database API)

**┌─────────────────────────────────────┐**
- Presentation Layer (UI)             │
- ┘
- ↕
**┌─────────────────────────────────────┐**
- Business Logic Layer (BLoCs)        │
- ┘
- ↕
**┌─────────────────────────────────────┐**
- Data Layer                          │
- ┘
- ↕
**┌─────────────────────────────────────┐**
- External Services                   │
- ┘

##### Specific Implementation Details

- UI → BLoC: Events/Actions
- BLoC → UI: States/Updates
- BLoC → Repository: Data requests
- Repository → API Provider: External calls

b. Related components:
- Models package (ItemModel, MovieDetailModel, etc.)
- UI widgets package
- Resources package

##### Additional Elements

- Notes about the BLoC pattern implementation
- I18n integration (generated/i18n.dart)
- Platform-specific components (iOS/Android)

##### Key Relationships to Highlight

- How UI components subscribe to BLoC streams
- How BLoCs interact with the Repository
- How the Repository manages API calls
- Model transformation flow

##### Technical Stack Indicators

- Flutter/Dart
- BLoC Pattern
- REST API integration
- Platform-specific code (Swift/Kotlin)

Remember to include:
- Clear component boundaries
- Data flow directions
- State management pattern
- External dependencies
- Cross-platform aspects

This will give other developers a clear understanding of how the movie app is structured and how the different components interact with each other using the BLoC pattern.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "UI Layer"
        HomePage["HomePage"]:::ui
        DetailPage["DetailPage"]:::ui
        
        subgraph "Reusable Widgets"
            Slideshow["Slideshow"]:::ui
            MovieList["MovieList"]:::ui
            MovieGallery["MovieGallery"]:::ui
            Category["Category"]:::ui
        end
        
        HomePage --> Slideshow
        HomePage --> MovieList
        HomePage --> MovieGallery
        HomePage --> Category
    end

    subgraph "BLoC Layer"
        BaseBloc["BaseBloc"]:::bloc
        MoviesListBloc["MoviesListBloc"]:::bloc
        MoviesDetailBloc["MoviesDetailBloc"]:::bloc
        MoviesImageBloc["MoviesImageBloc"]:::bloc
        
        BaseBloc --> MoviesListBloc
        BaseBloc --> MoviesDetailBloc
        BaseBloc --> MoviesImageBloc
    end

    subgraph "Data Layer"
        Repository["Repository"]:::data
        MovieApiProvider["MovieApiProvider"]:::data
        
        subgraph "Models"
            BaseModel["BaseModel"]:::model
            ItemModel["ItemModel"]:::model
            MovieDetailModel["MovieDetailModel"]:::model
            MovieImageModel["MovieImageModel"]:::model
            
            BaseModel --> ItemModel
            BaseModel --> MovieDetailModel
            BaseModel --> MovieImageModel
        end
        
        Repository --> MovieApiProvider
        Repository --> Models
    end

    subgraph "Platform Specific"
        iOSEntry["iOS Entry (Swift)"]:::platform
        AndroidEntry["Android Entry (Kotlin)"]:::platform
    end

    subgraph "External Services"
        TMDBAPI["TMDB API"]:::external
    end

    subgraph "Support Components"
        i18n["i18n Integration"]:::support
        Constants["Global Constants"]:::support
        CustomIcons["Custom Icons"]:::support
        ScrollBehavior["Scroll Behavior"]:::support
    end

    HomePage --> MoviesListBloc
    DetailPage --> MoviesDetailBloc
    DetailPage --> MoviesImageBloc
    MoviesListBloc --> Repository
    MoviesDetailBloc --> Repository
    MoviesImageBloc --> Repository
    MovieApiProvider --> TMDBAPI

    %% Click Events
    click HomePage "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/ui/homepage/home_page.dart"
    click DetailPage "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/ui/detail/detail_page.dart"
    click Slideshow "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/ui/widget/slideshow/slideshow.dart"
    click MovieList "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/ui/widget/movie_list/movie_list.dart"
    click MovieGallery "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/ui/widget/movie_gallery/movie_gallery.dart"
    click Category "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/ui/widget/category/category.dart"
    click BaseBloc "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/blocs/base.dart"
    click MoviesListBloc "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/blocs/movies_list_bloc.dart"
    click MoviesDetailBloc "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/blocs/movies_detail_bloc.dart"
    click MoviesImageBloc "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/blocs/movies_image_bloc.dart"
    click Repository "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/resources/repository.dart"
    click MovieApiProvider "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/resources/movie_api_provider.dart"
    click BaseModel "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/model/base_model.dart"
    click ItemModel "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/model/item_model.dart"
    click MovieDetailModel "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/model/movie_detail_model.dart"
    click MovieImageModel "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/model/movie_image_model.dart"
    click iOSEntry "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/ios/Runner/AppDelegate.swift"
    click AndroidEntry "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/android/app/src/main/kotlin/dev/anhndt/demo_bloc/MainActivity.kt"
    click i18n "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/generated/i18n.dart"
    click Constants "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/constant/global.dart"
    click CustomIcons "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/constant/custom_icon.dart"
    click ScrollBehavior "https://github.com/kzjn10/Flutter_Bloc_Movie/blob/master/lib/src/utils/my_scroll_behavior.dart"

    %% Styling
    classDef ui fill:#2196F3,stroke:#1976D2,color:white
    classDef bloc fill:#4CAF50,stroke:#388E3C,color:white
    classDef data fill:#FFC107,stroke:#FFA000,color:black
    classDef model fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef platform fill:#607D8B,stroke:#455A64,color:white
    classDef external fill:#795548,stroke:#5D4037,color:white
    classDef support fill:#FF5722,stroke:#E64A19,color:white
```
