# tcvathana/movie_app architecture

> Architecture diagram of the GitHub repository tcvathana/movie_app, 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/tcvathana/movie_app
- Repository: https://github.com/tcvathana/movie_app

## Overview

##### Main Architectural Layers
- Presentation Layer (UI and State Management):
- Located in the “lib/presentation” folder.
- Contains UI components such as pages (e.g., account_page.dart, home_page.dart, movie_detail_page.dart) and widgets.
- Uses the BLoC pattern as seen in “lib/presentation/bloc” with various blocs for account, authentication, movie details, movie lists, and search.
- Domain Layer (Business Rules):
- Found in “lib/domain”.
- Contains repository interfaces (e.g., i_account_repository.dart, i_auth_repository.dart) which abstract business logic.
- Data Layer (Data Sources and Models):
- Contained in “lib/data” with folders for data_sources (both local and remote), models, and repositories (tangible implementations of the domain interfaces).
- Core and Utility Components:
- “lib/core”, which includes networking utilities (network_info.dart) and configuration.
- The dependency injection setup is provided by “lib/injection_container.dart”.
- Platform-specific Directories:
- “android” and “ios” folders orchestrate platform-specific configurations and integrations, essential for a cross-platform Flutter app.

##### Relationships and Interactions
- The Presentation Layer interacts with the Domain layer through BLoC components:
- UI components (pages and widgets) dispatch events to their respective blocs.
- Blocs then call repository methods defined in the Domain layer.
- The Data Layer implements the repository interfaces:
- It fetches data either from remote sources (TMDB, as implemented in “remote” data sources) or local cache/storage (via “local” data sources).
- Dependency Injection:
- “lib/injection_container.dart” serves as the initializer for wiring up dependencies, ensuring that the correct data source and repository implementations are provided to the BLoC and Domain layers.
- External Interaction:
- The remote data sources in the “lib/data/data_sources/remote” folder are responsible for making HTTP requests to TMDB.
- The API key setup mentioned in the README (“constant_sample.dart”) configures authentication with the TMDB API.

##### Architectural Patterns
- Clean Architecture:
- The layering (Presentation, Domain, Data) emphasizes separation of concerns.
- Communication between layers is via well-defined interfaces (repository interfaces in the domain layer).
- BLoC Pattern:
- Provides reactive state management for the UI.
- Encourages clear event, state, and bloc separation as illustrated by the various “*_bloc.dart”, “*_event.dart”, and “*_state.dart” files.
- Dependency Injection:
- Facilitates loose coupling between modules and simplifies testing by using “injection_container.dart”.

##### Technologies, Frameworks, and Libraries
- Flutter Framework: For building cross-platform mobile UI.
- BLoC (Business Logic Component) Package: For managing state.
- HTTP/Networking (likely via underlying Flutter packages): For interactions with TMDB API.
- Platform-specific integration files in “android” and “ios” ensure the app complies with native platform requirements.

- Presentation Layer (UI and BLoCs).
- Domain Layer (Repository interfaces and business logic).
- Data Layer (Data sources, both local and remote, and model representations).
- Core Layer (Utilities, networking configurations, dependency injection).
- External Services (TMDB API).
- Native Platforms (Android and iOS).
- From BLoCs to Domain repositories.
- From Domain repositories to Data sources (remote/local).
- From the remote data sources to the TMDB API.
- Provide annotations that briefly describe each component’s responsibility:
- For instance, note that the injection container wires up dependencies, and that the BLoC pattern manages state transitions triggered by user interactions.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Presentation Layer"
        UI["UI Components (Pages & Widgets)"]:::presentation
        BLOC["BLoC Components (State Management)"]:::presentation
    end

    subgraph "Domain Layer"
        DOMAIN["Repository Interfaces (Business Rules)"]:::domain
    end

    subgraph "Data Layer"
        REMOTE["Remote Data Sources"]:::data
        LOCAL["Local Data Sources"]:::data
    end

    subgraph "Core Utilities"
        NETWORK["Network Utilities"]:::core
        DEP_INJ["Dependency Injection Setup"]:::core
    end

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

    subgraph "Native Platforms"
        ANDROID["Android Environment"]:::native
        IOS["iOS Environment"]:::native
    end

    %% Relationships
    UI -->|"dispatches_event"| BLOC
    BLOC -->|"calls_repo_methods"| DOMAIN
    DOMAIN -->|"implemented_by_remote"| REMOTE
    DOMAIN -->|"implemented_by_local"| LOCAL
    REMOTE -->|"fetches_from"| TMDB
    NETWORK -->|"supports_networking"| REMOTE

    DEP_INJ -->|"injects_dependency"| UI
    DEP_INJ -->|"injects_dependency"| BLOC
    DEP_INJ -->|"injects_dependency"| DOMAIN
    DEP_INJ -->|"injects_dependency"| REMOTE
    DEP_INJ -->|"injects_dependency"| LOCAL

    ANDROID -->|"hosts_app_on"| UI
    IOS -->|"hosts_app_on"| UI

    %% Click Events
    click UI "https://github.com/tcvathana/movie_app/tree/develop/lib/presentation"
    click BLOC "https://github.com/tcvathana/movie_app/tree/develop/lib/presentation/bloc"
    click DOMAIN "https://github.com/tcvathana/movie_app/tree/develop/lib/domain"
    click REMOTE "https://github.com/tcvathana/movie_app/tree/develop/lib/data/data_sources/remote"
    click LOCAL "https://github.com/tcvathana/movie_app/tree/develop/lib/data/data_sources/local"
    click NETWORK "https://github.com/tcvathana/movie_app/blob/develop/lib/core/network/network_info.dart"
    click DEP_INJ "https://github.com/tcvathana/movie_app/blob/develop/lib/injection_container.dart"
    click ANDROID "https://github.com/tcvathana/movie_app/tree/develop/android"
    click IOS "https://github.com/tcvathana/movie_app/tree/develop/ios"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef domain fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef core fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef native fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
```
