# garghimanshu0786/movie-info architecture

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

- Interactive diagram: https://gitdiagram.com/garghimanshu0786/movie-info
- Repository: https://github.com/garghimanshu0786/movie-info

## Overview

##### Main Components
- Frontend/Presentation Layer: This layer is responsible for UI elements and user interactions.
- It includes MainActivity, the Composables (e.g., MoviesScreen.kt, MovieCard.kt, etc.), UI components, and ViewModels (e.g., MoviesViewModel.kt).
- Domain Layer: This encapsulates the business logic.
- Contains entities (MoviesEntity.kt, ResultEntity.kt) and use cases (e.g., GetMoviesUseCase.kt, AddPlaylistUseCase.kt, etc.).
- Defines interfaces for the repository (IMovieRepository.kt) that abstract away the data sources.
- Data Layer: Handles data operations, network calls, and local persistence.
- Includes both local and remote data sources (e.g., IMovieLocalDataSource.kt, IMovieRemoteDataSource.kt, MovieRemoteDataSource.kt).
- Contains the repository implementation (MovieRepository.kt) that bridges between data sources and the domain.
- Manages API interactions (IMovieApiService.kt) and local database configurations (AppDatabase.kt, PlaylistDao.kt, etc.).
- Includes mappers (MovieFrameworkMapper.kt, MovieViewDataMapper.kt) to convert data between different layers.
- Dependency Injection and Configuration:
- MovieModule.kt and other DI components manage how these layers integrate.
- External Components and Utilities:
- API calling utilities (callAPI.kt) and other helper functions.
- Config files (build.gradle, gradle scripts, AndroidManifest.xml) which, though not part of the runtime architecture, play a role in project configuration.

##### Interactions and Relationships
- The Presentation Layer (UI and ViewModels) interacts with the Domain Layer by invoking specific use cases to fetch or update movie data.
- The Domain Layer communicates with the Data Layer through repository interfaces. Use cases trigger repository calls.
- The Data Layer further splits into:
- Remote data handling (using the API service and network modules).
- Local data management (using the AppDatabase and DAO components).
- Mappers act as transformation bridges to convert domain models to presentation models and vice versa.
- Dependency injection modules tie these interactions together and manage dependencies across layers.

- UI components (Composables and screens)
- ViewModels
- State management elements
- Use Cases that encapsulate business logic
- Domain Entities
- Repository interfaces
- Remote Data Source: API services, network components
- Local Data Source: Database components, DAOs
- Repository Implementation that unifies data from local and remote sources
- Mappers responsible for transforming models across layers
- Dependency Injection component as a connecting piece that wires up the repository, use cases, and view models.

