# sparta-nbcamp-ch3-advanced-team5/look-out-the-window architecture

> Architecture diagram of the GitHub repository sparta-nbcamp-ch3-advanced-team5/look-out-the-window, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window
- Repository: https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window

## Overview

##### Project type and purpose
- This is a native iOS weather‐forecast app called “Look‐out‐the‐window,” built in Swift and UIKit.
- It uses MVVM (Model–View–ViewModel) to fetch, persist, and present weather data (current, hourly, daily) and location information.

##### File structure
- Top‐level “Look-out-the-window” Xcode project and workspace.
- App folder: AppDelegate.swift and SceneDelegate.swift bootstrap the app.
- Data folder:
- CoreLocationManager for geolocation
- DTOs for parsing JSON responses
- Models for business data
- NetworkManager & APIEndpoints for REST calls
- CoreDataStorage for persistence
- Presentation folder (MVVM):
- Common (reusable views & compositional layout)
- RegionList, Register, WeatherDetail (each submodule has View, ViewController, ViewModel)
- Shared protocols, push notification center, extensions

##### Key architectural pattern
- MVVM with a Repository‐style Data layer.
- Single Scene architecture (UISceneSession).
- Asynchronous network calls and local caching via CoreData.
- CoreLocation service for live location.

##### Main components
a. App Shell
– AppDelegate & SceneDelegate (entry point, window setup, root navigation)
b. Presentation Layer (in green)
– Views & ViewControllers (RegionList, WeatherDetail, Register)
– ViewModels (RegionWeatherListViewModel, SearchResultViewModel, WeatherDetailViewModel, RegisterViewModel)
c. Data Layer (in blue)
– CoreLocationManager (location updates)
– NetworkManager + APIEndpoints (HTTP REST client)
– CoreDataStorage / CoreDataManager (local cache)
– DTO ↔ Model mappers
d. External Services (in gray)
– Third‐party Weather API (e.g., OpenWeatherMap)
– Push Notification Center
e. Resources (in orange)
– Rive Animations
– Asset Catalog

##### Relationships & data flow
1. User opens the app → SceneDelegate sets initial ViewController (RegionList)
2. ViewController binds to its ViewModel → requests location & weather data
3. ViewModel calls Data Layer:
– CoreLocationManager → returns CLLocation → ViewModel
– NetworkManager.fetch(WeatherEndpoint) → returns DTO → Model → ViewModel
– CoreDataManager.save(fetch result)
– CoreDataManager.load(cached data) on network failure
4. ViewModel updates ViewController via binding/delegation
5. For detail screens, NavigationController pushes WeatherDetailViewController
6. PushNotificationCenter registers for/handles remote notifications

