Mobile app architecture usually fails at one of two extremes. In the first, all the code lives in a 2,000-line ViewController or Activity, and any change to one screen breaks something next door. In the second, a ten-screen MVP gets a "perfect" Clean Architecture with five layers, a use case for every API call and twenty Gradle modules, and the team needs a week to add one form field.
This article explains what MVVM, Clean Architecture and modularisation actually give you, how to size them to your product and team, and which signals tell you it is time to add structure. We lean on the official Android recommendations and modern SwiftUI practice.
What problem architecture solves
Architecture is not about pretty diagrams. It answers practical questions: how much a change costs, how easily it can be tested and how many people can work in parallel without stepping on each other. Mobile adds platform challenges: screens are destroyed and recreated (rotation, memory pressure), the process can be killed in the background, and the network drops mid-request.
So the core principles are the same on iOS and Android:
- Separation of concerns. The UI renders state and forwards events; business logic and data access live elsewhere.
- Single source of truth. Every data type has one owner, such as a repository backed by a local database.
- Unidirectional data flow (UDF). State flows down to the UI, events flow up to the ViewModel. Google recommends this explicitly in its architecture recommendations.
- UI driven by a state model. A screen is a function of state, not a sequence of imperative calls.
MVVM: the baseline for most apps
MVVM (Model–View–ViewModel) is the de facto standard: on Android it is backed by Jetpack ViewModel and StateFlow, on iOS by SwiftUI with Observation (@observable) or ObservableObject on older versions.
What a healthy ViewModel looks like
- Exposes a single screen state object (UiState): data, a loading flag, an error.
- Accepts UI events: "Retry tapped", "filter changed".
- Knows nothing about concrete views, contexts or navigation controllers.
- Delegates data work to repositories rather than calling the API directly.
- Is covered by unit tests that run without an emulator or simulator.
A typical problem we find in code audits: the ViewModel becomes an 800–1,500-line god object that validates forms, formats dates, caches, talks to the network and handles analytics. That is the same Massive View Controller, just moved into another file. A sign it is time to extract logic: a method longer than a screen, or identical logic copied into two ViewModels.
MVI and TCA as variations
MVI treats state as an immutable object and every change as a reducer over events. On iOS, The Composable Architecture implements a similar idea. These approaches bring predictability and convenient testing of complex screens at the cost of more boilerplate. A sensible strategy is MVVM by default and a reducer approach for screens with complex state logic: multi-step forms, carts, editors.
Clean Architecture: what to keep and what to skip
Robert Martin described Clean Architecture as concentric circles with dependencies pointing inwards: business rules know nothing about frameworks, databases or UI. In mobile practice this usually becomes three layers: presentation, domain and data.
An important detail that often gets missed: the Android guide explicitly marks the domain layer as optional. It is worth introducing when logic is complex or reused by several ViewModels. A use case that merely forwards a repository call adds a file, a test and a level of indirection with no benefit.
| Layer | Contains | When you need it |
|---|---|---|
| Presentation | View, ViewModel, UiState, mapping to screen format | Always |
| Domain | Use cases, business rules, domain models | When logic is complex or shared across screens |
| Data | Repositories, API clients, database, cache, DTOs | Always, at least as a repository |
Signs of over-engineering
- Three nearly identical models (DTO, Entity, Domain) for every entity with no difference in fields.
- A use case for every repository method, each containing a single line.
- Interfaces with exactly one implementation that nobody substitutes, not even in tests.
- Adding a field to the API requires changes in 7–10 files.
Modularisation: when to split the codebase
A module is a Gradle module on Android or a Swift package / framework on iOS. Modularisation brings faster incremental builds, clear boundaries between teams, code reuse and enforced isolation: a feature module simply cannot see another module's internals. Google covers the approaches in its modularisation guide, and the Now in Android reference app shows them in practice.
But every module means build configuration, a public API, dependencies and maintenance time. Here are guidelines from our experience:
| Product size | Team | Recommended structure |
|---|---|---|
| MVP, up to 20 screens | 1–3 mobile developers | One app module with feature packages; optionally a separate core networking module |
| Growing product, 20–60 screens | 3–6 developers | app + core (network, database, design system) + 3–8 feature modules |
| Large product, 60+ screens | several teams | Feature modules split into api/impl, module owners, dependency graph checks |
How to split well
- Start with packages by feature, not by layer. A "checkout" folder with everything inside is far easier to extract than files scattered across "viewmodels" and "repositories".
- Extract core first. Networking, database, design system and analytics are needed by every feature and change less often.
- Feature modules do not depend on each other. Navigation between them goes through the app module or a dedicated navigation contract.
- Watch the graph. Circular dependencies, or a "core" that depends on everything and everything depends on, destroy the benefits.
- Measure. Clean and incremental build times before and after; Gradle Build Scans and the build cache on Android, Xcode's build timing summary on iOS.
Cross-platform specifics
Flutter and React Native apply the same principles with their own tools. In Flutter, Riverpod and BLoC are common ViewModel equivalents with UDF; in React Native, stateful hooks, Zustand or Redux Toolkit, and React Query for server state. The most useful split here is between server state (cached API responses) and local UI state. When both live in one global store, you get stale data and unnecessary re-renders.
With Kotlin Multiplatform it makes sense to share the data and domain layers while keeping the UI native or on Compose Multiplatform. That way layer boundaries line up with platform boundaries.
Testability as a measure of architecture
The simplest architecture test is trying to write a unit test for a screen's logic. If you need an emulator, ten mocks or access to private fields, the boundaries are in the wrong place. A realistic test pyramid for a mid-complexity app, from our experience:
| Level | What we test | Approximate share |
|---|---|---|
| Unit | ViewModels, use cases, mappers, validation | 60–75% |
| Integration | Repository + database, API client against a fake server | 15–25% |
| UI / end-to-end | Critical flows: sign-in, payment, onboarding | 5–15% |
Inject dependencies through constructors (Hilt or Koin on Android, a simple DI container or factories on iOS) so tests can swap them for fakes easily.
Common mistakes
- Tutorial architecture without adaptation. A big company's sample project structure does not necessarily fit a team of two.
- Business logic in the UI. A discount calculation inside a Composable or SwiftUI View cannot be properly tested or reused.
- No single source of truth. User data cached in three places drifts apart after a profile update.
- Modularisation for its own sake. Thirty modules for fifteen screens slow down both development and builds.
- Postponed refactoring. Boundaries you did not draw at 20 screens will cost several times more at 80.
Checklist for your project
- Every screen has a ViewModel (or equivalent) with one UiState and tests.
- Data access goes through repositories; ViewModels never call the API directly.
- A domain layer appears only where there is real business logic or reuse.
- Code is grouped by feature; core functionality is extracted separately.
- Adding a simple API field touches no more than 3–4 files.
- Incremental build time is measured and does not creep up unnoticed.
- Architecture decisions are briefly recorded as ADRs (Architecture Decision Records) so new developers understand the "why".
Sources: Android: Guide to app architecture; Android: Architecture recommendations; Android: Domain layer; Android: Guide to modularization; Now in Android; Robert C. Martin: The Clean Architecture; Apple: Observation; Apple: Swift packages; The Composable Architecture.
Originally published on the Mosmox journal: Mobile App Architecture: MVVM, Clean Architecture and Modularisation Without Overkill

Top comments (0)