How jaomelodev/pokedexswiftui works
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