# shoheitakino/pokemonappwithswiftuimvvm architecture

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

- Interactive diagram: https://gitdiagram.com/shoheitakino/pokemonappwithswiftuimvvm
- Repository: https://github.com/shoheitakino/pokemonappwithswiftuimvvm

## Overview

##### Project Overview & Type
- This is an iOS mobile application developed in Swift using SwiftUI.
- The architecture follows MVVM augmented with a centralized “Store” (or Dispatcher) pattern to manage data throughout the session.
- The purpose is to fetch Pokémon data through an API and hold it in a single data source, ensuring a consistent and unified state across the app.

##### Analyzing the File Structure
- APIClient: Contains network-handling components such as FetchPokemonData.swift, PokemonApiClient.swift, and a subdirectory “Model” that defines the API’s response formats.
- Core & Entity: “Core” (e.g., Constants.swift) holds constant values used app-wide; “Entity” (e.g., PokemonEntity.swift) defines data models.
- PokemonDispatcher: Implements state management components like PokemonFavoriteDispatcher, PokemonFavoriteStore, and PokemonStore. This layer is the “store” that maintains the single source of truth for the application.
- Presentation: Contains multiple subfolders for various screens (LaunchScreen, MainTab, PokemonList, PokemonDetail, PokemonLazyVGrid, and FavoritePokemonList) along with their corresponding ViewModels. The entry point for the app is also under MainTab.
- ViewModel: Contains additional shared ViewModel logic (such as PokemonDataViewModel.swift).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer - Views"
        LS_View("LaunchScreen View"):::presentation
        MT_View("Main Tab View"):::presentation
        PL_View("Pokemon List View"):::presentation
        PD_View("Pokemon Detail View"):::presentation
        PLazyVgrid_View("Pokemon LazyVGrid View"):::presentation
        FPL_View("Favorite Pokemon List View"):::presentation
    end

    subgraph "Presentation Layer - ViewModels"
        LS_VM("LaunchScreen ViewModel"):::viewModel
        MT_VM("Main Tab ViewModel"):::viewModel
        PL_VM("Pokemon List ViewModel"):::viewModel
        PD_VM("Pokemon Detail ViewModel"):::viewModel
        PLazyVgrid_VM("Pokemon LazyVGrid ViewModel"):::viewModel
        FPL_VM("Favorite Pokemon List ViewModel"):::viewModel
        Shared_VM("Pokemon Data ViewModel"):::viewModel
    end

    subgraph "Dispatcher/Store"
        Dispatcher("Pokemon Dispatcher/Store"):::dispatcher
    end

    subgraph "API Client"
        APIClient("APIClient"):::api
        APIModel("PokemonResponse (API Model)"):::api
    end

    subgraph "Core & Entities"
        CoreConstants("Constants (Core)"):::core
        Entity("PokemonEntity"):::core
    end

    %% Relationships: Views to ViewModels
    LS_View --> LS_VM
    MT_View --> MT_VM
    PL_View --> PL_VM
    PD_View --> PD_VM
    PLazyVgrid_View --> PLazyVgrid_VM
    FPL_View --> FPL_VM

    %% Relationships: ViewModels to Dispatcher/Store
    LS_VM -->|"update"| Dispatcher
    MT_VM -->|"update"| Dispatcher
    PL_VM -->|"update"| Dispatcher
    PD_VM -->|"update"| Dispatcher
    PLazyVgrid_VM -->|"update"| Dispatcher
    FPL_VM -->|"update"| Dispatcher
    Shared_VM -->|"update"| Dispatcher

    %% Relationships: ViewModels trigger API fetches
    LS_VM -->|"fetch"| APIClient
    MT_VM -->|"fetch"| APIClient
    PL_VM -->|"fetch"| APIClient
    PD_VM -->|"fetch"| APIClient
    PLazyVgrid_VM -->|"fetch"| APIClient
    FPL_VM -->|"fetch"| APIClient
    Shared_VM -->|"fetch"| APIClient

    %% Relationships: API Client processing and updating store
    APIClient -->|"parse"| APIModel
    APIClient -->|"updateStore"| Dispatcher

    %% Relationships: Dispatcher notifies ViewModels
    Dispatcher -->|"notify"| LS_VM
    Dispatcher -->|"notify"| MT_VM
    Dispatcher -->|"notify"| PL_VM
    Dispatcher -->|"notify"| PD_VM
    Dispatcher -->|"notify"| PLazyVgrid_VM
    Dispatcher -->|"notify"| FPL_VM
    Dispatcher -->|"notify"| Shared_VM

    %% Relationships: Dispatcher uses Core & Entity
    Dispatcher -.->|"uses"| CoreConstants
    Dispatcher -.->|"uses"| Entity

    %% Click Events
    click APIClient "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/tree/main/PokemonAppWithSwiftUIMVVM/APIClient"
    click APIModel "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/APIClient/Model/PokemonResponse.swift"
    click CoreConstants "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Core/Constants.swift"
    click Entity "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Entity/PokemonEntity.swift"
    click Dispatcher "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/tree/main/PokemonAppWithSwiftUIMVVM/PokemonDispatcher"
    click LS_View "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/LounchScreen/LaunchScreenView.swift"
    click LS_VM "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/LounchScreen/LaunchScreenViewModel.swift"
    click MT_View "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/MainTab/MainTabView.swift"
    click MT_VM "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/MainTab/MainTabViewModel.swift"
    click PL_View "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/PokemonList/PokemonListView.swift"
    click PL_VM "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/PokemonList/PokemonListViewModel.swift"
    click PD_View "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/PokemonDetail/PokemonDetailView.swift"
    click PD_VM "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/PokemonDetail/PokemonDetailViewModel.swift"
    click PLazyVgrid_View "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/PokemonLazyVGrid/PokemonLazyVGridView.swift"
    click PLazyVgrid_VM "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/PokemonLazyVGrid/PokemonLazyVGridViewModel.swift"
    click FPL_View "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/FavoritePokemonList/FavoritePokemonListView.swift"
    click FPL_VM "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/Presentation/FavoritePokemonList/FavoritePokemonListViewModel.swift"
    click Shared_VM "https://github.com/shoheitakino/pokemonappwithswiftuimvvm/blob/main/PokemonAppWithSwiftUIMVVM/ViewModel/PokemonDataViewModel.swift"

    %% Class Styles
    classDef presentation fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef viewModel fill:#90caf9,stroke:#0d47a1,stroke-width:2px;
    classDef dispatcher fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
    classDef api fill:#a5d6a7,stroke:#1b5e20,stroke-width:2px;
    classDef core fill:#e0e0e0,stroke:#424242,stroke-width:2px;
```
