# vladimirlogachov/moviespot architecture

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

## Overview

##### Main Components of the System
- Native Application Shells:
- Android Module (androidApp): Contains Android-specific application files, resources, manifests, and entry points (e.g. MainActivity and MoviesPotApp).
- iOS Module (iosApp): Contains Xcode project files, iOS-specific assets, and application entry point (e.g. iOSApp.swift, MainViewController, etc.).
- Shared Modules:
- shared-data: Implements networking (using Ktor), local storage (possibly with multiplatform settings), and repository implementations that fetch movie data from the TMDB API.
- shared-domain: Encapsulates business logic, models (e.g. Movie, Genre, Settings) and use cases (e.g. DiscoverMovies, SearchMovies, LoadDetails). This layer handles the core decisions and rules that are platform agnostic.
- shared-presentation: Contains shared UI logic and components, including Compose screens, navigation (Jetpack Navigation on Android), theme definitions (Material 3 dynamic themes), dependency injection configurations (using Koin) and view models that bind the UI to domain logic. It further has platform-specific implementations for Android, iOS, desktop, and web (WASM/JS).

##### Relationships and Interactions
- The shared-presentation layer calls use cases from the shared-domain layer to retrieve or manipulate data.
- The shared-domain layer, in turn, interacts with repositories and data sources defined in shared-data.
- Native modules (androidApp and iosApp) serve as entry points that initialize the application and setup platform-specific configurations. They rely on the shared code for business and UI functionalities.
- Configuration and build files (build.gradle.kts, settings.gradle.kts, gradle.properties) indicate build-time dependency management and project setup, supporting multiplatform compilation.
- The communication with the TMDB API is managed from the repositories (RemoteMovieRepository, RemoteDiscoverRepository, etc.) present in shared-data, and results are transformed via HTTP utilities and mapping to domain models.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clear separation of concerns into Data, Domain, and Presentation layers.
- Multiplatform: Common code repositories preventing duplication across Android, iOS, web, and even desktop.
- MVVM or MVI patterns (hinted by the presence of use cases, view models, and view state classes in shared-presentation).
- Dependency Injection handled by Koin for modularity and easier testing.
- Asynchronous Data Flows using Kotlin Coroutines Flow for reactive UI updates.
- Modular composition, where each layer interacts only via well-defined interfaces and dependency boundaries.

##### Relevant Technologies & Frameworks
- Kotlin Multiplatform for shared code.
- Compose Multiplatform and Material 3 design for the UI.
- Jetpack Navigation and Paging for Android navigation and data pagination.
- Ktor for network calls.
- Koin for dependency injection.
- Additional testing libraries like Turbine, Mokkery, and Detekt for static analysis.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Native Application Shells
    subgraph "Native Application Shells"
        A["Android App"]:::native
        B["iOS App"]:::native
    end

    %% Shared Modules
    subgraph "Shared Modules"
        subgraph "Presentation Layer"
            C["Shared Presentation\n(Compose UI, Navigation, DI with Koin)"]:::shared
        end
        subgraph "Domain Layer"
            D["Shared Domain\n(Business Logic, Use Cases)"]:::shared
        end
        subgraph "Data Layer"
            E["Shared Data\n(Repositories, Networking with Ktor, Local Storage)"]:::shared
        end
    end

    %% External service
    F["TMDB API"]:::external

    %% Data Flow Connections
    A -->|"initializes"| C
    B -->|"initializes"| C
    C -->|"calls_usecases"| D
    D -->|"accesses_repositories"| E
    E -->|"fetches_data"| F

    %% Click Events for Component Mapping
    click A "https://github.com/vladimirlogachov/moviespot/tree/master/androidApp/src/main/java/com/vlohachov/moviespot"
    click B "https://github.com/vladimirlogachov/moviespot/tree/master/iosApp/iosApp"
    click E "https://github.com/vladimirlogachov/moviespot/tree/master/shared-data"
    click D "https://github.com/vladimirlogachov/moviespot/tree/master/shared-domain"
    click C "https://github.com/vladimirlogachov/moviespot/tree/master/shared-presentation"

    %% Styles
    classDef native fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef shared fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#333,stroke-width:2px;
```
