Markdown Editor

Mobile App Architecture Template

Mobile app architecture: native vs cross-platform, MVVM/Clean layers, offline sync, secure storage, auth, privacy, releases, testing

Arquitectura y diseño de sistemasEstándarmobile

Cómo usar: Use when designing a new mobile app or a major rework. Fill users, devices and connectivity first, since offline needs drive most decisions. The main pitfall is having no forced-update or remote-config path at launch; you cannot roll back code on users' phones.

Vista previa

Mobile App Architecture: [App name]

Architecture document for a mobile application: platforms and development approach, app architecture pattern, modules, networking and offline sync, local storage and encryption, push notifications, authentication, analytics and privacy, performance targets, release management (store review, phased rollout, forced update), crash reporting and testing. Based on common industry practice and the published platform guidance from Apple and Google. Replace every [bracketed] value and every row marked Example; the examples follow a field-service app used by technicians with poor connectivity.

FieldValue
Document ID[MOB-ARCH-001]
App[Name, bundle ID / application ID]
Version[0.1]
Status[Draft / In review / Approved]
Owner[@mobile-lead]
Reviewers[@architect], [@security], [@backend-lead]
Last updatedYYYY-MM-DD
Related[API specification], [Design system], [Privacy assessment], [ADRs]

1. Context and drivers

ItemValue
UsersExample: 3,500 field technicians; 40,000 customers using the booking feature
DevicesExample: Company Android rugged devices (Android 12+), personal iPhones (iOS 17+)
ConnectivityExample: Often offline in basements and rural sites for up to 8 hours
Key journeysView job list, complete checklist, capture photos and signature, sync
Key requirementsFull offline job completion; no data loss; photos up to 30 per job
IDDriverTarget
MOB-01Example: Offline completion of a job100% of job steps work without network
MOB-02Example: Data safetyZero lost job records; sync conflicts resolved without user data loss
MOB-03Example: Time to release a fixCritical fix in users' hands within 48 h
[MOB-nn][Driver][Target]

2. Platforms and development approach

OptionStrengthsWeaknessesFit
Native (Swift / Kotlin)Best platform fidelity and API access; best performanceTwo codebases and teamsExample: Medium
Cross-platform with native rendering (for example Flutter, React Native)One codebase for most UI and logicBridge or engine overhead; native modules still neededExample: High
Shared logic only (for example Kotlin Multiplatform)Shared domain and data layers; native UITwo UI codebasesExample: Medium
Web or PWAOne codebase; no store reviewLimited background sync and device APIs on iOSLow for offline-heavy use

Decision: [approach, framework and version policy, ADR link]. Example: cross-platform framework for UI and logic, with native modules for the barcode scanner and background upload; minimum OS versions iOS 17 and Android 12 (ADR-014).

3. App architecture pattern and modules

Pattern: [e.g. MVVM with Clean Architecture layers]. Dependencies point inwards: UI depends on view models, view models on use cases, use cases on repository interfaces; data sources implement those interfaces.

ModuleResponsibilityOwner
core-domainExample: Entities, use cases, validation rules[@team]
core-dataRepositories, local database, API client, sync engine[@team]
feature-jobsJob list and job detail screens[@team]
feature-checklistChecklists, photos, signature[@team]
platform-servicesCamera, location, push, secure storage wrappers[@team]
design-systemTokens and shared components[@team]
[module][Responsibility][@team]

4. Networking and offline sync

TopicDesign
API styleExample: REST over HTTPS via the mobile BFF; JSON; gzip
Timeouts and retriesConnect 10 s, read 30 s; exponential backoff with jitter; retry only idempotent calls or calls with an idempotency key
Offline modelLocal database is the source for the UI; writes go to local database and an outbound sync queue
Sync triggerOn connectivity change, app foreground, and background task every 15 min where the OS allows
DownloadDelta sync using updated_since cursor; jobs for the next 3 days pre-fetched
UploadQueue processed in order per job; photos uploaded in chunks with resume
Conflict resolutionExample: Server wins for job assignment; field-level merge for checklist answers; user prompted only when the same answer differs
Certificate handlingSystem trust store; certificate pinning considered and rejected because of rotation risk (ADR-016)

5. Local storage and encryption

