# jaomelodev/pokedexswiftui architecture

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

- Interactive diagram: https://gitdiagram.com/jaomelodev/pokedexswiftui
- Repository: https://github.com/jaomelodev/pokedexswiftui

## Overview

##### Project type and purpose
- This is a native iOS client application built with SwiftUI.
- It fetches Pokémon data from an external GraphQL API (PokéAPI) using Apollo Client, then displays lists by generation and detailed views.
- Key indicators: “PokedexApp.swift”, “ApolloClient.swift”, GraphQL schema and operations, SwiftUI views under “Home” and “Pokemon” modules.

##### File structure
- Top-level modules:
- App – app entry point, common UI components, shared extensions, utilities, styles.
- Home – feature module for the generation‐based listing screen (Domain→Presentation→Views).
- Pokemon – feature module for the detailed Pokémon page (Domain→UseCases→Presentation).
- Network – Apollo GraphQL client setup, generated GraphQL operations and schema.
- Tests – unit/UI test targets.
- Layered patterns:
- Presentation layer – SwiftUI views and controllers (“HomeController.swift”, “PokemonPage.swift”).
- Domain layer – enterprise business logic entities and use-case interfaces.
- Data layer – DataSource protocols and implementations that drive network calls.
- Infrastructure – GraphQL client, codegen schema, external HTTP.
- Deployment config:
- Podfile/Podfile.lock – manages Apollo and other CocoaPods.
- Xcode workspace & project files.

##### Pulling insights from README
- Uses Swift, SwiftUI, Xcode, GraphQL via Apollo.
- Goal: interactive Pokédex with generation filters and detail pages.

