# wangtzuh/goat_challenge architecture

> Architecture diagram of the GitHub repository wangtzuh/goat_challenge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wangtzuh/goat_challenge
- Repository: https://github.com/wangtzuh/goat_challenge

## Overview

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: [`Goat_Challenge/Goat_Challenge/Gateways/API/Gateway/APIOpenWeatherGateway.swift`](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Gateway/APIOpenWeatherGateway.swift) (API Gateway), [`Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomePresenter.swift`](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomePresenter.swift) (Home Presenter), [`Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeConfigurator.swift`](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeConfigurator.swift) (Home Config), [`Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeViewController.swift`](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeViewController.swift) (Home VC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App Shell"]
  node_app_delegate["AppDelegate<br/>app entry<br/>[AppDelegate.swift]"]
  node_scene_delegate["SceneDelegate<br/>scene entry"]
  node_root_nav["Root Nav<br/>navigation shell"]
end

subgraph group_group_scenes["Scenes"]
  node_home_config["Home Config<br/>scene assembler"]
  node_home_vc["Home VC<br/>presentation controller"]
  node_home_view["Home View<br/>scene view"]
  node_home_presenter["Home Presenter<br/>ui logic"]
  node_detail_config["Detail Config<br/>scene assembler"]
  node_detail_vc["Detail VC<br/>presentation controller"]
  node_detail_view["Detail View<br/>scene view"]
  node_detail_presenter["Detail Presenter<br/>ui logic"]
end

subgraph group_group_core["Core"]
  node_current_weather["Current Weather<br/>domain model"]
  node_fetch_usecase["Fetch Weather<br/>use case"]
  node_gateway_port["Weather Gateway<br/>gateway protocol"]
end

subgraph group_group_infra["Infrastructure"]
  node_api_gateway["API Gateway<br/>remote gateway"]
  node_api_client["API Client<br/>network client<br/>[APIClient.swift]"]
  node_api_route["API Route<br/>request spec<br/>[APIRoute.swift]"]
  node_api_config["API Config<br/>network config"]
  node_api_response["API Response<br/>network result<br/>[APIResponse.swift]"]
  node_api_weather_data["API Weather<br/>remote payload"]
  node_location_mgr["Location Manager<br/>platform service"]
  node_location_data["Location Data<br/>value object<br/>[LocationData.swift]"]
  node_date_util["Date Util<br/>shared helper<br/>[DateUtil.swift]"]
end

node_app_delegate -->|"boots"| node_scene_delegate
node_scene_delegate -->|"creates"| node_root_nav
node_root_nav -->|"starts"| node_home_config
node_home_config -->|"assembles"| node_home_vc
node_home_config -->|"injects"| node_home_presenter
node_home_vc -->|"renders"| node_home_view
node_home_presenter -->|"requests"| node_fetch_usecase
node_home_presenter -->|"maps"| node_current_weather
node_fetch_usecase -->|"depends on"| node_gateway_port
node_gateway_port -->|"implemented by"| node_api_gateway
node_api_gateway -->|"uses"| node_api_client
node_api_gateway -->|"builds"| node_api_route
node_api_gateway -->|"reads"| node_api_config
node_api_gateway -->|"decodes"| node_api_response
node_api_gateway -->|"transforms"| node_api_weather_data
node_home_presenter -->|"subscribes"| node_location_mgr
node_location_mgr -->|"emits"| node_location_data
node_detail_config -->|"assembles"| node_detail_vc
node_detail_config -->|"injects"| node_detail_presenter
node_detail_vc -->|"renders"| node_detail_view
node_detail_presenter -->|"reads"| node_current_weather
node_detail_presenter -->|"formats"| node_date_util
node_home_vc -->|"navigates"| node_detail_config

click node_app_delegate "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/AppDelegate.swift"
click node_scene_delegate "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/SceneDelegate.swift"
click node_root_nav "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/RootNavigationController.swift"
click node_home_config "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeConfigurator.swift"
click node_home_vc "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeViewController.swift"
click node_home_view "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeView.swift"
click node_home_presenter "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomePresenter.swift"
click node_detail_config "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherConfigurator.swift"
click node_detail_vc "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherViewController.swift"
click node_detail_view "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherView.swift"
click node_detail_presenter "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherPresenter.swift"
click node_current_weather "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Core/Entity/CurrentWeather.swift"
click node_fetch_usecase "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Core/Entity/FetchOpenWeatherOneCallUsecase.swift"
click node_gateway_port "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Core/OpenWeatherGateway.swift"
click node_api_gateway "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Gateway/APIOpenWeatherGateway.swift"
click node_api_client "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIClient.swift"
click node_api_route "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIRoute.swift"
click node_api_config "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIConfiguration.swift"
click node_api_response "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIResponse.swift"
click node_api_weather_data "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Entity/APIWeatherData.swift"
click node_location_mgr "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/System/LocationManager/GCLocationManager.swift"
click node_location_data "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/System/LocationManager/LocationData.swift"
click node_date_util "https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Utils/DateUtil.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_delegate,node_scene_delegate,node_root_nav toneBlue
class node_home_config,node_home_vc,node_home_view,node_home_presenter,node_detail_config,node_detail_vc,node_detail_view,node_detail_presenter toneAmber
class node_current_weather,node_fetch_usecase,node_gateway_port toneMint
class node_api_gateway,node_api_client,node_api_route,node_api_config,node_api_response,node_api_weather_data,node_location_mgr,node_location_data,node_date_util toneRose
```

## Components

### App Shell

Process startup and root navigation.

- [AppDelegate](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/AppDelegate.swift): app entry · Application bootstrap and lifecycle hook · `Goat_Challenge/Goat_Challenge/AppDelegate.swift`
- [SceneDelegate](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/SceneDelegate.swift): scene entry · Window and scene setup · `Goat_Challenge/Goat_Challenge/SceneDelegate.swift`
- [Root Nav](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/RootNavigationController.swift): navigation shell · Main navigation container · `Goat_Challenge/Goat_Challenge/Scenes/RootNavigationController.swift`

### Scenes

Presentation layer using MVP per screen.

- [Home Config](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeConfigurator.swift): scene assembler · Wires the current weather scene · `Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeConfigurator.swift`
- [Home VC](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeViewController.swift): presentation controller · Coordinates lifecycle and table interactions · `Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeViewController.swift`
- [Home View](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeView.swift): scene view · Weather list layout and display · `Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomeView.swift`
- [Home Presenter](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomePresenter.swift): ui logic · Fetches and shapes weather state · `Goat_Challenge/Goat_Challenge/Scenes/CurrentWeather/WeatherHomePresenter.swift`
- [Detail Config](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherConfigurator.swift): scene assembler · Wires the detail scene · `Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherConfigurator.swift`
- [Detail VC](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherViewController.swift): presentation controller · Coordinates detail display · `Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherViewController.swift`
- [Detail View](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherView.swift): scene view · Granular weather layout · `Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherView.swift`
- [Detail Presenter](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherPresenter.swift): ui logic · Prepares detailed weather state · `Goat_Challenge/Goat_Challenge/Scenes/DetailInformation/DetailWeatherPresenter.swift`

### Core

Domain models and use case contracts.

- [Current Weather](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Core/Entity/CurrentWeather.swift): domain model · Primary weather data shown in UI · `Goat_Challenge/Goat_Challenge/Core/Entity/CurrentWeather.swift`
- [Fetch Weather](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Core/Entity/FetchOpenWeatherOneCallUsecase.swift): use case · Retrieves one-call weather data · `Goat_Challenge/Goat_Challenge/Core/Entity/FetchOpenWeatherOneCallUsecase.swift`
- [Weather Gateway](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Core/OpenWeatherGateway.swift): gateway protocol · Core abstraction for weather data access · `Goat_Challenge/Goat_Challenge/Core/OpenWeatherGateway.swift`

### Infrastructure

Networking, location, and shared utilities.

- [API Gateway](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Gateway/APIOpenWeatherGateway.swift): remote gateway · Concrete OpenWeather implementation · `Goat_Challenge/Goat_Challenge/Gateways/API/Gateway/APIOpenWeatherGateway.swift`
- [API Client](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIClient.swift): network client · Reusable HTTP request execution · `Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIClient.swift`
- [API Route](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIRoute.swift): request spec · Endpoint and request definition · `Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIRoute.swift`
- [API Config](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIConfiguration.swift): network config · Base configuration for API calls · `Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIConfiguration.swift`
- [API Response](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIResponse.swift): network result · Shared response envelope · `Goat_Challenge/Goat_Challenge/Gateways/API/Network/APIResponse.swift`
- [API Weather](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Gateways/API/Entity/APIWeatherData.swift): remote payload · OpenWeather-facing response model · `Goat_Challenge/Goat_Challenge/Gateways/API/Entity/APIWeatherData.swift`
- [Location Manager](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/System/LocationManager/GCLocationManager.swift): platform service · Wraps device location access · `Goat_Challenge/Goat_Challenge/System/LocationManager/GCLocationManager.swift`
- [Location Data](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/System/LocationManager/LocationData.swift): value object · Location coordinates and metadata · `Goat_Challenge/Goat_Challenge/System/LocationManager/LocationData.swift`
- [Date Util](https://github.com/wangtzuh/goat_challenge/blob/main/Goat_Challenge/Goat_Challenge/Utils/DateUtil.swift): shared helper · Date and time formatting helper · `Goat_Challenge/Goat_Challenge/Utils/DateUtil.swift`

## Connections

- 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
