How ngletuan-dev/pokeapp-swiftui works
Project type and purpose
• This is a SwiftUI‐based iOS application (“PokéApp”) that fetches Pokémon data from an external RESTful service (https://pokeapi.co/) and displays it in a list. Users can search, favorite, and view details of Pokémon.
File structure
• Top‐level: Xcode project and workspace, Assets folder, README, tests.
• iOS_PokeApp folder subdivided by feature-layer:
• Model: data structures (PokeModel.swift)
• PokemonAPI: networking layer (Downloader.swift, LoadingAPI.swift, PokemonAPI.swift)
• ViewModel: MVVM presentation logic (PokeViewModel.swift, PokeDetailViewModel.swift, PokeEffectViewModel.swift)
• View: SwiftUI views (PokeView, PokemonViewDetail, AbilityView, etc.)
• App entry: iOS_PokeAppApp.swift
• Testing targets: unit and UI tests.
README for additional insights
• Confirms MVVM with SwiftUI (targeting iOS 15+)
• Relies on PokéAPI, no local database yet (favorites are in‐memory or ephemeral)
• Core flows: list all Pokémon, search by name, slide‐to‐favorite, view detail with stats and abilities.
Main components and interactions
a. Components
1. UI Layer (Views)
2. Presentation Layer (ViewModels)
3. Domain/Data Layer (Models + Networking)
4. External Service (PokéAPI REST)
5. (Optional future) Local Storage for favorites (e.g., UserDefaults or CoreData)
b. Relationships & Data Flow
• UI → binds to → ViewModel
• ViewModel → calls → PokemonAPI (via LoadingAPI/Downloader)
• PokemonAPI → performs HTTP GET → PokéAPI → returns JSON
• JSON → decoded into → PokeModel
• ViewModel → publishes → PokeModel to UI
• UI → renders → List, Detail, Search, Favorite toggle
c. Architectural patterns
• MVVM (Views ←→ ViewModels ←→ Models + Network)
• Single Activity/Coordinator pattern is implicit in App entry (iOS_PokeAppApp.swift)
• Dependency inversion: ViewModels depend on protocol abstractions of network loader
d. Key technologies
• SwiftUI (all UI components)
• Combine or async/await (depending on implementation in LoadingAPI/Downloader)
• URLSession for networking
• Codable for JSON parsing
Essential details to capture
• All SwiftUI views and their hierarchical relationship (List view, Detail view, subviews)
• ViewModel responsibilities and which API calls they make
• Model definitions for Pokémon entities and effects
• The networking flow from app → URLSession → PokéAPI → JSON → Codable → ViewModel → UI
• Where tests fit in (pointing at the ViewModel and Networking modules)