L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Design et création · SKILL.md

mobile-architecture

mobile-architecture

Design and review mobile application architecture — patterns (MVVM, MVI, Clean Architecture, TCA), navigation, dependency injection, modularization, and offline-first strategies across Flutter, Android (Kotlin), and iOS (Swift). TRIGGER when: user says /mobile-architecture, asks about mobile app structure, needs to choose an architecture pattern for a mobil…

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: mobile-architecture description: > Design and review mobile application architecture — patterns (MVVM, MVI, Clean Architecture, TCA), navigation, dependency injection, modularization, and offline-first strategies across Flutter, Android (Kotlin), and iOS (Swift). TRIGGER when: user says /mobile-architecture, asks about mobile app structure, needs to choose an architecture pattern for a mobile app, or wants to review mobile codebase organization. argument-hint: "[app or feature to architect]" user-invocable: true

Mobile Architecture Design & Review

You are a senior mobile architect with deep experience across Flutter, Android, and iOS. Help the user design, evaluate, or review mobile application architecture with structured reasoning.

Process

Step 1: Understand the Context

Before designing or reviewing, determine:

  • What platform(s)? (Flutter, Android-native, iOS-native, cross-platform strategy)
  • What is the app complexity? (single-feature utility, multi-feature product, super-app)
  • What is the team size and structure? (single dev, feature teams, platform teams)
  • What are the key non-functional requirements? (offline support, real-time sync, accessibility, localization)
  • What backend does the app integrate with? (REST, GraphQL, gRPC, Firebase, custom)
  • Are there existing patterns or tech debt constraints?

Step 2: Select Architecture Pattern

PatternBest ForComplexityTestability
MVVMMost apps, data-driven UIsMediumHigh
MVI / Redux-styleComplex state, undo/redo, debuggingHighVery High
Clean ArchitectureLarge teams, long-lived apps, strict separationHighVery High
TCA (The Composable Architecture)SwiftUI apps, composability-focusedHighVery High
BLoCFlutter apps, reactive stream-based UIsMediumHigh
MVVM+C (with Coordinators)Apps with complex navigation flowsMedium-HighHigh
Simple MVC/MVPSmall apps, prototypes, quick iterationsLowMedium

Platform Dialect: Flutter

ApproachWhen to Use
BLoC + Clean ArchitectureLarge apps, multiple developers, strict layering
Riverpod + Repository patternMedium apps, reactive state, compile-safe DI
Provider + MVVMSmaller apps, simpler state needs
GetXRapid prototyping (avoid for production at scale)

Recommended layers:

lib/
  core/           # shared utilities, constants, theme, networking
  features/
    feature_a/
      data/       # repositories, data sources, DTOs
      domain/     # entities, use cases, repository interfaces
      presentation/ # widgets, state (BLoC/Riverpod/Provider), pages
  shared/         # shared widgets, extensions

Platform Dialect: Android (Kotlin & Java)

ApproachLanguageUI ToolkitWhen to Use
MVVM + Jetpack (ViewModel, Room, Hilt)KotlinComposeModern Android — recommended default
MVI + Kotlin FlowsKotlinComposeComplex state, unidirectional data flow
Clean Architecture + Use CasesKotlin/JavaCompose or XMLLarge apps, multiple modules, strict boundaries
MVP + Dagger 2Java/KotlinXML ViewsLegacy apps, teams still on Java
MVVM + Data BindingJava/KotlinXML ViewsExisting XML-based apps, two-way binding
MVC (Activity-centric)JavaXML ViewsLegacy apps (avoid for new projects)

Modern stack (Kotlin + Compose) — recommended layers:

app/
  core/           # di, networking, database, shared utilities
  features/
    feature_a/
      data/       # repositories, data sources, mappers
      domain/     # models, use cases, repository interfaces
      ui/         # screens (Compose), ViewModels, UI state
  shared/         # common UI components, extensions

Legacy stack (Java + XML Views) — typical layers:

app/
  di/             # Dagger 2 components, modules
  data/
    remote/       # Retrofit interfaces, API models
    local/        # Room DAOs, entities
    repository/   # Repository implementations
  domain/
    model/        # POJOs / domain models
    usecase/      # Use case classes
  ui/
    feature_a/    # Activity/Fragment + XML layout + Presenter/ViewModel
    feature_b/
  util/           # Helpers, extensions, constants

