# khaledalsawy44/moviesapp architecture

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

- Interactive diagram: https://gitdiagram.com/khaledalsawy44/moviesapp
- Repository: https://github.com/khaledalsawy44/moviesapp

## Overview

##### Project Type and Purpose
- The project is a full-stack mobile application (Android) for browsing and viewing movie information.
- The README highlights that the app uses the TMDb API, modern Android development tools (Jetpack Compose, Kotlin Coroutines), and follows an MVI architecture.
- With its clear separation into feature modules, core functionalities (networking, data handling, common utilities), and design system, it stresses modularity and reusability.

##### File Structure
- The top-level directories indicate multiple Gradle modules:
- app – The entry module containing the application launch (MainActivity.kt and Application.kt), AndroidManifest, and primary navigation that integrates Compose UI.
- business-models – Defines domain entities and models such as Movie, MovieDetails, and Pagination.
- core – Divided into submodules:
- core/common: Contains base classes, composables, and shared UI elements used across the app.
- core/data: Hosts repository implementations and dependency injection (DI) for accessing movie details and list repositories.
- core/network: Manages API communication, interceptors, mappers, and network services (using Retrofit, OkHttp, etc.).
- design-system – Provides atomic & component-based UI elements, themes, and design tokens to maintain consistency across the UI.
- features – Separate feature modules for Movie Details and Movies List. Each has its own set of screens, view models, and Compose UI code.
- navigation – Manages navigation arguments, screens, and related constants for handling screen transitions.
- The presence of separate modules for features and core services clearly indicates adherence to modular architecture principles.

##### Main Components
a. App Module:
- Entry point of the application with Application.kt and MainActivity.kt.
- Integrates navigation and composes the UI.
b. Business Models:
- Domain entities such as Movie, MovieDetails, and AppErrors.
c. Core Module:
- core/common: Provides base Compose screens, common UI components, and utility extensions.
- core/data: Repository implementations (e.g., MovieDetailsRepositoryImp, MoviesListRepositoryImp) along with DI setup.
- core/network: Handles API communications (Retrofit setup, interceptors like AuthorizationInterceptor, data sources, and mappers).
d. Design System:
- Contains design tokens, themes, and reusable UI components/atoms.
e. Features:
- features/moviesList: Contains screens, view models, and composables for listing movies.
- features/movieDetails: Contains screens, view models, and additional detail-specific UI.
f. Navigation Module:
- Organizes navigation screens and argument passing between different UI components.

##### Relationships and Interactions
- The App module kick-starts the process by initializing the application context and setting up navigation.
- Feature modules (Movies List and Movie Details) are responsible for composing the UI and interacting with the core repository layer to fetch movie data.
- The Core module acts as a service layer:
- The network submodule communicates with the external TMDb APIs using Retrofit and OkHttp, and then maps the data to business models.
- The data submodule handles data transformation and business logic via repositories.
- The design-system module provides styling and presentational components that are used by both the App and feature modules.
- The Navigation module facilitates screen transitions using Compose Navigation, ensuring that all features can interact seamlessly.
- Dependency Injection (with Hilt – implied by the mention in the README) orchestrates the dependencies among these modules, allowing smooth integration between networking, data fetching, and UI rendering.

##### Architectural Patterns
- MVI (Model-View-Intent) Architecture: Clear separation of concerns where the ViewModel processes intents, updates state, and triggers UI updates.
- Modular Architecture: The breakdown into modules (app, core, features, design-system) facilitates independent development and testing.
- DI (Dependency Injection) Pattern: Likely implemented via Hilt to manage dependencies (e.g., repositories, network services) across modules.

- That the data flow (user interaction → feature UI → view model → repository → network call → response to view model → UI update) is captured clearly.
- For each module, include technology annotations (e.g., “Jetpack Compose” in UI components, “Retrofit/OkHttp” in network, “Kotlin Coroutines” for asynchronous tasks).
- Finally, include high-level notes that the overall design follows MVI and uses dependency injection (Hilt) to maintain a clear separation of concerns.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        A["App Module (Jetpack Compose)"]:::ui
        N["Navigation Module"]:::ui
        DS["Design System"]:::ui
        subgraph "Features"
            ML["Movies List Feature"]:::ui
            MD["Movie Details Feature"]:::ui
        end
    end

    subgraph "Business Logic Layer"
        BM["Business Models"]:::business
        subgraph "Core Modules"
            C["Core - Common"]:::business
            D["Core - Data (Repositories & DI)"]:::business
            NT["Core - Network (Retrofit/OkHttp)"]:::business
        end
    end

    TMDB["TMDb API"]:::external

    %% Arrows for UI Flow
    A -->|"initNav"| N
    N -->|"navigatesTo"| ML
    N -->|"navigatesTo"| MD
    A -->|"renders"| DS
    DS -->|"styles"| ML
    DS -->|"styles"| MD

    %% Arrows for Feature to Core/Data interactions
    ML -->|"callsRepository"| D
    MD -->|"callsRepository"| D
    ML -->|"injectsRepo"| D
    MD -->|"injectsRepo"| D
    ML -->|"updatesState"| BM
    MD -->|"updatesState"| BM

    %% Arrows for Data to Network interactions
    D -->|"fetchesData"| NT
    NT -->|"calls"| TMDB
    TMDB -->|"response"| NT
    NT -->|"mapsData"| D

    %% Click Events
    click A "https://github.com/khaledalsawy44/moviesapp/tree/main/app/src/main/java/com/moviesApp/moviesapp"
    click N "https://github.com/khaledalsawy44/moviesapp/tree/main/navigation/src/main/java/com/moviesApp/navigation"
    click DS "https://github.com/khaledalsawy44/moviesapp/tree/main/design-system/src/main/java/com/moviesApp/designSystem"
    click ML "https://github.com/khaledalsawy44/moviesapp/tree/main/features/moviesList/src/main/java/com/moviesApp/movieslist"
    click MD "https://github.com/khaledalsawy44/moviesapp/tree/main/features/movieDetails/src/main/java/com/moviesApp/movieDetails"
    click BM "https://github.com/khaledalsawy44/moviesapp/tree/main/business-models/src/main/java/com/moviesApp/business_models"
    click C "https://github.com/khaledalsawy44/moviesapp/tree/main/core/common/src/main/java/com/moviesApp/common"
    click D "https://github.com/khaledalsawy44/moviesapp/tree/main/core/data/src/main/java/com/moviesApp/data"
    click NT "https://github.com/khaledalsawy44/moviesapp/tree/main/core/network/src/main/java/com/moviesapp/network"

    %% Styles
    classDef ui fill:#CCE5FF,stroke:#2A9DF4,stroke-width:2px;
    classDef business fill:#D4EDDA,stroke:#28A745,stroke-width:2px;
    classDef external fill:#F8D7DA,stroke:#C82333,stroke-width:2px;
```
