# Design Mobile Project Structure

> Use when starting a mobile app (Android/Kotlin, iOS/Swift, Flutter, React Native) or when an existing app has grown hard to build and change — one giant app mod

- Skill: `jeffreytse/design-mobile-project-structure` (Agent Skill)
- Install (CLI): `npx get-skill add jeffreytse/design-mobile-project-structure`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jeffreytse/design-mobile-project-structure/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: jeffreytse (https://skillmd.com/u/jeffreytse)
- Updated: 2026-12-03
- Page: https://skillmd.com/skills/jeffreytse/design-mobile-project-structure

---

---
name: design-mobile-project-structure
description: Use when starting a mobile app (Android/Kotlin, iOS/Swift, Flutter, React Native) or when an existing app has grown hard to build and change — one giant app module, slow incremental builds, screens mixing UI, networking, and persistence, or teams stepping on each other's code.
source: 'Android Developers, "Guide to app architecture" and "Guide to Android app modularization"; Google, "Now in Android" sample app (GitHub); Flutter Documentation, "Guide to app architecture", 2024; Apple, "Swift Package Manager" documentation; Uber Engineering, "Introducing RIBs", 2017'
tags: [project-structure, mobile, modularization, android, ios, build-performance]
related: [apply-package-by-feature, apply-module-boundary-enforcement, design-offline-first, design-frontend-project-structure]
---

# Design Mobile Project Structure

Structure a mobile app in **layers** (UI → optional domain → data) and, as it grows, **modules**: a thin `app` module, independent `feature` modules, and shared `core` modules. Features depend on core, never on each other.

## Why This Is Best Practice

**Adopted by:**
- Google's official Android architecture and modularization guides, demonstrated in the "Now in Android" reference app.
- Flutter's official architecture guide (views, view models, repositories, services).
- Uber (RIBs), Airbnb, and Spotify, which modularized large iOS and Android codebases.
- Apple's Swift Package Manager supports local packages for the same purpose.

**Impact:**
- Google's modularization guide cites these benefits:
  - faster builds through parallel and incremental compilation
  - better reusability and stricter visibility control
  - ownership and testability
  - the ability to use dynamic feature delivery
- Separating UI from data lets view models and repositories be unit tested without a device or emulator.

**Why best:**
- A single module with screens that call network and database directly works for a prototype.
- That approach collapses as the app grows: builds slow, changes ripple, and testing needs a device.
- Layering plus feature modules follows the same proven principles as backend and web, and the platform vendors officially recommend it.

Sources: Android Developers, "Guide to app architecture" and "Guide to Android app modularization". Now in Android (github.com/android/nowinandroid). Flutter docs (2024), "Guide to app architecture". Apple, Swift Package Manager docs. Uber Engineering (2017), "Introducing RIBs".

## Steps

1. **Layer every feature:**
   - **UI layer:** screens/views plus a state holder (ViewModel, Bloc/Cubit, ObservableObject). Unidirectional data flow: state goes down, events go up.
   - **Domain layer (optional):** use cases for complex or reused business logic.
   - **Data layer:** repositories (the single source of truth, exposing data as streams) backed by data sources (network, database, cache). See `design-offline-first` for offline needs.

2. **Start as a single module with feature packages** (`apply-package-by-feature`):
   ```
   app/src/main/java/com/acme/
     feature/home/  (HomeScreen, HomeViewModel)
     feature/profile/
     core/data/  core/network/  core/database/  core/designsystem/
   ```

3. **Modularize when builds slow down or teams grow.** Use the "Now in Android" pattern:
   ```
   app/                    # entry point, navigation graph, DI wiring
   feature/
     home/   profile/   settings/
   core/
     designsystem/  ui/  data/  domain/  network/  database/  model/  common/  testing/
   build-logic/            # convention plugins (Gradle) for shared build config
   ```
   - `feature:*` depends on `core:*` only. Features never depend on other features. Navigate through routes defined in `app` or a navigation contract module.
   - `core:model` holds plain data models shared across layers.

4. **Apply platform equivalents:**
   - **iOS (Swift):** a thin app target plus local Swift packages (`Features/Home`, `Core/Networking`, `Core/DesignSystem`) declared in a `Packages/` folder. Use `internal` access by default and expose a minimal `public` API. Tuist or XcodeGen can generate the project to avoid `.pbxproj` conflicts.
   - **Flutter:** `lib/ui/<feature>/{views,view_models}`, `lib/data/{repositories,services}`, `lib/domain/models`, and `lib/config`, per the Flutter architecture guide. For large apps, use Dart packages in a melos or pub workspace.
   - **React Native/Expo:** feature folders (`src/features/<feature>/{screens,components,hooks,api}`) plus `src/shared` and Expo Router's `app/` for routes, following the frontend structure (see `design-frontend-project-structure`).

5. **Centralize dependencies and build config:** a Gradle version catalog (`libs.versions.toml`) plus convention plugins, a single SPM manifest per package, and pinned Flutter/Dart SDK versions.

6. **Wire with dependency injection** in the app module (Hilt/Koin, Swift initializer injection or Factory, Riverpod/get_it), so features stay decoupled from concrete implementations.

7. **Mirror the structure in tests:**
   - unit tests for view models and repositories, using fakes from `core:testing`
   - UI tests per feature
   - a few end-to-end flows in the app module

8. **Enforce boundaries.** Rely on module visibility first (Gradle `implementation`, Swift `internal`). Add Konsist or a dependency-analysis plugin for rules such as "no feature-to-feature dependencies" (see `apply-module-boundary-enforcement`).

## Rules

- UI never talks to network or database directly. It goes through repositories.
- Repositories are the single source of truth for their data.
- Features depend on core modules, never on each other.
- The app module only wires and navigates. It holds no business logic.
- Modularize to solve real problems (build time, ownership), not preemptively.

## Common Mistakes

- **God activity or ViewController.** UI, networking, and persistence in one class that can't be tested.
- **Feature-to-feature dependencies** for navigation. Use route contracts instead.
- **Over-modularizing early.** Fifty modules in a three-screen app create build-config overhead with no gain.
- **A `core:common` dumping ground.** Split by purpose (network, database, designsystem).
- **Duplicated build config across modules.** Use convention plugins or a version catalog.

## Examples

**Android news app:** `app` + `feature:foryou`, `feature:bookmarks`, `feature:search` + `core:data`, `core:network` (Retrofit), `core:database` (Room), `core:designsystem` (Compose theme). Hilt wiring sits in `app`. Clean builds run modules in parallel, and incremental builds rebuild only the changed feature.

**iOS app:** an `App` target plus `Packages/Features/{Feed,Profile}` and `Packages/Core/{API,Persistence,DesignSystem}` as local SPM packages. Previews and unit tests run per package without launching the whole app.

## When NOT to Use

- **Prototypes and very small apps.** A single module with feature packages is enough.
- **Cross-platform shells around a web app** (Capacitor/WebView). Follow the web structure instead.

