# myofficework000/jetmvi-template architecture

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

- Interactive diagram: https://gitdiagram.com/myofficework000/jetmvi-template
- Repository: https://github.com/myofficework000/jetmvi-template

## Overview

##### Project type and purpose
- This is a native Android application (“GitHubCompose”) built as a production-grade reference app to showcase Jetpack Compose, MVI, Clean Architecture, Coroutine/Flow, Koin DI, Retrofit networking, Coil image loading, and TDD.
- It follows a single-activity MVI pattern with clearly separated View, Presentation (ViewModel), and Model (Repository) layers.

##### File structure
- Top-level “app” module contains everything Android: source, resources, manifest, Gradle config.
- Under `app/src/main/java/com/…/githubcompose/` you find packages:
- `data` – Retrofit API interface, endpoints constants, repository interface & implementation, data models
- `di` – Koin modules (AppModule, RepositoryModule, ViewModelModule)
- `ui` – Composable screens grouped by feature (`users`, `repos`, `main`), base classes, common widgets, theme, navigation
- `common` – extensions and utility classes
- Tests mirror the same packages under `app/src/test` and `androidTest`.
- `buildSrc` holds centralized versions and dependencies.

##### README for additional insights
- Confirms MVI: each screen defines a State, Events, Effects contract.
- Single-activity navigation via Jetpack Navigation component.
- Uses Kotlin coroutines & Flow for async, Koin for DI, Retrofit for networking.

##### Main system components and their relationships
a. Components
- **Android Host**: `GithubApplication` + `MainActivity` + NavController
- **UI Layer**: Composable screens (`UsersScreen`, `ReposScreen`, etc.)
- **Presentation Layer**: Screen-scoped ViewModels managing State, receiving Events, emitting Effects
- **Domain/Data Layer**: `GithubRepository` interface and `GithubRepositoryImpl`
- **Networking**: Retrofit service (`GithubApi`), Endpoints
- **Dependency Injection**: Koin modules wiring ViewModels → Repositories → API
- **External Service**: GitHub REST API
- **Utilities**: Coil loader, Intent extensions, themes

b. Interactions/data flow
1. User interaction in a Composable UI emits an **Event**
2. Event is sent into its ViewModel’s Event Flow
3. ViewModel updates **State** (StateFlow / Compose MutableState) and/or triggers **Effects** (ChannelFlow)
4. On data requests, ViewModel calls a method on `GithubRepository`
5. `GithubRepositoryImpl` uses `GithubApi` (Retrofit) to fetch JSON, maps to domain models, returns Flow
6. ViewModel collects the Flow, updates State → UI

c. Architectural patterns
- Unidirectional data flow (MVI)
- Single‐Activity Navigation
- Clean Architecture layering: UI → ViewModel → Repository → RemoteDataSource
- DI inversion via Koin

d. Key technologies/frameworks
- Jetpack Compose, Navigation, ViewModel
- Kotlin Coroutines & Flow
- Retrofit + OkHttp
- Coil (image loading)
- Koin (DI)
- JUnit + MockWebServer for TDD

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        A["GithubApplication"]:::ui
        B["MainActivity"]:::ui
        C["NavHost"]:::ui
        D["AppNavigation"]:::ui
        E["UsersScreen"]:::ui
        F["UsersList"]:::ui
        G["UsersListItem"]:::ui
        H["UsersListHeader"]:::ui
        I["UsersTopBar"]:::ui
        J["ReposScreen"]:::ui
        K["ReposList"]:::ui
        L["ReposListItem"]:::ui
        M["ReposListHeader"]:::ui
        N["ReposTopBar"]:::ui
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        UV["UsersViewModel\n(State, Event, Effect)"]:::presentation
        RV["ReposViewModel\n(State, Event, Effect)"]:::presentation
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RepoInt["GithubRepository"]:::data
        RepoImpl["GithubRepositoryImpl"]:::data
        API["GithubApi\n+ Endpoints"]:::data
    end

    %% Dependency Injection
    subgraph "Dependency Injection"
        direction TB
        AM["AppModule"]:::di
        RM["RepositoryModule"]:::di
        VM["ViewModelModule"]:::di
    end

    %% External Service
    GitHub["GitHub REST API"]:::external

    %% Connections
    A -->|"launches"| B
    B -->|"hosts"| C
    C -->|"uses"| D
    D -->|"navigates to"| E
    D -->|"navigates to"| J

    E -->|"Event →"| UV
    J -->|"Event →"| RV

    UV -->|"calls"| RepoInt
    RV -->|"calls"| RepoInt

    RepoInt -->|"implemented by"| RepoImpl
    RepoImpl -->|"Retrofit call"| API
    API -->|"HTTP"| GitHub
    API -->|"returns JSON"| RepoImpl
    RepoImpl -->|"Flow←"| UV
    RepoImpl -->|"Flow←"| RV

    %% DI wiring
    AM --> RM
    AM --> VM
    VM --> UV
    VM --> RV
    RM --> RepoImpl
    RM --> API

    %% Click Events
    click A "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/GithubApplication.kt"
    click B "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/main/MainActivity.kt"
    click E "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/users/composables/UsersScreen.kt"
    click F "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/users/composables/UsersList.kt"
    click G "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/users/composables/UsersListItem.kt"
    click H "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/users/composables/UsersListHeader.kt"
    click I "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/users/composables/UsersTopBar.kt"
    click J "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/repos/composables/ReposScreen.kt"
    click K "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/repos/composables/ReposList.kt"
    click L "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/repos/composables/ReposListItem.kt"
    click M "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/repos/composables/ReposListHeader.kt"
    click N "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/repos/composables/ReposTopBar.kt"
    click D "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/navigation/AppNavigation.kt"
    click UV "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/users/UsersViewModel.kt"
    click RV "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/ui/feature/repos/ReposViewModel.kt"
    click RepoInt "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/data/GithubRepository.kt"
    click RepoImpl "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/data/GithubRepositoryImpl.kt"
    click API "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/data/GithubApi.kt"
    click RM "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/di/RepositoryModule.kt"
    click VM "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/di/ViewModelModule.kt"
    click AM "https://github.com/myofficework000/jetmvi-template/blob/master/app/src/main/java/com/abhishek/pathak/kotlin/android/githubcompose/di/AppModule.kt"

    %% Styles
    classDef ui fill:#2196f3,stroke:#1e88e5,color:#fff
    classDef presentation fill:#4caf50,stroke:#388e3c,color:#fff
    classDef data fill:#ffeb3b,stroke:#fbc02d,color:#000
    classDef di fill:#ff9800,stroke:#f57c00,color:#000
    classDef external fill:#9e9e9e,stroke:#616161,color:#fff
```
