# git-xuhao/kotlinmvp architecture

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

- Interactive diagram: https://gitdiagram.com/git-xuhao/kotlinmvp
- Repository: https://github.com/git-xuhao/kotlinmvp

## Overview

##### Main Components Identification

a. Presentation Layer:
- Activities and Fragments (UI Components)
- Presenters
- Contracts (Interfaces between Views and Presenters)

b. Data Layer:
- Models
- API Service
- Local Storage (Watch History)

c. Core Components:
- Network Layer (Retrofit)
- Image Loading (Glide)
- Dependency Injection
- Utils and Helpers

**┌─────────────────────────────────────────────────────────────┐**
- Presentation Layer                       │
- ┬─────────────────────────┬──────────────────┤
- Activities  │       Fragments         │     Adapters      │
- & Views     │                        │                    │
- ┬───────┴──────────┬─────────────┴────────┬──────────┘

- ▼                  ▼                      ▼
**┌───────────────────────────────────────────────────────────┐**
- MVP Components                         │
- ┬────────────────────┬────────────────────┤
- Contracts    │    Presenters      │      Models        │
- ┬───────┴────────┬──────────┴─────────┬──────────┘

- ▼                ▼                     ▼
**┌───────────────────────────────────────────────────────────┐**
- Data Layer                            │
- ┬────────────────────┬────────────────────┤
- API Service   │  Local Storage     │   Cache Manager    │
- ┬───────┴────────┬──────────┴─────────┬──────────┘

- ▼                ▼                     ▼
**┌───────────────────────────────────────────────────────────┐**
- Core Components                        │
- ┬────────────────────┬────────────────────┤
- Retrofit    │      Glide         │   RxJava/Android   │
- ┴────────────────────┴────────────────────┘

##### Important Relationships

- Unidirectional data flow from API to Presenters to Views

##### Additional Elements

Specific features:
- Video playback component (GSYVideoPlayer)
- Image loading pipeline (Glide)
- Navigation flow between main sections
- Error handling and network state management
- Cache management for offline support

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef presenter fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef core fill:#95a5a6,stroke:#7f8c8d,color:white
    
    subgraph Presentation
        UI[UI Components]:::ui
        CustomViews[Custom Views]:::ui
        Adapters[Adapters]:::ui
    end
    
    subgraph MVP
        Contracts[MVP Contracts]:::presenter
        Presenters[Presenters]:::presenter
        Models[Data Models]:::data
    end
    
    subgraph Data
        ApiService[API Service]:::data
        LocalStorage[Local Storage]:::data
        CacheManager[Cache Manager]:::data
    end
    
    subgraph Core
        Network[Network Layer]:::core
        ImageLoader[Image Loading]:::core
        RxUtils[RxJava Utils]:::core
        BaseComponents[Base Components]:::core
        Utils[Utility Classes]:::core
    end
    
    %% Relationships
    UI --> Contracts
    UI --> CustomViews
    Contracts --> Presenters
    Presenters --> Models
    Models --> ApiService
    ApiService --> Network
    Models --> LocalStorage
    Models --> CacheManager
    UI --> ImageLoader
    Presenters --> RxUtils
    UI --> BaseComponents
    
    %% Click events
    click UI "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/ui/"
    click CustomViews "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/view/"
    click Contracts "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/mvp/contract/"
    click Presenters "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/mvp/presenter/"
    click Models "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/mvp/model/"
    click ApiService "https://github.com/git-xuhao/KotlinMvp/blob/master/app/src/main/java/com/hazz/kotlinmvp/api/ApiService.kt"
    click Network "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/net/"
    click ImageLoader "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/glide/"
    click LocalStorage "https://github.com/git-xuhao/KotlinMvp/blob/master/app/src/main/java/com/hazz/kotlinmvp/utils/WatchHistoryUtils.kt"
    click BaseComponents "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/base/"
    click RxUtils "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/rx/"
    click Utils "https://github.com/git-xuhao/KotlinMvp/tree/master/app/src/main/java/com/hazz/kotlinmvp/utils/"
    
    %% Legend
    subgraph Legend
        UI_Legend[UI Components]:::ui
        Presenter_Legend[Presenter Components]:::presenter
        Data_Legend[Data Components]:::data
        Core_Legend[Core Components]:::core
    end
```