DataStoreProtectionRetention
Example: Jobs, checklistsSQLite databaseEncrypted with a key held in Keychain or Android KeystoreDeleted 7 days after sync
Example: PhotosApp sandbox filesFile protection class "complete until first user authentication" (iOS); encrypted file API (Android)Deleted after confirmed upload
Example: TokensKeychain / KeystoreHardware-backed where availableUntil logout or expiry
Example: PreferencesPlatform preferencesNot sensitiveApp lifetime

Rules: no personal or business data in logs; screenshots blocked on screens with customer data where policy requires; remote wipe of app data on device unenrolment through mobile device management.

6. Push notifications

TopicDesign
ProvidersAPNs (iOS) and Firebase Cloud Messaging (Android) via [notification service]
PayloadExample: Notification text plus job ID; no customer data in payload
PermissionRequested in context after the first job assignment, not at first launch
Deep linksapp://jobs/{id} handled by router; verified universal links / app links for web URLs
Silent pushesUsed to trigger sync; app tolerates them being throttled by the OS
Token managementRegistered at login; removed at logout; refreshed on change

7. Authentication and authorisation

TopicDesign
FlowExample: OAuth 2.0 authorisation code with PKCE in the system browser (ASWebAuthenticationSession, Custom Tabs)
TokensShort-lived access token (15 min); refresh token rotated on use, stored in secure storage
OfflineApp usable offline for up to 72 h after last successful refresh; then re-authentication required
Device unlockOptional biometric unlock of the local session
AuthorisationEnforced by the API; app hides actions the role cannot perform

8. Analytics and privacy

TopicDesign
Events collectedExample: Screen views, sync success and failure, job completion time; no free text, no location trails
ConsentAnalytics off until consent where required; choice changeable in settings
TrackingNo cross-app tracking; App Tracking Transparency prompt therefore not needed
Store declarationsApple privacy nutrition labels and Google Play Data safety form updated with every change to data collection
Privacy manifestiOS privacy manifest lists required-reason APIs and SDKs
Third-party SDKsAllow-list reviewed for data collection; versions pinned

9. Performance targets

MetricTargetMeasured on
Cold start to interactiveExample: p90 <= 2.0 sLow-end supported Android device
Screen transitionp90 <= 300 msBoth platforms
Frame rendering< 1% slow frames on job listBoth platforms
Crash-free sessions>= 99.8%Production
ANR rate (Android)Below Google Play's bad-behaviour threshold; Example: internal target 0.2%Android vitals
App download size<= 40 MBStore listing
Full sync of 3 days of jobs<= 20 s on 4GField test

10. Release management

TopicDesign
CadenceExample: Every two weeks; release branch cut on Monday
Store reviewSubmit 3 working days before target date; expedited review only for critical fixes
Phased rolloutiOS phased release over 7 days; Google Play staged rollout 5%, 20%, 50%, 100%
Rollout gatesHalt if crash-free sessions fall below 99.5% or sync failure rate doubles
Feature flags and remote configNew features shipped dark and enabled remotely; kill switch per feature
Forced updateBackend returns minimum supported version; app shows blocking update screen below it, soft prompt below recommended version
API compatibilityBackend supports the last 3 app versions or 90 days, whichever is longer
SigningKeys held in CI secrets and platform signing services; access limited to release managers

11. Crash reporting and monitoring

TopicDesign
Crash reportingExample: [Crash reporting SDK] with dSYM and mapping file upload in CI
Non-fatal errorsSync failures and API errors reported with error code and app version
Personal dataScrubbed from breadcrumbs and logs before sending
AlertingNew crash cluster affecting > 0.1% of sessions pages the mobile on-call
TriageDaily during rollout; weekly otherwise

12. Testing

LayerScopeToolingWhen
UnitUse cases, view models, sync logicExample: Platform unit test frameworksEvery pull request
IntegrationRepositories with local database and mocked APITest containers or mock serverEvery pull request
UIKey journeysPlatform UI testing frameworksNightly
Device matrix8 devices covering min OS, small screens, low memoryDevice cloudBefore release
Offline and syncAirplane mode, flaky network, conflictsNetwork conditioner and scripted scenariosBefore release
UpgradeInstall previous version, create data, upgradeScriptedBefore release
AccessibilityScreen readers, dynamic type, contrastVoiceOver, TalkBack, scannersEach release

Standard and licence note

Based on common industry practice for mobile application architecture and on public platform guidance from Apple and Google (store review, phased or staged rollout, privacy declarations). Store policies and thresholds change; check the current versions before each release. Original text written for this collection; examples are illustrative and not legal advice. Template licence: MIT.

Plantillas relacionadas