# hide1202/moviedatabase architecture

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

- Interactive diagram: https://gitdiagram.com/hide1202/moviedatabase
- Repository: https://github.com/hide1202/moviedatabase

## Overview

Based on both the file tree and the README, this project is an Android application called “Movie Database” built to consume an external Movie Database API. Its purpose is to serve as a lab for trying out modern Android development techniques. The app leverages Kotlin, Jetpack libraries (Compose, Lifecycle, Navigation, Paging, Room, etc.), and follows an MVVM architecture with unidirectional data flow (UDF). It’s also heavily modularized—with core modules (e.g., api, data, domain, model, design system), feature modules (e.g., home, search, setting, common UI), and application-level modules—, as well as having a customized build-logic folder for Gradle conventions.

##### Main Components
- Application Module: The “app” module along with its platform-related packages (like AndroidManifest, startup, receivers, UI components). This is the entry point and wires up DI modules (e.g., AndroidModule, ImageLoaderModule) along with the MovieDatabaseApp.
- Feature Modules: Modules under “feature” (home, search, setting, common-ui) that encapsulate specific UI screens (e.g., HomeScreen, MovieSearchScreen, DetailViews) and their ViewModels.
- Core Modules: Several “core” directories that are split into:
- API: Handles Retrofit interfaces, JSON serialization (with Moshi), and network communications.
- Data: Contains repository implementations, data sources (database via Room & network), and DI setup (e.g., ApiModule, RepositoryModule).
- Domain: Contains business logic interfaces, repository contracts, and model definitions representing the app domain (Movie, Credit, Keyword, etc.).
- Model: Contains UI model mappers and data transformation logic.
- Common (and Widget): Provide utilities, common coroutine helpers, view-specific components, and shared code.
- Build/System Infrastructure Modules: “build-logic” holds custom Gradle plugins and build convention scripts which are part of the continuous integration and build configuration.
- Test Suites: Various test folders (unit and instrumented) spread across modules to validate API functionality, UI behavior, and integrations.

##### Relationships and Interactions
- The Application Module initializes the app components and sets up dependency injection (using Hilt) bringing together DI modules from the “app” and “core/data/di” folders.
- The UI layer (activities/compose components under feature modules) interacts with the ViewModels (in the viewmodel packages), which in turn coordinate with the Domain layer.
- The Domain layer processes data by interacting with repository interfaces; these repositories are implemented in the Data layer.
- API calls (using Retrofit with Moshi for JSON) reside in the “core/api” module. Data flows from these external services into the Data repositories and then transforms (using mapper packages in “model”) for display in the UI.
- Persistence is achieved via Room in “core/data”, storing details like “WantToSee” statuses.
- There is a clear separation between UI, business logic, and data sources—as evidenced by the MVVM structure and the unidirectional data flow design.

