---
title: MVP Architecture
pubDate: 2026-08-17T09:53:44.266Z
antora:
  editUrl: https://github.com/couchbaselabs/mobile-travel-sample/edit/master/content/modules/mobile-travel-tutorial/pages/swift/develop/mvp-architecture.adoc
  xref: xref:tutorials:mobile-travel-tutorial:swift/develop/mvp-architecture.adoc[]
---

[Consult the llms.txt file for a full list of contents](/llms.txt)
[View original HTML](/tutorials/mobile-travel-tutorial/swift/develop/mvp-architecture.html)

# MVP Architecture

## [](#the-model-view-presenter-pattern)The Model-View-Presenter pattern

In our app, we follow the MVP pattern, separating the internal data model, from a passive view through a presenter that handles the logic of our application and acts as the conduit between the model and the view.

![ios eb1](../../_images/ios-eb1.png) 

### [](#protocols)Protocols

In the Travel app, we define two sets of protocols. The `PresenterProtocol` protocol that must be implemented by all Presenter objects and `PresentingViewProtocol` must be implemented by the corresponding "view" objects. The `PresenterProtocol` and `PresentingViewProtocol` may be optionally extended to support capabilities of specific presenter/view

The app defines the following PresenterProtocols that extend the `PresenterProtocol` protocol.

* _BookingPresenterProtocol_ defines methods to be implemented by the Booking Presenter.
* _FlightPresenterProtocol_ defines methods to be implemented by the Flight Presenter.
* _AirportPresenterProtocol_ defines methods to be implemented by the Airport Presenter.
* _HotelPresenterProtocol_ defines methods to be implemented by the Hotel Presenter.

The app defines the following PresentingViewProtocols that extend the `PresentingViewProtocol` protocol.

* _BookingPresentingViewProtocol_ defines methods to be implemented by the Booking View

### [](#model)Model

The model provides and stores the internal data. In our travel app, for simplicity, we use standard data types of `Dictionary` and `Array` to represent the data. In a real application, one would use a custom object to represent the model.

The app implements the following models.

* _Booking_ which represents a flight reservation
* _Flight_ which represents airline details
* _Airport_ which represents airport name
* _Hotel_ which represents hotel details

In addition, the `DatabaseManager.swift` is a singleton class that is used to manage the common database operations such as Database Creation/Deletion and Replication.

### [](#view)View

In the Travel app, the `UIView` and the `UIViewController` classes represent the "view" in MVP. It handles user input and forwards requests to the Presenter. It updates the UI based on response from the Presenter. The view object holds a weak reference to the corresponding Presenter object that implements the corresponding `PresenterProtocol`.

The app implements the following ViewControllers.

* _LoginViewController_ which represents the login UI
* _BookmarkedHotelsTableViewController_ which represents the UI that lists bookmarked hotels
* _BookingTableViewController_ which represents the flight reservations UI
* _FlightListingTableViewController_ which represents the UI that lists of flight details
* _FlightSearchViewController_ which represents flight search UI
* _HotelsTableViewController_ which represents the UI that lists hotels
* _HotelDetailViewController_ which represents the UI that lists hotel details

In addition, there are custom UITableViewCells.

### [](#presenter)Presenter

The Presenter acts as the intermediary between the View and the Model. It holds a weak reference to the corresponding view object that implements appropriate `PresentingViewProtocol`.

The app implements the following Presenters.

* _BookingPresenter_ which implements the `BookingPresenterProtocol`
* _FlightPresenter_ which implements the `FlightPresenterProtocol`
* _AirportPresenter_ which implements the `AirportPresenterProtocol`
* _HotelPresenter_ which implements the `HotelPresenterProtocol`

In addition, there are some simple custom UI widgets like custom UITableViewCells