Implement a Service-Oriented Architecture in Swift 5
Why using just MVC/MVVM/VIPER isn’t enough
Intro
Why is just using MVC, MVVM, MVP, or VIPER not enough? These architectural patterns handle only the higher level (UI) of your application. But very often, you also have to implement network managers, API clients, data sources, persistence containers, and so on. Service-oriented architecture makes your life easier by structuring the interaction between the high-level and lower-level implementations.
In this piece, I’ll show you how you can implement a service-oriented architecture (SOA). I did it by using a demo app I created for my VIPER piece and refactoring it according to SOA recommendations.
The source code of the project is available on GitHub.
Project Structure

The root of the project is divided into three folders: Classes, Resources, and Supporting Files. The Resources folder contains Assets.xcassets, and the Supporting Files folder contains LaunchScreen.storyboard and Info.plist.
As you can see, in Classes, we have the following folders:
- The
ApplicationLayerfolder contains theAppDelegate.swiftfile - The
PresentationLayerfolder has two VIPER modules:QuotesandQuoteDetail - The
BusinessLogicLayerfolder containsServicesandEntities[aka models in MV(X)] - The
Servicesfolder has three services we use in our app:QuoteService, which fetches quotes from the API;KingfisherService, which obtains image data from an URL; andImageDataService, which generates an image from that data - The
CoreLayerfolder contains all the helper files we’ll need to work with services:ApiUrls, request configurators, and network clients
Define a Service
First, we need to provide a base functionality of a service that’ll be subclassed by specific services in the future:





