SwiftPumpkin

15 of 22 · System architecture

Feature Modules

Feature modularization splits an app into modules per feature, each with a small interface module and an implementation module. Features depend on each other's interfaces; implementations only meet at the composition root.

How it's wired

Imports, buildsInjects BImportsConformsApp / rootWires everythingFeature BImplementationFeature AUses BB InterfaceProtocol only
calls or tellsreports backFeatures depend on each other's interfaces, never implementations. Only the root sees both.
  • ThanksHistoryInterface holds the protocol.
  • ThanksHistory implements it with internal screens.
  • Only AppContainer imports the implementation.
PartOwnsLooks like
Interface moduleTiny, stable contractThanksHistoryInterface
Implementation moduleScreens and logic, internalThanksHistory
Composition rootThe one place implementations meetAppContainer

What you gain and what it costs

  • Build times: changing one feature's implementation rebuilds that module and the app, not every feature that uses it.
  • Ownership: modules map to teams, and module APIs make cross-team changes explicit and reviewable.
  • Preview apps: build and run one feature with fakes in seconds, without launching the whole app.
  • Costs: Package.swift plumbing, cross-module refactors, and "public" everywhere. Watch for a Core module everything imports; touching it rebuilds the world.
  • Linking matters: many dynamic frameworks slow app launch; prefer static linking for feature modules.

When I'd modularize by feature

Several teams, build times hurtingInterface plus implementation modules.
One small teamLayer modules or folders are enough.

Compared

Monolith vs layer modules vs feature modules

MonolithLayer modulesFeature modules
Incremental buildsSlowBetterBest
Team ownershipBlurryBy layerBy feature
Setup costNoneModerateHighest

Expert notes

  • Modularize along ownership lines. A module boundary no team owns is just friction.

Check yourself

Answer out loud before you reveal. Recall is what makes it stick.

30-second answer

Explain Feature Modules in 30 seconds.

System designAsked directly

Why split an app into dozens of SPM feature modules? What do you actually gain?

System designAsked indirectly

Onboarding only appears on first launch, so QA keeps reinstalling the app to test it. How would you restructure the code?

System designAsked indirectly

Feature A must navigate to Feature B, but feature modules shouldn't import each other. How do you wire it?

System designAsked indirectly

Leadership wants a strict modular, plugin-based architecture for a 10-person team. What does it actually cost?

Read it in the app's source