Skip to content

Core Design

BhupeshPruthi edited this page Jul 12, 2021 · 2 revisions

The app has followed

  • At low level - MVVM Design
  • Singleton Design Pattern
  • Delegates and Protocols

Core Data

There are two Managed Objects in the project

  • CityMO

  • WeatherMO

  • Data first will be received from API and then inserted into DB.

  • Data will always be displayed after successfully saved in DB.

  • ViewModel will decide what should be fed to the View

  • CityMO has one to one mapping with WeatherMO with cityId as primary key (Core data constraint)

  • Have kept both Main MOC and Private MOC for the future use (to support rollback and 'Favourite Cities's weather update)

  • Core Data Util class consists of all the operations used on CityMO and WeatherMO

Operations includes

  • Saving new City + Weather -> saveCity(cityModel : CityModel , weatherModel : WeatherModel)
  • Retrieve a City + Weather -> fetchCityForId
  • Removing City + Weather -> RemoveCityForId
  • Marking a City Favourite
  • Marking a city Default -> setDefaultCityForId

Network Layer

  • Network layer consist of APIManager responsible for Request and Response methods. (Generics used with Protocols)
  • WeatherOneCallAPI use the Generic APIManager for request and response related to Weather API
  • A separate class is written to provide baseURL, query params and request header
  • Codable is used for data parsing

View

Two major views are present in the app

  • WeatherHomePageViewController -> To show the Home page View
  • LocationSearchViewController -> To show the list of Favourite cities

There are three custom cells available

  1. For favourite cities
  2. User to select city from search results
  3. Generic Custom Cell for error message

Model

There are model classes available for each custom cell and each view All Views are on Main Queue and all ViewModel works on Global Queue

  • Weather Home Page
  • Location Search
  • Search Results

Clone this wiki locally