# devmfawzy/weatherapp architecture

> Architecture diagram of the GitHub repository devmfawzy/weatherapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devmfawzy/weatherapp
- Repository: https://github.com/devmfawzy/weatherapp

## Overview

##### Main Components
- Domain Layer: This contains the core business logic, entities (e.g., Weather, Location), repository interfaces (WeatherRepositoryProtocol, SearchHistoryRepositoryProtocol), services (LocationServiceProtocol), and use cases (GetWeatherUseCase, GetCurrentLocationUseCase, ManageSearchHistoryUseCase).
- Data Layer: This layer handles data management and includes:
- Data Sources: Remote (WeatherRemoteDataSource) and Local (SearchHistoryLocalDataSource, WeatherLocalDataSource).
- Repository Implementations: (WeatherRepository and SearchHistoryRepository) which conform to the protocol contracts defined in the Domain layer.
- DTOs/Models for mapping external data (WeatherResponseDTO, WeatherLocal).
- Services that manage low-level details such as Location services (LocationService).
- Presentation Layer: This includes:
- UI Components (Views and subcomponents such as WeatherView, WeatherContentView, SearchView, WeatherCardView, ErrorView, LoadingView, LocationPermissionInfoView).
- View Models (WeatherViewModel) that manage state and translate Domain data to UI models.
- UIModels (WeatherUIModel) to structure data for the view.

##### Architectural Patterns and Technologies
- For each component, annotate with the relevant technologies. For example, mention that the Presentation layer leverages SwiftUI and the ViewModel pattern.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        pv1["WeatherView"]:::presentation
        pv2["WeatherContentView"]:::presentation
        pv3["SearchView"]:::presentation
        pc1["WeatherCardView"]:::presentation
        pc2["ErrorView"]:::presentation
        pc3["LoadingView"]:::presentation
        pc4["LocationPermissionInfoView"]:::presentation
        vm["WeatherViewModel"]:::presentation
        uim["WeatherUIModel"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        ent1["Weather (Entity)"]:::domain
        ent2["Location (Entity)"]:::domain
        repProto1["WeatherRepositoryProtocol"]:::domain
        repProto2["SearchHistoryRepositoryProtocol"]:::domain
        svcProto["LocationServiceProtocol"]:::domain
        use1["GetWeatherUseCase"]:::domain
        use2["GetCurrentLocationUseCase"]:::domain
        use3["ManageSearchHistoryUseCase"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        remote["WeatherRemoteDataSource"]:::data
        local1["SearchHistoryLocalDataSource"]:::data
        local2["WeatherLocalDataSource"]:::data
        rep1["WeatherRepository"]:::data
        rep2["SearchHistoryRepository"]:::data
        dto1["WeatherResponseDTO"]:::data
        dto2["WeatherLocal"]:::data
        svcImpl["LocationService"]:::data
    end

    %% Dependency Injection Container
    dc["DependencyContainer"]:::container

    %% Interactions between Presentation and Domain
    pv1 -->|"calls"| vm
    vm -->|"calls"| use1
    vm -->|"calls"| use2
    vm -->|"calls"| use3
    vm -->|"updates"| uim

    %% Interactions between Domain and Data
    use1 -->|"requires"| repProto1
    use2 -->|"requires"| svcProto
    use3 -->|"requires"| repProto2

    repProto1 -->|"impl"| rep1
    repProto2 -->|"impl"| rep2
    svcProto -->|"impl"| svcImpl

    rep1 -->|"fetches"| remote
    rep1 -->|"fetches"| local2
    rep2 -->|"fetches"| local1

    rep1 -->|"maps"| dto1
    rep1 -->|"maps"| dto2

    use1 -->|"returns"| ent1
    use2 -->|"returns"| ent2

    %% Dependency Injection wiring
    dc -->|"injects"| rep1
    dc -->|"injects"| rep2
    dc -->|"injects"| svcImpl
    dc -->|"injects"| vm

    %% Styling
    classDef domain fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef data fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef presentation fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef container fill:#ffff99,stroke:#000,stroke-width:2px;

    %% Click Events - Domain Layer
    click ent1 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Domain/Entities/Weather.swift"
    click ent2 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Domain/Entities/Location.swift"
    click repProto1 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Domain/RepositoryInterfaces/WeatherRepositoryProtocol.swift"
    click repProto2 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Domain/RepositoryInterfaces/SearchHistoryRepositoryProtocol.swift"
    click svcProto "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Domain/Services/LocationServiceProtocol.swift"
    click use1 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Domain/UseCases/GetWeatherUseCase.swift"
    click use2 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Domain/UseCases/GetCurrentLocationUseCase.swift"
    click use3 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Domain/UseCases/ManageSearchHistoryUseCase.swift"

    %% Click Events - Data Layer
    click remote "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Data/DataSources/Remore/WeatherRemoteDataSource.swift"
    click local1 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Data/DataSources/Local/SearchHistoryLocalDataSource.swift"
    click local2 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Data/DataSources/Local/WeatherLocalDataSource.swift"
    click rep1 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Data/RepositoryImplementation/WeatherRepository.swift"
    click rep2 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Data/RepositoryImplementation/SearchHistoryRepository.swift"
    click dto1 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Data/DataModels/WeatherResponseDTO.swift"
    click dto2 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Data/DataModels/WeatherLocal.swift"
    click svcImpl "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Data/Services/LocationService.swift"

    %% Click Events - Presentation Layer
    click uim "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/UIModels/WeatherUIModel.swift"
    click vm "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/ViewModels/WeatherViewModel.swift"
    click pv1 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/Views/WeatherView.swift"
    click pv2 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/Views/WeatherContentView.swift"
    click pv3 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/Views/SearchView.swift"
    click pc1 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/Views/Components/WeatherCardView.swift"
    click pc2 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/Views/Components/ErrorView.swift"
    click pc3 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/Views/Components/LoadingView.swift"
    click pc4 "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/Presentation/Views/Components/LocationPermissionInfoView.swift"

    %% Click Event - Dependency Container
    click dc "https://github.com/devmfawzy/weatherapp/blob/main/WeatherApp/DependencyContainer/DependencyContainer.swift"
```