a. Main components
- iOS Application
– Presentation Layer (SwiftUI views, Controllers)
– Domain Layer (Use Cases, Entities)
– Data Layer (DataSources, DTOs)
– Shared UI Components & Utilities
- Apollo GraphQL Client
- External Service: PokéAPI GraphQL endpoint
- Local Resources: Assets catalog, Fonts
- Test harnesses (unit and UI tests)
b. Relationships and interactions
1. User taps UI → Presentation Controller processes event
2. Controller invokes Use Case (e.g., GetPokemonsByGenerationUseCase)
3. Use Case calls DataSource protocol (PokemonDataSource)
4. DataSourceImpl uses ApolloClient to send GraphQL query
5. ApolloClient sends HTTP request to PokéAPI GraphQL server
6. JSON response is parsed into generated GraphQL types → mapped to Domain Entities
7. Entities flow back up: DataSource → Use Case → Presentation → UI
c. Architectural patterns & design principles
- Clean Architecture / Layered Architecture: strict separation of Presentation, Domain, Data, Infrastructure
- Dependency inversion: presentation depends on use-case protocols, data layer implements protocols
- MVVM-like flow: SwiftUI views bind to state in Controllers
- Code generation for type‐safe GraphQL
d. Key technologies
- SwiftUI (UI layer)
- Apollo iOS (GraphQL client, codegen)
- CocoaPods (dependency management)
- Xcode Workspaces/Projects

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        PokedexApp["PokedexApp"]:::presentation
        HomeView["HomeView"]:::presentation
        HomeController["HomeController"]:::presentation
        HomeViewComponents["Home View\nComponents"]:::presentation
        PokemonPage["PokemonPage"]:::presentation
        PokemonComponents["Pokemon\nComponents"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        FilterParametersEntity["FilterParametersEntity"]:::domain
        PokemonEntity["PokemonEntity"]:::domain
        PokemonAbilityEntity["PokemonAbilityEntity"]:::domain
        PokemonEvolutionEntity["PokemonEvolutionEntity"]:::domain
        PokemonStatEntity["PokemonStatEntity"]:::domain
        GetPokemonsByGenerationUseCase["GetPokemonsByGenerationUseCase"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        PokemonDataSourceProtocol["PokemonDataSource"]:::data
        PokemonDataSourceImpl["PokemonDataSourceImpl"]:::data
    end

    %% Infrastructure Layer
    subgraph "Infrastructure / Network"
        direction TB
        ApolloClient["ApolloClient"]:::infra
        GraphQLQueryFiles[".graphql Queries"]:::infra
        GeneratedOperations["Generated\nOperations & Schema"]:::infra
        SchemaFile["schema.graphqls"]:::infra
        PokeAPIQueries["PokeAPIQueries"]:::infra
        GraphQLHTTP["GraphQL HTTP\nTransport"]:::cloud
    end

    %% Resources
    subgraph "Resources"
        direction TB
        Assets["Assets.xcassets"]:::resource
        LaunchStoryboard["LaunchScreen.storyboard"]:::resource
        Fonts["Fonts"]:::resource
    end

    %% Tests
    subgraph "Test Harnesses"
        direction TB
        UnitTests["PokedexTests"]:::test
        UITests["PokedexUITests"]:::test
    end

    %% External Service
    subgraph "External Service"
        direction TB
        PokeAPI["PokéAPI GraphQL Endpoint"]:::external
    end

    %% Connections
    PokedexApp -->|uses| HomeView
    HomeView -->|binds to| HomeController
    HomeController -->|calls| GetPokemonsByGenerationUseCase
    GetPokemonsByGenerationUseCase -->|depends on| PokemonDataSourceProtocol
    PokemonDataSourceProtocol -->|implemented by| PokemonDataSourceImpl
    PokemonDataSourceImpl -->|uses| ApolloClient
    ApolloClient -->|executes| GraphQLQueryFiles
    GraphQLQueryFiles -->|codegen→| GeneratedOperations
    GeneratedOperations -->|schema defined in| SchemaFile
    ApolloClient -->|helper queries| PokeAPIQueries
    ApolloClient -->|sends over| GraphQLHTTP
    GraphQLHTTP -->|requests| PokeAPI
    Assets -->|consumed by| PokedexApp
    Fonts -->|used by| PokedexApp
    LaunchStoryboard -->|launches| PokedexApp
    UnitTests -->|test| HomeController
    UItests -->|test| HomeView

    %% Click Events
    click PokedexApp "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/PokedexApp.swift"
    click HomeView "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/Home/Presentation/Views/HomeView.swift"
    click HomeController "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/Home/Presentation/Controllers/HomeController.swift"
    click HomeViewComponents "https://github.com/jaomelodev/pokedexswiftui/tree/main/Pokedex/Home/Presentation/Views/Components/"
    click PokemonPage "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/Pokemon/Presentation/PokemonPage.swift"
    click PokemonComponents "https://github.com/jaomelodev/pokedexswiftui/tree/main/Pokedex/Pokemon/Presentation/Components/"
    click FilterParametersEntity "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/Home/Domain/Entities/FilterParemetersEntity.swift"
    click GetPokemonsByGenerationUseCase "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/Pokemon/Domain/UseCases/GetPokemonsByGenerationUseCase.swift"
    click PokemonDataSourceProtocol "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/Pokemon/Data/DataSources/PokemonDataSource.swift"
    click PokemonDataSourceImpl "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/Pokemon/Data/DataSources/PokemonDataSourceImpl.swift"
    click ApolloClient "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/App/Network/ApolloClient.swift"
    click GraphQLQueryFiles "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/App/Network/GraphQL/GetPokemonByGeneration.graphql"
    click GeneratedOperations "https://github.com/jaomelodev/pokedexswiftui/tree/main/Pokedex/App/Network/GraphQL/PokeAPI/"
    click SchemaFile "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/App/Network/GraphQL/schema.graphqls"
    click PokeAPIQueries "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/App/Network/PokeAPIQueries.swift"
    click Assets "https://github.com/jaomelodev/pokedexswiftui/tree/main/Pokedex/Resources/Assets.xcassets/"
    click LaunchStoryboard "https://github.com/jaomelodev/pokedexswiftui/blob/main/Pokedex/LaunchScreen.storyboard"
    click Fonts "https://github.com/jaomelodev/pokedexswiftui/tree/main/Pokedex/Resources/Fonts/"
    click UnitTests "https://github.com/jaomelodev/pokedexswiftui/blob/main/PokedexTests/PokedexTests.swift"
    click UITests "https://github.com/jaomelodev/pokedexswiftui/blob/main/PokedexUITests/PokedexUITests.swift"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef domain fill:#E4F9E0,stroke:#2E7D32,stroke-width:1px
    classDef data fill:#FFE5B4,stroke:#FF9100,stroke-width:1px
    classDef infra fill:#FFCCCB,stroke:#D32F2F,stroke-width:1px
    classDef cloud fill:#E0F7FA,stroke:#00838F,stroke-width:1px,stroke-dasharray: 5 5
    classDef resource fill:#F5F5F5,stroke:#9E9E9E,stroke-width:1px
    classDef test fill:#FFF3E0,stroke:#FB8C00,stroke-width:1px
    classDef external fill:#CFD8DC,stroke:#455A64,stroke-width:1px,shape:cylinder
```
