A UIKit iOS app with MVP architecture utilizing IoC and DI

Clean MVP

POW-dark.mp4


Requirements:

Functional:

  • Fetching and parsing data from API.
  • Listing Data.
  • Searching.
  • Pagination.
  • Navigation to Details view.

Non-Functional:

  • Performance:

    • Caching images.
  • Scalability:

    • Modularity.
  • Reliability:

    • Unit tests.

Low-Level Design


Design Decisions

  • UI:

    • UIKit
    • MVP Architecture
  • Principals and Patterns:

    • SOLID conformance:
      • Features are separated into modules.
      • UseCases for business logic.
    • Utilizing IoC and DI.
    • Coordinator pattern for navigation.
  • Dependency Manager:

    • Swift Package Manager (SPM)
  • Dependencies:

    • Kingfisher: Downloading and caching images from the web.

Notes:

  • Design Patterns:
    • Bridge Design Pattern (BaseVC and BasePresenter) is used to avoid code duplication.
    • Adapter Design Pattern (HTTPClient and WatchlistDataStore) is used to easily swap HTTP clients or Data Persistence if needed (ex. Alamofire instead of URLSession).
    • Composite Reuse Principle (CRP) (DataSources and Delegates) is used to compose the ViewControllers.
    • An Automatic DI Container (Resolver or Swinject) could be used if the project got bigger.
    • Repository Pattern could be used if local data storage is needed in the future.
  • iOS APIs:
    • DispatchGroup (SimilarMoviesUseCase) is used to handle multiple async network calls.
    • Race Conditions are avoided in SimilarMoviesUseCase using a serial DispatchQueue.
    • A Set is used over an Array in WatchlistDataStore to achieve O(1) search time complexity.
  • To achieve better UX:
    • ActivityIndicator for each network called is used.
    • Debouncer is used to avoid unneeded search results and UI refreshes.
    • DarkMode and Landscape modes are supported.
    • Errors are handled to avoid failing silently.
    • Different placeholders are used for different image types (poster or cast).
  • All the presenters are unit tested (15 tests in total).

GitHub

View Github