# dedulka22/nba-app architecture

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

- Interactive diagram: https://gitdiagram.com/dedulka22/nba-app
- Repository: https://github.com/dedulka22/nba-app

## Overview

##### Main Components
- UI Layer:
- ViewModel Layer:
– Contains state management and business logic coordination via ViewModels (PlayersViewModel, PlayerDetailViewModel, TeamDetailViewModel).
- Domain Layer:
– Holds core business logic: UseCases (GetPlayersUseCase, GetPlayerDetailUseCase, GetTeamDetailUseCase), domain models (Player, PlayerDetail, Team), and repository interface definitions.
- Data Layer:
– Implements repository interfaces via classes in data/repository (PlayerRepositoryImpl, PlayerDetailRepositoryImpl, TeamDetailRepositoryImpl). This layer also includes data models (e.g., PlayerResponse, TeamResponse), API clients (NBAApi, UnsplashApi via ApiClient.kt), paging sources (PlayersPagingSource), and data services (e.g., PlayerImageService).
- Dependency Injection Layer:
– The DI module (in di/appModule.kt) sets up dependency injection using Koin.
- External Services:
– Represents integration with external APIs: the Ball Don't Lie API (for player and team information) and Unsplash API (for images).
- Testing:
– A separate testing structure for both instrumentation and unit tests (JUnit, MockK, etc.) to verify the functionality of components.

##### Understand Relationships and Data Flow
- The UI layer (built with Jetpack Compose and Material 3) interacts with its ViewModels.
- ViewModels invoke use cases defined in the Domain layer.
- Use cases use repository interfaces to fetch data.
- The repository implementations in the Data layer connect to API clients (Retrofit integrated with OkHttp) and PagingSources to manage remote API calls.
- Dependency Injection, configured via Koin (in di/appModule.kt), wires these components together.
- Data flows from external services (Ball Don't Lie API, Unsplash API) through the Data layer, then flows through Domain logic and to the UI.

##### Architectural Patterns and Design Principles
- MVVM: Ensure you capture the clear separation between UI (View), ViewModel (presentation logic), and Model (domain/data).
- Clean Architecture: Highlight the separation into Data, Domain, and Presentation layers.
- Dependency Injection: Mark the DI layer that decouples component instantiation (using Koin in this project).
- Modern asynchronous programming with Kotlin Coroutines & Flow is used in the data fetching and processing layers.
- Navigation: Note the integration with Voyager Navigation to manage screen transitions.

– In the center, show the Data layer linking out to these APIs.
– Above that, the Domain layer sits as a mediator presenting business logic.
– The UI and ViewModel layers sit at the top as the interaction point with users.
– The DI layer can be shown as a “glue” element (or a separate module on the side) that provides dependency wiring across layers.

##### Important Reminders for the Principal Software Engineer
- Every component is clearly segmented and labeled.
- Keep annotations concise but informative — focus on showing how the MVVM pattern, clean architecture, and dependency injection bring all parts together.
- Asynchronous data handling via Kotlin Coroutines & Flow where appropriate.
- Optionally, indicate test components to show how the application’s functionality is verified.

## Diagram (Mermaid)

```mermaid
graph TD
    %% UI Layer
    subgraph "UI Layer"
        UI_Screens["Screens & Custom Views"]:::ui
        UI_Theming["Theming"]:::ui
        MainActivity["Main Activity"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        ViewModels["ViewModels"]:::vm
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Domain_Models["Domain Models"]:::domain
        UseCases["Use Cases"]:::domain
        RepoInterfaces["Repository Interfaces"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        API_Clients["API Clients"]:::data
        Data_Models["Data Models"]:::data
        RepoImpl["Repository Implementations"]:::data
        Paging_Sources["Paging Sources"]:::data
        Data_Services["Data Services"]:::data
    end

    %% Dependency Injection Layer
    subgraph "DI Layer"
        DI["DI Module"]:::di
    end

    %% External APIs
    subgraph "External APIs"
        BallDontLie["Ball Don't Lie API"]:::external
        Unsplash["Unsplash API"]:::external
    end

    %% Relationships between layers
    UI_Screens -->|"calls"| ViewModels
    UI_Theming -->|"calls"| ViewModels
    MainActivity -->|"calls"| ViewModels

    ViewModels -->|"calls"| UseCases

    UseCases -->|"calls"| RepoInterfaces

    RepoImpl -->|"implements"| RepoInterfaces
    RepoImpl -->|"uses"| API_Clients
    RepoImpl -->|"uses"| Paging_Sources
    RepoImpl -->|"uses"| Data_Services

    API_Clients -->|"integrates"| BallDontLie
    API_Clients -->|"integrates"| Unsplash

    DI -->|"wires"| UI_Screens
    DI -->|"wires"| ViewModels
    DI -->|"wires"| UseCases
    DI -->|"wires"| RepoImpl

    %% Click Events
    click UI_Screens "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/ui/view"
    click UI_Theming "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/ui/theme"
    click MainActivity "https://github.com/dedulka22/nba-app/blob/main/app/src/main/java/com/example/nbaapp/MainActivity.kt"
    click ViewModels "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/ui/viewmodel"
    click Domain_Models "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/domain/model"
    click UseCases "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/domain/usecase"
    click RepoInterfaces "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/domain/repository"
    click API_Clients "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/data/api"
    click Data_Models "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/data/model"
    click RepoImpl "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/data/repository"
    click Paging_Sources "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/data/paging"
    click Data_Services "https://github.com/dedulka22/nba-app/tree/main/app/src/main/java/com/example/nbaapp/data/service"
    click DI "https://github.com/dedulka22/nba-app/blob/main/app/src/main/java/com/example/nbaapp/di/appModule.kt"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef vm fill:#A3E4D7,stroke:#1D8348,stroke-width:2px;
    classDef domain fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef data fill:#F5B7B1,stroke:#943126,stroke-width:2px;
    classDef di fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
```
