Skip to content

PRWeatherApp is a modern iOS weather application built with SwiftUI

Notifications You must be signed in to change notification settings

mhmdzaid/PRWeatherApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PRWeatherApp

Overview

PRWeatherApp is a modern iOS weather application built with SwiftUI. It allows users to manage a list of cities, view current weather details, and access historical weather data. The app is designed for maintainability, testability, and a smooth user experience.

Screenshots

Simulator Screenshot - iPhone 16 Pro - 2025-11-06 at 03 10 36 Simulator Screenshot - iPhone 16 Pro - 2025-11-06 at 03 08 21 Simulator Screenshot - iPhone 16 Pro - 2025-11-06 at 03 08 13 Simulator Screenshot - iPhone 16 Pro - 2025-11-06 at 03 14 47 Simulator Screenshot - iPhone 16 Pro - 2025-11-06 at 03 15 38 Simulator Screenshot - iPhone 16 Pro - 2025-11-06 at 03 15 54 Simulator Screenshot - iPhone 16 Pro - 2025-11-06 at 03 16 08

Architecture

  • MVVM Pattern: The app uses Model-View-ViewModel for clear separation of concerns.
    • Models: Represent weather data, cities, and persistence entities.
    • ViewModels: Handle business logic, state management, and data fetching.
    • Views: SwiftUI views for UI presentation and user interaction.
  • Networking: Abstracted via protocols (WeatherServiceProtocol, WeatherAPIClientProtocol) for easy mocking and testing.
  • Persistence: Uses Core Data via a PersistenceManager abstraction.
  • Error Handling: Centralized with ErrorUtils for extracting error messages.
  • Testing: Includes unit tests for view models and services, with mocks for dependencies.

File/Folder Structure

PRWeatherApp/
├── Features/
│   ├── MainView/
│   ├── DetailsView/
│   └── HistoricalDataView/
├── Helpers/
├── Network/
├── Persistence/
├── Shared/
├── Utilities/
├── Resources/
├── Configs/
├── Preview Content/
├── PRWeatherAppApp.swift
├── ...
PRWeatherAppTests/
PRWeatherAppUITests/
  • Features/: Contains feature modules (Main, Details, Historical Data) with their Views, ViewModels, and Models.
  • Helpers/: Utility functions (e.g., date formatting, temperature conversion).
  • Network/: Networking layer (API client, service, bridging header).
  • Persistence/: Core Data manager and model files.
  • Shared/: Reusable UI components (buttons, backgrounds, fonts).
  • Utilities/: Error handling, parsing utilities.
  • Resources/: Assets, fonts, colors.
  • Configs/: App configuration files (Info.plist).
  • Preview Content/: SwiftUI preview assets.
  • Tests/: Unit and UI tests for app logic and user flows.

Component Flow Diagram

+-------------------+
|      Views        |
|  (SwiftUI UI)     |
+-------------------+
          |
          v
+-------------------+
|    ViewModels     |
| (State, Logic)    |
+-------------------+
          |
          v
+-------------------+-------------    
|           Services              |   
| (WeatherService, localManager)  |
+-------------------+-------------   
          |
          v
+-------------------+
|   API Client      |
| (WeatherAPIClient)|
+-------------------+
          |
          v
+-------------------+
|   Network Layer   |
+-------------------+

ViewModels <----> PersistenceManager (Core Data)

Error Handling: ErrorUtils (used throughout)
Parsing: Parser (used by Services)
  • User interacts with Views (SwiftUI)
  • Views bind to ViewModels (MVVM)
  • ViewModels fetch data from Services (networking)
  • Services use API Clients to get data from the network
  • Data is parsed and returned to ViewModels
  • ViewModels may store/fetch data via PersistenceManager (Core Data)
  • ViewModels update Views with new state

Design Rationale

  • SwiftUI: Enables declarative UI and state-driven design.
  • Dependency Injection: Improves testability and flexibility.
  • Async/Await: Modern concurrency for networking and persistence.
  • State Management: UI states (loading, error, empty, loaded) are handled explicitly for robust UX.

Testing

  • Unit Tests: Located in PRWeatherAppTests/, covering view models and services.
  • UI Tests: Located in PRWeatherAppUITests/.
  • How to Run Tests:
    • In Xcode, select Product > Test or press Cmd+U.

Last updated: October 20, 2025

About

PRWeatherApp is a modern iOS weather application built with SwiftUI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published