How wangtzuh/goat_challenge works
1. Overall shape
- This is an iOS app built in UIKit with a Clean Architecture + MVP split.
- The codebase is organized into three major boundaries: Scenes (presentation), Core (application/domain contracts), and Gateways/System (infrastructure and platform services).
2. App entry and composition
- AppDelegate and SceneDelegate handle app startup.
- RootNavigationController is the main navigation container, so the app is organized as a navigation-based flow rather than a tabbed or multi-window UI.
- WeatherHomeConfigurator and DetailWeatherConfigurator are the wiring points that assemble each scene’s dependencies.
3. Presentation layer: scene-based MVP
- Each screen has its own scene folder under Scenes/.
- The presentation layer is split into View, ViewController, Presenter, and Configurator, which makes the UI a thin rendering layer and pushes behavior into presenters.
- The View types are UIKit-backed classes/protocols focused on layout and display, while presenters own the interaction logic.
4. Current Weather scene
- Scenes/CurrentWeather is the main screen that displays weather data in a UITableView.
- WeatherHomeViewController coordinates lifecycle and table interactions.
- WeatherHomeView handles the screen layout, and the table uses custom UI pieces like WeatherTableHeaderView and DailyWeatherForcastCell.
- WeatherHomePresenter drives fetching and transforms model data into UI state.
5. Detail Information scene
- Scenes/DetailInformation is a secondary screen for showing more granular weather data.
- It follows the same MVP pattern with DetailWeatherViewController, DetailWeatherView, DetailWeatherPresenter, and DetailWeatherConfigurator.
- DetailInfoCell suggests the detail screen is table-driven or list-driven as well.
6. Core application layer
- Core/Entity contains the app’s domain-facing models and use case contracts.
- CurrentWeather.swift is the central model used for what the UI displays.
- FetchOpenWeatherOneCallUsecase.swift represents the application logic for retrieving weather data.
- OpenWeatherGateway.swift is the abstraction boundary the use case depends on, keeping the core independent from networking details.
7. Infrastructure: weather API gateway
- Gateways/API/Gateway/APIOpenWeatherGateway.swift is the concrete implementation that talks to OpenWeather.
- The APIClient, APIRoute, APIConfiguration, and APIResponse types form a reusable networking stack underneath the gateway.
- APIWeatherData.swift is the API-facing payload model, distinct from the core CurrentWeather model, which indicates a mapping layer between remote data and app domain data.
- mock.json suggests the gateway can be backed by sample payloads for development or testing.
8. System services: location
- System/LocationManager is a separate platform boundary for acquiring device location.
- GCLocationManager and GCLocationManagerDelegate encapsulate Core Location-style behavior and likely feed coordinates into the weather-fetch flow.
- LocationData is the value object used to pass location information around without exposing platform-specific objects everywhere.
9. Shared utilities
- Utils/DateUtil.swift is a small shared helper layer, likely used to format timestamps, dates, or forecast labels for display.
- This indicates formatting concerns are kept out of presenters and views where possible.
10. External dependencies and tech choices
- The app uses Alamofire for HTTP networking, AlamofireImage for image loading/caching, and SnapKit for programmatic Auto Layout.
- These libraries materially shape the architecture: networking is centralized in gateway/client types, images can be loaded asynchronously, and layouts are likely code-based rather than storyboard-driven.
11. Primary data flow
- Device location is obtained via GCLocationManager.
- The current-weather use case requests data through the OpenWeatherGateway abstraction.
- APIOpenWeatherGateway uses the API client stack to call OpenWeather, maps the response into app models, and returns them to the presenter.
- The presenter updates the view controller/view layer, which renders the table and detail UI.
- Navigation likely moves from the current weather list into the detail scene, carrying selected weather data.
12. Project maturity / boundaries not yet implemented
- The README explicitly calls out missing unit tests, local persistence, and fuller error handling.
- There is no persistence subsystem yet, so the architecture currently stops at remote API + location + UI, with no database or offline cache boundary in place.
Main entry points: APIOpenWeatherGateway.swift API Gateway · WeatherHomePresenter.swift Home Presenter · WeatherHomeConfigurator.swift Home Config · WeatherHomeViewController.swift Home VC
Components 23
App Shell
Process startup and root navigation.
- AppDelegate · Application bootstrap and lifecycle hook
Goat_Challenge/Goat_Challenge/AppDelegate.swift - SceneDelegate · Window and scene setup
Goat_Challenge/Goat_Challenge/SceneDelegate.swift - Root Nav · Main navigation container
Goat_Challenge/Goat_Challenge/Scenes/RootNavigationController.swift
Scenes
Presentation layer using MVP per screen.
- Home Config · Wires the current weather scene
Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeConfigurator.swift - Home VC · Coordinates lifecycle and table interactions
Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeViewController.swift - Home View · Weather list layout and display
Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeView.swift - Home Presenter · Fetches and shapes weather state
Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomePresenter.swift - Detail Config · Wires the detail scene
Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherConfigurator.swift - Detail VC · Coordinates detail display
Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherViewController.swift - Detail View · Granular weather layout
Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherView.swift - Detail Presenter · Prepares detailed weather state
Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherPresenter.swift
Core
Domain models and use case contracts.
- Current Weather · Primary weather data shown in UI
Goat_Challenge/Goat_Challenge/Core/Entity/CurrentWeather.swift - Fetch Weather · Retrieves one-call weather data
Goat_Challenge/Goat_Challenge/Core/Entity/FetchOpenWeatherOneCallUsecase.swift - Weather Gateway · Core abstraction for weather data access
Goat_Challenge/Goat_Challenge/Core/OpenWeatherGateway.swift
Infrastructure
Networking, location, and shared utilities.
- API Gateway · Concrete OpenWeather implementation
Goat_Challenge/Goat_Challenge/Gateways/API/Gateway/APIOpenWeatherGateway.swift - API Client · Reusable HTTP request execution
Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIClient.swift - API Route · Endpoint and request definition
Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIRoute.swift - API Config · Base configuration for API calls
Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIConfiguration.swift - API Response · Shared response envelope
Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIResponse.swift - API Weather · OpenWeather-facing response model
Goat_Challenge/Goat_Challenge/Gateways/API/Entity/APIWeatherData.swift - Location Manager · Wraps device location access
Goat_Challenge/Goat_Challenge/System/LocationManager/GCLocationManager.swift - Location Data · Location coordinates and metadata
Goat_Challenge/Goat_Challenge/System/LocationManager/LocationData.swift - Date Util · Date and time formatting helper
Goat_Challenge/Goat_Challenge/Utils/DateUtil.swift
Connections 23
- AppDelegate → SceneDelegate: boots · App lifecycle hands off to scene setup
- SceneDelegate → Root Nav: creates · Scene delegate installs the root navigation flow
- Root Nav → Home Config: starts · Initial flow enters the current weather scene
- Home Config → Home VC: assembles · Configurator builds the home screen stack
- Home Config → Home Presenter: injects · Wires presenter dependencies
- Home VC → Home View: renders · View controller drives the UIKit view
- Home Presenter → Fetch Weather: requests · Presenter triggers weather retrieval through the use case
- Home Presenter → Current Weather: maps · Presenter consumes domain weather state
- Fetch Weather → Weather Gateway: depends on · Use case works against the gateway abstraction
- Weather Gateway → API Gateway: implemented by · Infrastructure provides the concrete gateway
- API Gateway → API Client: uses · Gateway delegates HTTP execution to the client
- API Gateway → API Route: builds · Gateway selects request endpoints
- API Gateway → API Config: reads · Gateway uses shared API configuration
- API Gateway → API Response: decodes · Gateway interprets transport responses
- API Gateway → API Weather: transforms · Remote payload is mapped into app-facing data
- Home Presenter → Location Manager: subscribes · Presenter gets device location for weather lookup
- Location Manager → Location Data: emits · Location manager produces a neutral value object
- Detail Config → Detail VC: assembles · Configurator builds the detail scene stack
- Detail Config → Detail Presenter: injects · Wires detail presenter dependencies
- Detail VC → Detail View: renders · View controller drives the detail view
- Detail Presenter → Current Weather: reads · Detail presenter consumes selected weather data
- Detail Presenter → Date Util: formats · Helper formats dates and labels for display
- Home VC → Detail Config: navigates · Selection moves from list to detail scene