# pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent architecture

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

- Interactive diagram: https://gitdiagram.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent
- Repository: https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent

## Overview

##### Project type and purpose
- This is a single-module Android mobile application written in Kotlin.
- It demonstrates best practices for combining coroutines (for async work), Gson (for JSON parsing), RecyclerView (for list display), and Intent navigation between screens.
- Key features:
– MainActivity shows a list of items loaded from a local JSON resource.
– DetailActivity displays details for a selected item.
– Uses MVVM: MyViewModel mediates data between UI and data source.

##### File structure
Top-level
- build.gradle.kts, settings.gradle.kts, gradle wrapper – standard Android/Gradle config
- /app – Android application module
Under app/src/main/java/com/example/...
- MainActivity.kt – entry point with RecyclerView setup
- DetailActivity.kt – shows details of a tapped item
- MyViewModel.kt – holds LiveData/List of model objects
- MyDatabase/MyJsonClass.kt – data model class matching JSON schema
- MyDatabase/MyJsonString.json – embedded sample data
- MyRecyclerViewManager/MyAdapter.kt – RecyclerView adapter + view-holder
Under app/src/main/res
- layout/*.xml – UI layouts for list, item, and detail screens
- values, drawable, mipmap – standard resources
Tests in androidTest and test directories

##### README
- It contains an image only, no further textual architecture description.
- We infer architecture from source code patterns (MVVM + local data).

##### Elements
- Clear labels: MainActivity, DetailActivity, MyViewModel, JSON File, Adapter, Model Class
– from MainActivity to ViewModel (data request)
– from ViewModel to JSON file & back (async load)
– from ViewModel to MainActivity (LiveData update)
– from Adapter to DetailActivity (Intent navigation)
– Presentation (ViewModel) in another
– Data (JSON file, Model) in a third

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        MainActivity["MainActivity"]:::ui
        MainLayout["activity_main.xml"]:::ui
        Adapter["MyAdapter"]:::ui
        ItemLayout["activity_my_recyclerview_item.xml"]:::ui
        DetailActivity["DetailActivity"]:::ui
        DetailLayout["activity_info_detail.xml"]:::ui
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        MyViewModel["MyViewModel"]:::presentation
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        JSONFile["MyJsonString.json"]:::data
        ModelClass["MyJsonClass"]:::data
    end

    %% Third-Party Libraries
    subgraph "Third-Party Libraries"
        direction TB
        Coroutines["Kotlin Coroutines"]:::libs
        Gson["Gson"]:::libs
    end

    %% Connections
    MainActivity -->|"observes LiveData"| MyViewModel
    MyViewModel -->|"launch coroutine (IO dispatcher)"| Coroutines
    Coroutines -->|"read JSON file"| JSONFile
    JSONFile -->|"raw data"| Coroutines
    Coroutines -->|"parse JSON"| Gson
    Gson -->|"create Model instances"| ModelClass
    ModelClass -->|"data list"| MyViewModel
    MyViewModel -->|"post LiveData update"| MainActivity

    MainActivity -->|"binds list"| Adapter
    Adapter -->|"uses item layout"| ItemLayout
    MainActivity -->|"uses layout"| MainLayout

    Adapter -->|"onClick Intent(item ID)"| DetailActivity
    DetailActivity -->|"uses layout"| DetailLayout
    DetailActivity -->|"reads Intent extra & gets data"| MyViewModel

    %% Click Events
    click MainActivity "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/java/com/example/mypratice_mix_3_coroutine_gson_recyclerview_intent/MainActivity.kt"
    click DetailActivity "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/java/com/example/mypratice_mix_3_coroutine_gson_recyclerview_intent/DetailActivity.kt"
    click Adapter "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/java/com/example/mypratice_mix_3_coroutine_gson_recyclerview_intent/MyRecyclerViewManager/MyAdapter.kt"
    click MyViewModel "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/java/com/example/mypratice_mix_3_coroutine_gson_recyclerview_intent/MyViewModel.kt"
    click ModelClass "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/java/com/example/mypratice_mix_3_coroutine_gson_recyclerview_intent/MyDatabase/MyJsonClass.kt"
    click JSONFile "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/java/com/example/mypratice_mix_3_coroutine_gson_recyclerview_intent/MyDatabase/MyJsonString.json"
    click MainLayout "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/res/layout/activity_main.xml"
    click DetailLayout "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/res/layout/activity_info_detail.xml"
    click ItemLayout "https://github.com/pudcheetah/mypratice_mix_3_coroutine_gson_recyclerview_intent/blob/master/app/src/main/res/layout/activity_my_recyclerview_item.xml"

    %% Styles
    classDef ui fill:#f0f8ff,stroke:#333,stroke-width:1px
    classDef presentation fill:#e6ffe6,stroke:#333,stroke-width:1px
    classDef data fill:#fff0f5,stroke:#333,stroke-width:1px
    classDef libs fill:#ffffe0,stroke:#333,stroke-width:1px
```
