The Entity Component System architecture pattern is mostly known in the world of game development. But the general ideas could be applied to all kind of software.
Sources of inspiration:
- Point-Free's Tagged.
- Sindre Sørhus's Defaults.
- Dmitriy Zharov's SwiftSecurity.
Your domain models (with their associated domain logic).
If a domain model should interact with one or more systems, add components to it in the form of extension methods.
- HTTP with
HTTPSession(a thin wrapper aroundURLSession).Endpoint<Resource>.
- Key-value store with
Defaults(a thin wrapper aroundUserDefaults).DefaultsEntry<Target>(and theDefaultsStoredprotocol).
- Secure key-value store with
SecureDefaults(a thin wrapper aroundKeychain services).SecureDefaultsEntry<Target>(and theSecureDefaultsStoredprotocol).
- Managed cryptographic keys with
KeyVault(a thin wrapper aroundKeychain services).KeyVaultEntry<Key>(and theKeyVaultManagedprotocol).