# strumswell/oscar-weather architecture

> Architecture diagram of the GitHub repository strumswell/oscar-weather, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/strumswell/oscar-weather
- Repository: https://github.com/strumswell/oscar-weather

## Overview

##### Main System Components

a) Presentation Layer (UI)
- Main views hierarchy
- Widget extensions (iOS, Watch, Lockscreen)
- Background weather animations
- Charts and visualizations

b) Data Management Layer
- Weather data services
- Location services
- Cache management
- Persistence layer

c) External Services Integration
- Weather data providers
- Tile services
- Radar services

##### Component Relationships

**[User Interface Layer]**
- ↑↓
**[Data Management Layer]**
- ↑↓
**[External Services Layer]**

##### Detailed Component Breakdown

a) UI Components (Purple Rectangles)
- Main Views (NowView, MapDetailView, etc.)
- Widget Views
- Watch App Interface
- Background Animations

b) Data Services (Blue Hexagons)
- WeatherObservable
- LocationManager
- CityService
- SettingService

- CoreData (DataModels.xcdatamodeld)
- Cache Middleware
- Persistence Controller

d) External APIs (Orange Clouds)
- OpenMeteo
- Tomorrow.io
- DWD
- BrightSky

##### Data Flow Indicators

- User interaction flows
- Data refresh patterns
- Widget updates
- Watch app synchronization

##### Technical Details

Annotations for:
- SwiftUI framework usage
- iOS 17 specific features
- CoreData integration
- Location services
- Widget extensions

##### Architectural Patterns

Following patterns:
- MVVM architecture for views
- Observer pattern for weather updates
- Repository pattern for data access
- Service locator for dependency injection

This architecture should emphasize the app's focus on weather data accuracy and the multiple visualization options (charts, radar, maps) while showing how it maintains performance through proper caching and data management.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Presentation Layer"
        MainViews["Main Views"]
        NowView["NowView"]
        MapDetail["MapDetailView"]
        SearchCity["SearchCityView"]
        BgAnim["Background Animations"]
        Charts["Weather Charts"]
        Radar["Radar System"]

        MainViews --> NowView
        MainViews --> MapDetail
        MainViews --> SearchCity
        MainViews --> Charts
        MainViews --> Radar
    end

    subgraph "Widget Extensions"
        iOSWidget["iOS Widget"]
        WatchWidget["Watch Widget"]
        LockWidget["Lockscreen Widget"]
    end

    subgraph "Watch App"
        WatchInterface["Watch App Interface"]
    end

    subgraph "Data Management Layer"
        WeatherObs["WeatherObservable"]
        LocationMgr["LocationManager"]
        CityServ["CityService"]
        SettingServ["SettingService"]
        Cache["Cache Management"]
        APIClient["API Client"]
    end

    subgraph "Storage Layer"
        CoreData[(CoreData)]
        PersistCtrl["Persistence Controller"]
    end

    subgraph "External Services"
        OpenMeteo["OpenMeteo API"]
        Tomorrow["Tomorrow.io API"]
        DWD["DWD API"]
        BrightSky["BrightSky API"]
    end

    MainViews <--> WeatherObs
    WeatherObs <--> APIClient
    APIClient <--> Cache
    Cache <--> CoreData
    CoreData <--> PersistCtrl
    LocationMgr <--> WeatherObs
    CityServ <--> CoreData
    SettingServ <--> CoreData

    APIClient --> OpenMeteo
    APIClient --> Tomorrow
    APIClient --> DWD
    APIClient --> BrightSky

    WeatherObs --> iOSWidget
    WeatherObs --> WatchWidget
    WeatherObs --> LockWidget
    WeatherObs --> WatchInterface

    classDef ui fill:#e6e6fa,stroke:#333
    classDef service fill:#add8e6,stroke:#333
    classDef storage fill:#90ee90,stroke:#333
    classDef external fill:#ffa500,stroke:#333
    classDef widget fill:#ffb6c1,stroke:#333
    classDef watch fill:#dda0dd,stroke:#333

    class MainViews,NowView,MapDetail,SearchCity,BgAnim,Charts,Radar ui
    class WeatherObs,LocationMgr,CityServ,SettingServ,Cache,APIClient service
    class CoreData,PersistCtrl storage
    class OpenMeteo,Tomorrow,DWD,BrightSky external
    class iOSWidget,WatchWidget,LockWidget widget
    class WatchInterface watch

    click NowView "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Views/NowView.swift"
    click MapDetail "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Views/MapDetailView.swift"
    click SearchCity "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Views/SearchCityView.swift"
    click Charts "https://github.com/strumswell/oscar-weather/tree/master/Oscar°/Views/NowSubViews/ChartViews/"
    click Radar "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Views/RainRadarView.swift"
    click BgAnim "https://github.com/strumswell/oscar-weather/tree/master/Oscar°/Views/Backgrounds/"
    click WeatherObs "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Networking/WeatherObservable.swift"
    click APIClient "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Networking/APIClient.swift"
    click LocationMgr "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Networking/LocationManager.swift"
    click Cache "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Networking/CacheMiddleware.swift"
    click CoreData "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Storage/DataModels.xcdatamodeld"
    click PersistCtrl "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Storage/PersistenceController.swift"
    click CityServ "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Storage/CityService.swift"
    click SettingServ "https://github.com/strumswell/oscar-weather/blob/master/Oscar°/Storage/SettingService.swift"
    click iOSWidget "https://github.com/strumswell/oscar-weather/tree/master/Oscar°Widget/"
    click WatchWidget "https://github.com/strumswell/oscar-weather/tree/master/Oscar°WatchWidget/"
    click LockWidget "https://github.com/strumswell/oscar-weather/tree/master/Oscar°Widget/Lockscreen/"
    click WatchInterface "https://github.com/strumswell/oscar-weather/tree/master/Oscar°Watch Watch App/"
```