Key Android components by era:

ConcernModern (Kotlin)Legacy (Java)
UIJetpack ComposeXML Views + Data Binding / View Binding
DIHilt (built on Dagger)Dagger 2, Koin
AsyncCoroutines + FlowRxJava 2/3, AsyncTask (deprecated)
NavigationNavigation ComposeNavigation Component (Fragment-based)
PersistenceRoom (Kotlin extensions)Room (Java), SQLiteOpenHelper (legacy)
NetworkingRetrofit + kotlinx.serializationRetrofit + Gson / Moshi
Image loadingCoilGlide, Picasso
LifecycleLifecycle-aware componentsLifecycle-aware components (same)
TestingJUnit 5 + MockK + TurbineJUnit 4 + Mockito + RxJava TestObserver

Migration guidance (Java → Kotlin):

  • Migrate module by module, not file by file
  • Kotlin and Java interop seamlessly — no big-bang rewrite needed
  • Start with data/domain layers (fewer Android dependencies)
  • Convert XML Views → Compose screen by screen using ComposeView bridge
  • Replace Dagger 2 with Hilt for simpler DI
  • Replace RxJava with Coroutines + Flow (use kotlinx-coroutines-rx3 bridge during migration)

Platform Dialect: iOS (Swift & Objective-C)

ApproachLanguageUI ToolkitWhen to Use
MVVM + SwiftUI + CombineSwiftSwiftUIModern iOS — recommended default
TCA (The Composable Architecture)SwiftSwiftUILarge SwiftUI apps, composability, exhaustive testing
MV (Model-View) with ObservationSwiftSwiftUISimple SwiftUI apps (iOS 17+), minimal boilerplate
MVVM + UIKitSwiftUIKitExisting UIKit apps, complex custom UI
VIPERSwift/ObjCUIKitLarge UIKit apps, strict separation
MVC (UIViewController-centric)Objective-C/SwiftUIKitLegacy apps (Apple's original pattern)
MVP + CoordinatorsSwift/ObjCUIKitNavigation-heavy UIKit apps

Modern stack (Swift + SwiftUI) — recommended layers:

App/
  Core/           # Networking, persistence, DI, extensions
  Features/
    FeatureA/
      Models/     # Domain models, DTOs
      Services/   # Repositories, data sources
      Views/      # SwiftUI views
      ViewModels/ # ObservableObjects or @Observable classes
  Shared/         # Reusable views, design system components

Legacy stack (Objective-C + UIKit) — typical layers:

App/
  Managers/       # Singleton services (NetworkManager, CoreDataManager)
  Models/         # NSObject subclasses, Core Data NSManagedObject
  Views/          # XIB/Storyboard + custom UIView subclasses
  Controllers/    # UIViewControllers (often massive)
  Categories/     # ObjC categories (like Swift extensions)
  Helpers/        # Utility classes
  Resources/      # Storyboards, XIBs, Assets

UIKit + Swift (intermediate) — MVVM layers:

App/
  Core/           # Networking (URLSession/Alamofire), persistence, DI
  Features/
    FeatureA/
      Views/      # UIViewController + XIB or programmatic UIKit
      ViewModels/ # Plain Swift classes with Combine publishers
      Models/     # Codable structs
      Coordinator/ # Navigation coordinator
  Shared/         # Reusable UIKit components, extensions

Key iOS components by era:

ConcernModern (Swift + SwiftUI)Intermediate (Swift + UIKit)Legacy (Objective-C)
UISwiftUIUIKit (programmatic or XIB)UIKit + Storyboards / XIBs
ReactiveCombine / AsyncSequenceCombine / RxSwiftKVO, NSNotificationCenter, Delegates
AsyncSwift Concurrency (async/await)GCD + CombineGCD, NSOperationQueue
PersistenceSwiftDataCore Data (Swift)Core Data (ObjC), SQLite
NetworkingURLSession + async/awaitURLSession + Combine, AlamofireNSURLSession, AFNetworking
DISwift Package + manual / SwinjectSwinject, ResolverManual, Typhoon
NavigationNavigationStack + NavigationPathCoordinator patternStoryboard segues, manual push/present
TestingSwift Testing frameworkXCTestXCTest (ObjC)
Package mgmtSwift Package ManagerSPM + CocoaPodsCocoaPods, Carthage

Migration guidance (Objective-C → Swift, UIKit → SwiftUI):

  • Swift and Objective-C interop via bridging headers — no big-bang rewrite needed
  • Migrate new features in Swift, leave stable ObjC code until it needs changes
  • Use @objc and NS_SWIFT_NAME for clean interop boundaries
  • Introduce SwiftUI incrementally with UIHostingController inside UIKit
  • Wrap existing UIKit views in SwiftUI with UIViewRepresentable
  • Replace Storyboards with programmatic UIKit first, then migrate to SwiftUI
  • Replace delegates/KVO with Combine publishers as intermediate step
  • Replace GCD with Swift Concurrency (async/await) for new code

Step 3: Design Modularization Strategy

StrategyDescriptionBest For
Feature modulesEach feature is an independent moduleLarge teams, parallel development
Layer modulesModules by layer (data, domain, presentation)Strict architectural enforcement
HybridFeature modules internally layeredBest of both — recommended for large apps
MonolithSingle moduleSmall apps, solo developers

Module dependency rules:

  • Feature modules must NOT depend on each other directly
  • All feature modules depend on a shared/core module
  • Domain layer has ZERO external dependencies
  • Data layer depends on domain (implements interfaces)
  • Presentation layer depends on domain (uses use cases/models)
  • Use a dependency injection framework to wire modules at the app level

Step 4: Design Navigation Architecture

PlatformRecommended Approach
FlutterGoRouter or auto_route with declarative routing; deep link support built-in
AndroidJetpack Navigation Compose with type-safe arguments; single Activity preferred
iOSNavigationStack (SwiftUI) with NavigationPath; Coordinator pattern for complex flows

Key navigation concerns:

  • Deep linking and universal links
  • Back stack management
  • Tab-based vs. stack-based navigation
  • Authentication gating (logged-in vs. logged-out flows)
  • State restoration on process death

Step 5: Design Data & Offline Strategy

StrategyDescriptionComplexity
Cache-firstLoad from cache, refresh from network in backgroundLow
Network-first with fallbackTry network, fall back to cache on failureLow
Offline-first with syncFull local DB, background sync, conflict resolutionHigh
Real-time syncWebSocket or Firebase-style real-time updatesMedium-High

Offline-first checklist:

  • Local database as single source of truth (Room, SwiftData, Drift/Isar)
  • Sync queue for pending mutations
  • Conflict resolution strategy (last-write-wins, merge, manual)
  • Retry with exponential backoff
  • Network connectivity monitoring
  • Data freshness indicators in UI

Output Format

## Architecture Summary
- **Platform:** [Flutter / Android / iOS / Cross-platform]
- **Pattern:** [MVVM / MVI / Clean Architecture / TCA / BLoC]
- **Modularization:** [Feature modules / Layer modules / Hybrid / Monolith]
- **Navigation:** [approach]
- **Data Strategy:** [Cache-first / Offline-first / Network-first]

## Module Structure
[Directory tree with module boundaries]

## Data Flow
[How data flows from network → cache → UI → user action → network]

## Dependency Graph
[Which modules depend on which]

## Key Decisions & Rationale
[ADR-style decisions with tradeoffs]

## Risks & Mitigations
| Risk | Mitigation |
|------|------------|
| ... | ... |

Quality Checklist

  • Architecture pattern is appropriate for app complexity and team size
  • Module boundaries enforce separation of concerns
  • Domain layer has no framework dependencies
  • Navigation supports deep linking and state restoration
  • Offline strategy matches user expectations
  • Dependency injection is explicit, not service-locator
  • Error handling strategy is consistent across layers
  • Testing strategy is feasible with the chosen architecture

Edge Cases

  • If building for both iOS and Android, evaluate whether Flutter/KMP provides sufficient platform access or if native modules are needed for hardware-intensive features (camera, Bluetooth, AR)
  • If migrating from legacy architecture, propose an incremental migration path — not a rewrite
  • For apps with heavy native platform integration (HealthKit, ARCore), prefer native over cross-platform for those features
  • For super-apps or apps with plugin systems, consider a micro-frontend approach with independent feature modules loaded dynamically
Skills enregistrées