# vishnu32510/whosthatdog architecture

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

## Overview

##### And List the Main Components
- User Interface (UI) Layer: This is built using Jetpack Compose. It includes:
- MainActivity and various screens (HomeScreen, BreedsScreen, BreedsImagesScreen, LoginScreen, SignupScreen).
- Composable UI components (e.g., BottomNavigationBar, CustomTextField, HeaderText, LoadingErrorPage, ShowImage, etc.).
- Theme and styling files (under the “ui/theme” directory).
- ViewModel Layer: Contains ViewModels (HomeViewModel, BreedsViewModel, BreedImagesViewModel) that hold UI state and manage business logic.
- Model Layer: Represents data models (BreedImagesModel, BreedsListModel, RandomImageModel) which mirror the JSON responses from the API.
- Service/Networking Layer: Implements networking using Retrofit. Key files include ApiServices.kt and RetrofitClient.kt.
- Utility and Helpers: Includes utility functions (like StringExtentions.kt) aiding operations across the application.

##### Relationships and Data Flow
- UI Layer interacts with the ViewModel:
- User actions in composables trigger functions in the ViewModel.
- The ViewModel holds state using StateFlow and interacts with the repository/services.
- ViewModels request data using the Networking Layer:
- They call methods in ApiServices (which use Retrofit for network calls).
- Data models are used to represent and store this fetched information.
- Network data flows back into the ViewModel:
- Processed asynchronously using Coroutines and Flow.
- UI components observe state changes and update accordingly.
- The application’s resource files and theme settings dictate brand look and feel.

##### Architectural Patterns and Design Principles
- MVVM Architecture: Separates concerns between UI (composables), ViewModels (state and business logic), and data/model layers.
- Asynchronous Data Handling: Utilizes Coroutines and Flow to handle network calls and UI updates.
- Separation of Concerns: Each layer has a clear responsibility from data fetching to UI presentation.
- Modularization: The directory structure clearly separates endpoints (like services, ui, viewmodel, models, etc.) making the system highly maintainable.

##### Relevant Technologies and Frameworks
- Language: Kotlin
- UI Framework: Jetpack Compose, with Composable components (LazyColumn, Material Design elements, etc.).
- Networking: Retrofit (with Gson for JSON processing)
- Asynchronous Processing: Kotlin Coroutines and Flow
- Architectural Pattern: MVVM
- Additional: Material 3 design, custom themes, and resources for the Android ecosystem.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        MA["MainActivity"]:::uiLayer
        HS["HomeScreen"]:::uiLayer
        BS["BreedsScreen"]:::uiLayer
        BIS["BreedsImagesScreen"]:::uiLayer
        LS["LoginScreen"]:::uiLayer
        SS["SignupScreen"]:::uiLayer
        CC["Composable Components"]:::uiLayer
        TF["Theme & Styling"]:::uiLayer
    end

    subgraph "ViewModel Layer"
        HVM["HomeViewModel"]:::viewModel
        BVM["BreedsViewModel"]:::viewModel
        BIM["BreedImagesViewModel"]:::viewModel
    end

    subgraph "Service/Networking Layer"
        RC["RetrofitClient"]:::network
        AS["ApiServices"]:::network
    end

    subgraph "Model Layer"
        BIMd["BreedImagesModel"]:::model
        BLMd["BreedsListModel"]:::model
        RIMd["RandomImageModel"]:::model
    end

    subgraph "Utility & Helpers"
        UF["Utility Functions"]:::utility
    end

    subgraph "Configuration & Resources"
        AM["AndroidManifest"]:::config
        BSRes["Build Scripts & Resources"]:::config
    end

    %% UI Layer connections
    MA -->|"starts"| HS
    HS -->|"trigger"| HVM
    BS -->|"trigger"| BVM
    BIS -->|"trigger"| BIM

    %% ViewModel to Networking (request and response)
    HVM -->|"request"| AS
    BVM -->|"request"| AS
    BIM -->|"request"| AS
    AS -->|"response"| HVM
    AS -->|"response"| BVM
    AS -->|"response"| BIM

    %% Networking internal relation
    AS -->|"uses"| RC

    %% Networking to Model mapping
    AS -->|"maps_to"| BIMd
    AS -->|"maps_to"| BLMd
    AS -->|"maps_to"| RIMd

    %% Utility usage
    UF -->|"used_by"| HS
    UF -->|"used_by"| HVM

    %% Configuration support
    AM -->|"configures"| MA
    BSRes -->|"provides"| TF

    %% Click Events
    click MA "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/MainActivity.kt"
    click HS "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/ui/screens/HomeScreen.kt"
    click BS "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/ui/screens/BreedsScreen.kt"
    click BIS "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/ui/screens/BreedsImagesScreen.kt"
    click LS "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/ui/login/LoginScreen.kt"
    click SS "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/ui/signup/SignupScreen.kt"
    click CC "https://github.com/vishnu32510/whosthatdog/tree/main/app/src/main/java/com/vn/whosthatdog/ui/components"
    click TF "https://github.com/vishnu32510/whosthatdog/tree/main/app/src/main/java/com/vn/whosthatdog/ui/theme"
    click HVM "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/viewmodel/HomeViewModel.kt"
    click BVM "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/viewmodel/BreedsViewModel.kt"
    click BIM "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/viewmodel/BreedImagesViewModel.kt"
    click BIMd "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/models/BreedImagesModel.kt"
    click BLMd "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/models/BreedsListModel.kt"
    click RIMd "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/models/RandomImageModel.kt"
    click AS "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/services/ApiServices.kt"
    click RC "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/services/RetrofitClient.kt"
    click UF "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/java/com/vn/whosthatdog/utils/StringExtentions.kt"
    click AM "https://github.com/vishnu32510/whosthatdog/blob/main/app/src/main/AndroidManifest.xml"
    click BSRes "https://github.com/vishnu32510/whosthatdog/blob/main/app/build.gradle.kts"

    %% Styles
    classDef uiLayer fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef viewModel fill:#AED6F1,stroke:#2980B9,stroke-width:2px;
    classDef network fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef model fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef utility fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef config fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
```