- Presentation Layer (UI/Components, ViewModels)
- Domain Layer (Use Cases, Entities)
- Data Layer (Repository, Remote & Local Data Sources, Mappers)
- Data flow from the user interaction (UI) → ViewModel → Use Cases → Repository → (Remote API / Database) and the reverse flow for presenting the data.
- An annotation indicating the role of dependency injection in integrating these layers.
- Use notes or legends to describe technology uses (e.g., Retrofit or similar for API calls if applicable, Room or equivalent for the database).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Presentation Layer"
        PMA["MainActivity"] 
        PMS["MoviesScreen"]
        PC["UI Components"]
        VM["MoviesViewModel"]
        TS["Theming & State"]
    end

    subgraph "Domain Layer"
        MT["MoviesEntity"]
        RT["ResultEntity"]
        UM["GetMoviesUseCase"]
        AP1["AddPlaylistUseCase"]
        AP2["AddMovieToPlaylistUseCase"]
        GP["GetAllPlaylistsUseCase"]
        RM["RemoveMovieFromPlaylistUseCase"]
        IR["IMovieRepository"]
    end

    subgraph "Data Layer"
        REP["MovieRepository"]
        RDS["IMovieRemoteDataSource"]
        RDI["MovieRemoteDataSource"]
        LDS["IMovieLocalDataSource"]
        LDI["MovieLocalDataSource"]
        API["IMovieApiService"]
        DB["AppDatabase"]
        DAO["PlaylistDao"]
        FM["MovieFrameworkMapper"]
        PM["MovieViewDataMapper"]
        CALL["callAPI"]
    end

    DI["MovieModule"]

    subgraph "Configuration"
        AM["AndroidManifest.xml"]
        BG["build.gradle"]
    end

    %% Connections from Presentation Layer to Domain Layer
    PMA -->|"triggers"| VM
    PMS -->|"displays"| VM
    VM -->|"calls"| UM

    %% Domain interactions
    UM -->|"calls"| IR
    AP1 -->|"calls"| IR
    AP2 -->|"calls"| IR
    GP -->|"calls"| IR
    RM -->|"calls"| IR

    %% Data Layer interactions
    IR -->|"implementedBy"| REP
    REP -->|"accessesRemote"| RDS
    RDS -->|"implementedBy"| RDI
    REP -->|"accessesLocal"| LDS
    LDS -->|"implementedBy"| LDI
    RDI -->|"calls"| API
    LDI -->|"calls"| DB
    DB -->|"contains"| DAO
    REP -->|"usesMapper"| FM
    REP -->|"usesMapper"| PM
    REP -->|"utilizes"| CALL

    %% Dependency Injection binds layers
    DI --- VM
    DI --- UM
    DI --- REP

    %% Styles for visual clarity
    class PMA,PMS,PC,VM,TS presentation;
    class MT,RT,UM,AP1,AP2,GP,RM,IR domain;
    class REP,RDS,RDI,LDS,LDI,API,DB,DAO,FM,PM,CALL data;
    class DI di;
    class AM,BG config;

    %% Click Events for Presentation Layer
    click PMA "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/presentation/MainActivity.kt"
    click PMS "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/presentation/ui/MoviesScreen.kt"
    click PC "https://github.com/garghimanshu0786/movie-info/tree/master/app/src/main/java/com/himanshu/movieinfo/features/presentation/ui/components/"
    click VM "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/presentation/viewmodels/MoviesViewModel.kt"
    click TS "https://github.com/garghimanshu0786/movie-info/tree/master/app/src/main/java/com/himanshu/movieinfo/features/presentation/theme/"

    %% Click Events for Domain Layer
    click MT "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/domain/entities/MoviesEntity.kt"
    click RT "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/domain/entities/ResultEntity.kt"
    click UM "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/domain/usecases/GetMoviesUseCase.kt"
    click AP1 "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/domain/usecases/AddPlaylistUseCase.kt"
    click AP2 "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/domain/usecases/AddMovieToPlaylistUseCase.kt"
    click GP "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/domain/usecases/GetAllPlaylistsUseCase.kt"
    click RM "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/domain/usecases/RemoveMovieFromPlaylistUseCase.kt"
    click IR "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/domain/IMovieRepository.kt"

    %% Click Events for Data Layer
    click REP "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/data/repository/MovieRepository.kt"
    click RDS "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/data/source/IMovieRemoteDataSource.kt"
    click RDI "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/framework/network/MovieRemoteDataSource.kt"
    click LDS "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/data/source/IMovieLocalDataSource.kt"
    click LDI "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/framework/database/MovieLocalDataSource.kt"
    click API "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/framework/api/IMovieApiService.kt"
    click DB "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/framework/database/AppDatabase.kt"
    click DAO "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/framework/database/PlaylistDao.kt"
    click FM "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/framework/mapper/MovieFrameworkMapper.kt"
    click PM "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/presentation/mapper/MovieViewDataMapper.kt"
    click CALL "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/features/framework/utilities/callAPI.kt"

    %% Click Event for Dependency Injection
    click DI "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/java/com/himanshu/movieinfo/base/di/MovieModule.kt"

    %% Click Events for Configuration
    click AM "https://github.com/garghimanshu0786/movie-info/blob/master/app/src/main/AndroidManifest.xml"
    click BG "https://github.com/garghimanshu0786/movie-info/blob/master/app/build.gradle"

    %% Style Definitions
    classDef presentation fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef domain fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef data fill:#ffa07a,stroke:#000,stroke-width:1px;
    classDef di fill:#dda0dd,stroke:#000,stroke-width:1px;
    classDef config fill:#f5deb3,stroke:#000,stroke-width:1px;
```
