# kongquan98/movieapps architecture

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

- Interactive diagram: https://gitdiagram.com/kongquan98/movieapps
- Repository: https://github.com/kongquan98/movieapps

## Overview

##### Overall Project Type and Purpose
- Project Type: Mobile application using native Android development.
- Purpose: A movie listing and details app that includes user authentication, movie search, and detailed screens.
- Technologies: Jetpack Compose for UI, MVVM as an architectural pattern, Retrofit for API networking, Room for the local database, Hilt for dependency injection, and Firebase Auth/Firestore for user management.

- UI Layer (Presentation):
- UI Screens (located under app/src/main/java/.../ui/screen): LoginScreen, SignupScreen, OnboardingScreen, MovieListScreen, MovieDetailsScreen.
- UI Components (e.g., ErrorValidation and NetworkValidation components) under app/src/main/java/.../ui/component.
- Navigation Component (AppNavigation) that manages screen transitions.
- ViewModel Layer:
- ViewModels (found under app/src/main/java/.../viewmodel): MovieViewModel, LoginAndSignupViewModel – these manage UI state and business logic interaction.
- Domain/Business Logic Layer:
- Repositories (MovieImdbRepository) that gather data from various sources.
- Domain Models/Data Models (MovieListResponse, MovieDetailsResponse, ModelConversion, etc.) that transform raw data into usable formats.
- Service Interfaces (MovieImdbApi) for retrieving movie information from remote API endpoints.
- Configuration (ApiConfig.properties, Config.kt) which determine API endpoints and settings.
- Data Persistence Layer:
- Local Database using Room (MovieListDao, MovieListDatabase, UserDatabasePassphrase) enabling caching and local storage.
- Dependency Injection:
- DI Modules (NetworkModule in app/src/main/java/.../domain/di) that configure and provide instances required throughout the app (e.g., Retrofit, Room instances).
- External Services:
- Firebase Integration as implied by google-services.json and the README; although client code specifics aren’t detailed, it fits as an external authentication and data service.

##### Relationships and Data Flow
- UI Components interact with ViewModels to send user events.
- ViewModels orchestrate calls to the Domain layer (running business logic, data validation, etc.).
- The Domain layer, via repositories, manages data by interfacing with:
- Remote API calls (using Retrofit through the MovieImdbApi service).
- Local Cache/Database operations (using Room through DAOs).
- DI (via Hilt) ensures that all components (services, database, repositories) are correctly injected without manual assembly.
- Firebase services represent external dependencies, especially for user authentication and perhaps storing user profiles, with secure data flows between the app and cloud.

##### Architectural Patterns and Design Principles
- MVVM: Clearly separate presentation (UI and ViewModel) from business logic (Domain) and data persistence.
- Dependency Injection: Using Hilt to decouple module dependencies.
- Modular Design: Different packages (ui, viewmodel, domain, storage, config, di) keep concerns isolated.
- Clean/Layered Architecture: Ensures that UI remains independent of the data source, making the system testable and maintainable.

##### Essential Elements
- Configuration details such as dependency injection flows from the NetworkModule to various components.