##### Essential elements
- Component names (e.g., “NetworkManager”, “WeatherDetailViewModel”).
- Layers (Presentation, Data, External, Resources).
- Arrowheads showing call direction, callbacks, and data return paths.
- UI components (rounded corners)
- Services & managers (rectangles)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% App Shell
    subgraph "App Shell" 
        direction TB
        AppDelegate["AppDelegate"]:::appShell
        SceneDelegate["SceneDelegate"]:::appShell
    end

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        subgraph "RegionList Module"
            direction TB
            RegionWeatherListVC["RegionWeatherListViewController"]:::presentation
            RegionWeatherListVM["RegionWeatherListViewModel"]:::presentation
        end
        subgraph "WeatherDetail Module"
            direction TB
            WeatherDetailVC["WeatherDetailViewController"]:::presentation
            WeatherDetailVM["WeatherDetailViewModel"]:::presentation
        end
        subgraph "Register Module"
            direction TB
            RegisterVC["RegisterViewController"]:::presentation
            RegisterVM["RegisterViewModel"]:::presentation
        end
        subgraph "Common & Shared"
            direction TB
            BackgroundTopInfoView["BackgroundTopInfoView"]:::presentation
            ViewModelProtocol["ViewModelProtocol"]:::presentation
            PushNotificationCenter["PushNotificationCenter"]:::presentation
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        CoreLocationManager["CoreLocationManager"]:::data
        subgraph "Network Service"
            direction TB
            NetworkManager["NetworkManager"]:::data
            APIEndpoints["APIEndpoints"]:::data
        end
        subgraph "Persistence"
            direction TB
            CoreDataManager["CoreDataManager"]:::data
            CoreDataStorageModel["CoreDataStorage Model"]:::data
        end
        subgraph "DTOs & Models"
            direction TB
            CurrentWeatherDTO["CurrentWeatherDTO"]:::data
            CurrentWeatherModel["CurrentWeather"]:::data
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        WeatherAPI["Third-party Weather API"]:::external
    end

    %% Resources
    subgraph "Resources"
        direction TB
        Assets["Assets.xcassets"]:::resources
        RiveAnims["Rive Animations"]:::resources
    end

    %% Relationships
    SceneDelegate -->|"sets root"| RegionWeatherListVC
    RegionWeatherListVC -->|"binds to"| RegionWeatherListVM
    RegionWeatherListVM -->|"requestLocation()"| CoreLocationManager
    RegionWeatherListVM -->|"fetchWeather()"| NetworkManager
    NetworkManager -->|"uses endpoints"| APIEndpoints
    NetworkManager -->|"returns DTO"| CurrentWeatherDTO
    CurrentWeatherDTO -->|"maps to model"| CurrentWeatherModel
    RegionWeatherListVM -->|"saveForecast() / loadCached()"| CoreDataManager
    CoreDataManager -->|"model store"| CoreDataStorageModel
    RegionWeatherListVM -->|"update view"| RegionWeatherListVC

    RegionWeatherListVC -->|"navigates"| WeatherDetailVC
    WeatherDetailVC -->|"binds to"| WeatherDetailVM
    WeatherDetailVM -->|"fetchWeather()"| NetworkManager

    SceneDelegate -->|"registers"| PushNotificationCenter

    WeatherAPI -->|"provides data"| NetworkManager
    CoreLocationManager -->|"provides location"| RegionWeatherListVM

    BackgroundTopInfoView --> RegionWeatherListVC

    RiveAnims --> BackgroundTopInfoView
    Assets --> BackgroundTopInfoView

    %% Click Events
    click AppDelegate "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/App/AppDelegate.swift"
    click SceneDelegate "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/App/SceneDelegate.swift"
    click CoreLocationManager "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Data/CoreLocation/CoreLocationManager.swift"
    click NetworkManager "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Data/Network/NetworkManager.swift"
    click APIEndpoints "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Data/Network/APIEndpoints.swift"
    click CoreDataManager "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Data/PersistentStorages/CoreDataStorage/CoreDataManager.swift"
    click CoreDataStorageModel "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Data/PersistentStorages/CoreDataStorage/CoreDataStorage.xcdatamodeld"
    click CurrentWeatherDTO "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Data/DTO/CurrentWeatherDTO.swift"
    click CurrentWeatherModel "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Data/Model/CurrentWeather.swift"
    click RegionWeatherListVC "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Presentation/RegionList/ViewController/RegionWeatherListViewController.swift"
    click RegionWeatherListVM "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Presentation/RegionList/ViewModel/RegionWeatherListViewModel.swift"
    click WeatherDetailVC "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Presentation/WeatherDetail/VIewController/WeatherDetailViewController.swift"
    click WeatherDetailVM "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Presentation/WeatherDetail/ViewModel/WeatherDetailViewModel.swift"
    click ViewModelProtocol "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Presentation/Shared/Protocols/ViewModelProtocol.swift"
    click PushNotificationCenter "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Presentation/Shared/PushNotification/PushNotificationCenter.swift"
    click Assets "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/blob/develop/Look-out-the-window/Look-out-the-window/Resources/Assets.xcassets"
    click RiveAnims "https://github.com/sparta-nbcamp-ch3-advanced-team5/look-out-the-window/tree/develop/Look-out-the-window/Look-out-the-window/Resources/Riv"

    %% Styles
    classDef appShell fill:#fde2e2,stroke:#e34a4a;
    classDef presentation fill:#e2f7e1,stroke:#2e7d32;
    classDef data fill:#e1f0fe,stroke:#0277bd;
    classDef external fill:#f0f0f0,stroke:#616161,stroke-dasharray: 5 5;
    classDef resources fill:#fff3e0,stroke:#fb8c00;
```