##### Important Architectural Patterns and Technologies
- MVVM Architecture: Clearly separating Model, View, and ViewModel with Dependency Injection to manage components.
- Unidirectional Data Flow (UDF): Ensuring a clear flow of data from repositories to UI.
- Dependency Injection using Hilt, which is configured via multiple “di” packages across modules.
- Usage of modern Android libraries: Compose for UI; Navigation for managing screens; Paging 3 for data pagination.
- Gradle build customization through “build-logic” to enforce consistency across modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External API
    EX("External Movie API"):::external

    %% Android Platform
    subgraph "Android Platform"
        A1("MovieDatabaseApp"):::appLayer
        A2("DI Modules (App-Level)"):::diLayer
    end

    %% Feature Modules
    subgraph "Feature Modules"
        HUI("Home UI"):::uiLayer
        HVM("Home ViewModel"):::viewModel
        SUI("Search UI"):::uiLayer
        SVM("Search ViewModel"):::viewModel
        SET("Setting Module"):::uiLayer
        CUI("Common UI"):::uiLayer
        CVM("Common UI ViewModel"):::viewModel
    end

    %% Core Layers
    subgraph "Core Layers"
        DM("Domain Module"):::domainLayer
        DAT("Data Module (Repos, Room)"):::dataLayer
        API("API Module (Retrofit,Moshi)"):::apiLayer
        MM("Model Module (Mappers)"):::modelLayer
        DS("Design System"):::designLayer
    end

    %% Build Infrastructure
    subgraph "Build Infrastructure"
        BL("Build-Logic"):::buildLayer
    end

    %% Relationships
    %% Android Platform relationships
    A1 -->|"init_DI"| A2
    A2 -->|"injects"| HVM
    A2 -->|"injects"| SVM
    A2 -->|"injects"| SET
    A2 -->|"injects"| CVM
    A2 -->|"injects"| DM
    A2 -->|"injects"| DAT
    A2 -->|"injects"| API
    A2 -->|"injects"| MM

    %% Feature Modules binding
    HUI -->|"binds"| HVM
    SUI -->|"binds"| SVM
    CUI -->|"binds"| CVM

    %% ViewModel to Domain
    HVM -->|"calls"| DM
    SVM -->|"calls"| DM
    SET -->|"calls"| DM
    CVM -->|"calls"| DM

    %% Domain to Data
    DM -->|"fetches_from"| DAT

    %% Data Layer interactions
    DAT -->|"gets_from"| API
    DAT -->|"maps_with"| MM

    %% External API feeds into API module
    EX -->|"provides_data"| API

    %% UI theming from Design System
    HUI -->|"theme"| DS
    SUI -->|"theme"| DS
    SET -->|"theme"| DS
    CUI -->|"theme"| DS

    %% Build system builds the app
    BL -->|"builds"| A1

    %% Click Events
    click A1 "https://github.com/hide1202/moviedatabase/blob/develop/app/src/main/java/io/viewpoint/moviedatabase/platform/MovieDatabaseApp.kt"
    click A2 "https://github.com/hide1202/moviedatabase/tree/develop/app/src/main/java/io/viewpoint/moviedatabase/di"
    click HUI "https://github.com/hide1202/moviedatabase/tree/develop/feature/home/src/main/java/io/viewpoint/moviedatabase/ui/home"
    click HVM "https://github.com/hide1202/moviedatabase/blob/develop/feature/home/src/main/java/io/viewpoint/moviedatabase/viewmodel/MainViewModel.kt"
    click SUI "https://github.com/hide1202/moviedatabase/tree/develop/feature/search/src/main/java/io/viewpoint/moviedatabase/ui/search"
    click SVM "https://github.com/hide1202/moviedatabase/tree/develop/feature/search/src/main/java/io/viewpoint/moviedatabase/viewmodel"
    click SET "https://github.com/hide1202/moviedatabase/tree/develop/feature/setting/src/main/java/io/viewpoint/moviedatabase/ui/setting"
    click CUI "https://github.com/hide1202/moviedatabase/tree/develop/feature/common-ui/src/main/java/io/viewpoint/moviedatabase/ui/common"
    click CVM "https://github.com/hide1202/moviedatabase/tree/develop/feature/common-ui/src/main/java/io/viewpoint/moviedatabase/ui/common"
    click API "https://github.com/hide1202/moviedatabase/tree/develop/core/api/src/main/java/io/viewpoint/moviedatabase/api"
    click DAT "https://github.com/hide1202/moviedatabase/tree/develop/core/data/src/main/java/io/viewpoint/moviedatabase/core/data"
    click DM "https://github.com/hide1202/moviedatabase/tree/develop/core/domain/src/main/java/io/viewpoint/moviedatabase/domain"
    click MM "https://github.com/hide1202/moviedatabase/tree/develop/core/model/src/main/java/io/viewpoint/moviedatabase/model/ui"
    click DS "https://github.com/hide1202/moviedatabase/tree/develop/core/designsystem/src/main/java/io/viewpoint/moviedatabase/designsystem"
    click BL "https://github.com/hide1202/moviedatabase/tree/develop/build-logic/"

    %% Styles
    classDef appLayer fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef diLayer fill:#ffe6cc,stroke:#cc6600,stroke-width:2px;
    classDef uiLayer fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef viewModel fill:#ccffcc,stroke:#009900,stroke-dasharray: 5 5,stroke-width:2px;
    classDef domainLayer fill:#cce5ff,stroke:#004d99,stroke-width:2px;
    classDef dataLayer fill:#e6ccff,stroke:#6600cc,stroke-width:2px;
    classDef apiLayer fill:#e6ffcc,stroke:#66cc00,stroke-width:2px;
    classDef modelLayer fill:#ffffcc,stroke:#cccc00,stroke-width:2px;
    classDef designLayer fill:#d9d9d9,stroke:#808080,stroke-width:2px;
    classDef buildLayer fill:#ffebcc,stroke:#ff9900,stroke-width:2px;
    classDef external fill:#f2f2f2,stroke:#999999,stroke-width:2px;
```