##### Step-by-Step Creation
a. Begin by laying out the UI layer on the left side, including the individual composable screens and navigation.
d. At the bottom or side, attach the Data Persistence components (Room database, DAOs) and the network components (Retrofit with its API endpoint settings).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        LoginScreen["Login Screen"]:::ui
        SignupScreen["Signup Screen"]:::ui
        OnboardingScreen["Onboarding Screen"]:::ui
        MovieListScreen["Movie List Screen"]:::ui
        MovieDetailsScreen["Movie Details Screen"]:::ui
        ErrorValidation["ErrorValidation"]:::ui
        NetworkValidation["NetworkValidation"]:::ui
        AppNavigation["AppNavigation"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        LoginAndSignupViewModel["LoginAndSignupViewModel"]:::viewmodel
        MovieViewModel["MovieViewModel"]:::viewmodel
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Repository["MovieImdbRepository"]:::domain
        ModelConversion["ModelConversion"]:::domain
        MovieDetailsResponse["MovieDetailsResponse"]:::domain
        MovieListEntity["MovieListEntity"]:::domain
        MovieListResponse["MovieListResponse"]:::domain
        MovieImdbApi["MovieImdbApi"]:::domain
        ApiConfig["ApiConfig.properties"]:::domain
        Config["Config.kt"]:::domain
    end

    %% Data Persistence Layer
    subgraph "Data Persistence Layer"
        MovieListDao["MovieListDao"]:::persistence
        MovieListDatabase["MovieListDatabase"]:::persistence
        UserDBPassphrase["UserDatabasePassphrase"]:::persistence
    end

    %% Dependency Injection
    subgraph "Dependency Injection"
        NetworkModule["NetworkModule"]:::di
    end

    %% External Services
    subgraph "External Services"
        Firebase["Firebase Services"]:::external
    end

    %% Connections: UI Layer to ViewModel Layer
    LoginScreen -->|"triggers"| LoginAndSignupViewModel
    SignupScreen -->|"triggers"| LoginAndSignupViewModel
    OnboardingScreen -->|"triggers"| LoginAndSignupViewModel
    MovieListScreen -->|"triggers"| MovieViewModel
    MovieDetailsScreen -->|"triggers"| MovieViewModel

    AppNavigation -->|"manages"| LoginScreen
    AppNavigation -->|"manages"| SignupScreen
    AppNavigation -->|"manages"| OnboardingScreen
    AppNavigation -->|"manages"| MovieListScreen
    AppNavigation -->|"manages"| MovieDetailsScreen

    %% Connections: ViewModel Layer to Domain Layer
    LoginAndSignupViewModel -->|"orchestrates"| Repository
    MovieViewModel -->|"orchestrates"| Repository

    %% Connections: Domain Layer internal relations
    Repository -->|"calls"| MovieImdbApi
    Repository -->|"caches"| MovieListDao
    Repository -->|"converts via"| ModelConversion
    Repository -->|"processes"| MovieDetailsResponse
    Repository -->|"processes"| MovieListEntity
    Repository -->|"processes"| MovieListResponse

    MovieImdbApi -->|"uses"| ApiConfig
    MovieImdbApi -->|"uses"| Config

    %% Connections: Dependency Injection to Domain & Persistence
    NetworkModule -->|"injects"| MovieImdbApi
    NetworkModule -->|"injects"| MovieListDatabase

    %% Connections: Data Persistence internal relations
    MovieListDatabase -->|"provides access to"| MovieListDao
    MovieListDatabase -->|"secured by"| UserDBPassphrase

    %% External Services Integration
    Firebase -->|"auth"| LoginAndSignupViewModel

    %% Class Definitions
    classDef ui fill:#F0F8FF,stroke:#333,stroke-width:2px;
    classDef viewmodel fill:#FFFACD,stroke:#e69500,stroke-width:2px;
    classDef domain fill:#E6FFE6,stroke:#339966,stroke-width:2px;
    classDef persistence fill:#FFE6E6,stroke:#CC3333,stroke-width:2px;
    classDef di fill:#E6E6FF,stroke:#3333CC,stroke-width:2px;
    classDef external fill:#FFF0F5,stroke:#993399,stroke-width:2px;

    %% Click Events for UI Screens
    click LoginScreen "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/ui/screen/LoginScreen.kt"
    click SignupScreen "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/ui/screen/SignupScreen.kt"
    click OnboardingScreen "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/ui/screen/OnboardingScreen.kt"
    click MovieListScreen "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/ui/screen/MovieListScreen.kt"
    click MovieDetailsScreen "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/ui/screen/MovieDetailsScreen.kt"
    click ErrorValidation "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/ui/component/ErrorValidation.kt"
    click NetworkValidation "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/ui/component/NetworkValidation.kt"
    click AppNavigation "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/navigation/AppNavigation.kt"

    %% Click Events for ViewModel Layer
    click LoginAndSignupViewModel "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/viewmodel/LoginAndSignupViewModel.kt"
    click MovieViewModel "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/viewmodel/MovieViewModel.kt"

    %% Click Events for Domain Layer
    click Repository "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/MovieImdbRepository.kt"
    click ModelConversion "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/datamodel/ModelConversion.kt"
    click MovieDetailsResponse "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/datamodel/MovieDetailsResponse.kt"
    click MovieListEntity "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/datamodel/MovieListEntity.kt"
    click MovieListResponse "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/datamodel/MovieListResponse.kt"
    click MovieImdbApi "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/service/MovieImdbApi.kt"
    click ApiConfig "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/config/ApiConfig.properties"
    click Config "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/config/Config.kt"

    %% Click Events for Data Persistence Layer
    click MovieListDao "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/storage/MovieListDao.kt"
    click MovieListDatabase "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/storage/MovieListDatabase.kt"
    click UserDBPassphrase "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/storage/UserDatabasePassphrase.kt"

    %% Click Events for Dependency Injection
    click NetworkModule "https://github.com/kongquan98/movieapps/blob/main/app/src/main/java/com/example/movieapps/domain/di/NetworkModule.kt"

    %% Click Event for External Service
    click Firebase "https://github.com/kongquan98/movieapps/blob/main/app/google-services.json"
```
