Markdown Editor

Mobile Backend Design Template (BFF, Sync, Push)

BFF, screen-shaped APIs, native-app OAuth (PKCE, DPoP), offline sync and conflicts, APNs and FCM v1 push, old versions, rate limits, MASVS

ArchitectureFullRFC 8252 (BCP 212); RFC 9700; OWASP MASVS v2.1.0CC BY-SA 4.0mobilebackenddesign

How to use: Use it when designing the server side of a mobile app that must work on poor networks and across many app versions. Fill the client and version profile and the capacity estimate first, then the sync and conflict rules per entity. The main pitfall is breaking old app versions with no minimum-version mechanism and losing offline edits through whole-record last-write-wins.

Preview

Mobile Backend Design: [App or product name]

Design document for the server side of a mobile app: the backend-for-frontend (BFF) layer, API aggregation, sign-in with OAuth 2.0 for native apps (RFC 8252, BCP 212) and token handling, offline sync and conflict resolution, push notification fan-out through Apple Push Notification service (APNs) and the Firebase Cloud Messaging (FCM) HTTP v1 API, support for old app versions, rate limiting, observability, security mapped to the OWASP Mobile Application Security Verification Standard (MASVS) v2.1.0, and operations. The app-side design (modules, local storage, UI) is covered by the Mobile architecture template (architecture/mobile-architecture). Replace every [bracketed] value and every row marked Example.

Document control

FieldValue
Document ID[MBE-001]
Apps in scope[iOS app bundle ID], [Android application ID]
BFF services[Service names and repositories]
Identity provider[Provider]
Push providersAPNs (token-based authentication), FCM HTTP v1
Security baselineOWASP MASVS v2.1.0
Version[0.1]
Status[Draft / In review / Approved / Superseded]
Owner[@mobile-backend-lead]
Approvers/reviewers[@mobile-lead], [@security-architect], [@sre-lead], [@product-owner]
Last updatedYYYY-MM-DD
Classification[Internal / Confidential]

Approvals

RoleNameDecisionDate
Mobile engineering[@name][Approve / Approve with conditions / Reject]YYYY-MM-DD
Backend engineering[@name][Decision]YYYY-MM-DD
Security[@name][Decision]YYYY-MM-DD
Operations[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft
1.0YYYY-MM-DD[@name]Example: Approved; BFF, delta sync and push live for release 5.0
1.1YYYY-MM-DD[@name]Example: Added DPoP-bound refresh tokens and minimum version enforcement

Contents

1. Scope, clients and versions

The worked example is a field service app: technicians receive jobs, work offline on site, complete checklists, take photos and sync when connected. Pair it with the client-side Mobile Architecture (architecture/mobile-architecture), which owns app modules, local storage and the app release process; this document owns everything behind the edge.

ClientPlatformsUsersNetwork profileOffline need
Technician app (Example)iOS, Android150,000 monthly active devicesOften poor or none on siteFull working day offline
Supervisor app (Example)iOS, Android, tablet layout8,000Office and vehicleRead-only cache
[Client][Platforms][Users][Profile][Need]
App version (Example)Share of active devicesReleasedStatus
5.261 %YYYY-MM-DDCurrent
5.124 %YYYY-MM-DDSupported
5.011 %YYYY-MM-DDSupported, upgrade prompt shown
4.x4 %YYYY-MM-DDBelow minimum supported version from [date]

2. Requirements and capacity

2.1 Requirements

IDRequirementPriority
MBE-REQ-001 (Example)A technician can complete a full day of jobs offline and sync without losing any changeCore
MBE-REQ-002 (Example)First screen after app start loads in under [1.5 s] at the 90th percentile on 4GCore
MBE-REQ-003 (Example)New job assignments reach the device within [60 s] when it is onlineCore
MBE-REQ-004 (Example)App versions released in the last [12 months] keep workingCore
MBE-REQ-005 (Example)A stolen device can be cut off within [5 min] of the reportCore
MBE-REQ-006 (Example)Supervisors see live technician locationsBelow the line for this release
[MBE-REQ-NNN][Requirement][Core / Below the line]

2.2 Capacity estimate

Example assumptions: 60,000 daily active devices, 40 BFF calls per device per day, 25 % of daily calls in the peak hour, each BFF call fanning out to 3 domain service calls.

QuantityCalculationResultConsequence
BFF calls per day60,000 x 402,400,000Modest; one small autoscaling BFF pool per region is enough
Peak-hour BFF rate2,400,000 x 25 % / 3,600 sAbout 167 per secondPlan for 3x headroom: 500 per second
Domain calls at peak167 x 3About 500 per secondAggregation must use parallel calls with per-call timeouts
Shift-start sync burst40,000 devices x 2 MB delta in 15 min (900 s)About 89 MB/s (about 711 Mbit/s)Serve photos and documents from object storage through a CDN; add random jitter of up to [10 min] to background sync
Push per day60,000 devices x 8 notifications480,000Low steady load
Broadcast push150,000 devices in 5 min (300 s)500 per secondFan-out workers must respect provider throttling and retry

3. Backend topology and BFF pattern

LayerOwnsDoes not own
CDN and API gatewayTLS, coarse rate limits, request size limits, routing, static and media cachingBusiness decisions
Mobile BFFScreen-shaped endpoints, aggregation, response shaping, app version checks, per-user rate limitsData storage, business rules
Sync serviceChange feeds per user scope, cursors, upload batches, conflict detectionDomain validation (delegated to domain services)
Domain servicesBusiness rules, data, eventsPresentation
Notification serviceTemplates, preferences, provider fan-out, delivery trackingDeciding who must be notified

Choose one BFF per experience (technician, supervisor) rather than per platform: iOS and Android show the same screens, while technicians and supervisors do not. Detailed gateway design belongs in the API gateway design (system-design/design-api-gateway).

4. API design and aggregation

IDEndpoint (Example)AggregatesPayload budgetCachingTimeout budget
API-001GET /v1/homeToday's jobs, unread messages, alertsUnder [30 KB] compressedPrivate, ETag800 ms total; 300 ms per dependency
API-002GET /v1/jobs/{id}Job, customer, site, parts, checklist templateUnder [50 KB]Private, ETag1 s
API-003POST /v1/sync/pullChanges since cursor for the user's scopePages of [500] changesNone5 s
API-004POST /v1/sync/pushBatch of client mutations with idempotency keysUp to [200] mutationsNone10 s
API-005POST /v1/media/uploadsCreates a resumable upload session in object storagen/aNone2 s
[API-NNN][Endpoint][Aggregates][Budget][Caching][Budget]

Rules:

  • Aggregate in parallel with a timeout per dependency and return partial results with a per-section status when an optional dependency fails; the home screen must render without the alerts section.
  • Return errors as problem details (RFC 9457) with a stable type URI the app can map to messages.
  • Use cursor pagination and ETag or If-None-Match revalidation; compress responses.
  • Accept an Idempotency-Key header on every mutating call, so retries after a dropped connection do not create duplicates.
  • Version the BFF API in the path and keep each version for the supported app window in section 8.
  • Choose REST or GraphQL per BFF with a decision record; if GraphQL, apply query cost limits and persisted queries (see architecture/graphql-schema-spec).

5. Authentication and token handling

TopicDesignBasis
Sign-in flowAuthorization code flow with PKCE in an external user-agent (system browser or in-app browser tab), never an embedded web viewRFC 8252 (BCP 212), RFC 7636
Redirect URIClaimed HTTPS link (universal link or app link) preferred; private-use URI scheme in reverse domain form as fallbackRFC 8252
Access tokenShort-lived ([10 to 15 min]), audience-restricted to the BFFInternal policy
Refresh tokenRotated on every use with reuse detection, or sender-constrained with DPoP; both for high-risk appsRFC 9700 (BCP 240), RFC 9449
Token storage on deviceiOS Keychain and Android Keystore-backed storage; never in plain preferences or logsMASVS-STORAGE
App and device integrityPlatform attestation (App Attest on iOS, Play Integrity API on Android) checked at sign-in and on sensitive calls as a risk signalVendor documentation
Session revocationRevoke refresh tokens per device on report of loss; BFF checks a revocation list for access tokens within [5 min]MBE-REQ-005
Offline sessionsApp works offline for up to [72 h] after the last successful refresh, then requires sign-inBusiness rule

Design the customer identity side with the CIAM solution design (security/ciam-solution-design) or, for workforce apps, the IAM solution design (security/iam-solution-design).

6. Offline sync and conflict resolution

6.1 Sync model

AspectDesign (Example)
ScopeEach device syncs the user's jobs for the past 7 days and the next 3 days, plus reference data (parts, checklist templates)
Change detectionServer change log with a monotonically increasing sequence per scope; the client keeps the last sequence as its cursor
PullPOST /v1/sync/pull with cursor; returns changes and tombstones for deletions; client applies in order
PushClient queues mutations locally, each with a client-generated ID and the base version it was made against
IdempotencyServer stores mutation IDs for [30 days]; a repeated mutation returns the original result
OrderingMutations for one job processed in client order; different jobs in parallel
ResetIf the cursor is older than the change log retention ([30 days]), the server signals a full resync of the scope

6.2 Conflict rules per entity

EntityConflict strategyRuleUser involvement
Job assignmentServer winsDispatch decides; client change rejected with reasonMessage shown
Job statusState machineOnly valid transitions accepted (see diagram); invalid ones rejectedMessage shown
Checklist answersField-level mergeDifferent fields merge; same field with different values kept as a conflictTechnician chooses
NotesAppend onlyEvery note kept with author and timeNone
PhotosAdd onlyUploads never overwrite; deletions are tombstonesNone
[Entity][Strategy][Rule][Involvement]

The server validates each pushed mutation against the current state: a mutation whose base version is older than the server version goes through the entity's conflict rule rather than being applied blindly. Return per-mutation results so the client can mark each queued item as applied, merged or rejected. Conflict-free replicated data types fit collaborative text; for business records with rules, explicit per-entity strategies are easier to reason about and audit.

7. Push notification fan-out

TopicDesign
TriggerDomain events (for example JobAssigned) consumed by the notification service; the BFF never sends pushes directly
PayloadA short, non-sensitive alert plus an identifier; the app fetches details through the BFF
APNsHTTP/2 provider API with token-based authentication (JWT signed with ES256, kid and team ID); refresh the provider token no more often than every 20 minutes and at least every 60 minutes; set apns-push-type, apns-priority, apns-expiration and, for replaceable alerts, apns-collapse-id
FCMHTTP v1 API (projects/{project}/messages:send) with short-lived OAuth 2.0 access tokens from a service account; the legacy HTTP and XMPP APIs were deprecated on 20 June 2023 and shut down from 22 July 2024
Token registryDevice token per installation with platform, app version, user and last-seen time; updated on every app start
Invalid tokensRemove the token on APNs 410 (Unregistered) or FCM UNREGISTERED (HTTP 404); do not retry
RetriesExponential backoff with jitter on provider throttling and server errors; respect provider retry hints
Silent pushesUsed only as a hint to sync; never relied on, because the operating system may delay or drop them
PreferencesPer user and per category, held by the notification service

Design templates, preferences, provider failover and delivery tracking with the notification service design (system-design/design-notification-service). Check payload limits and header rules on the current Apple and Firebase documentation before each provider client upgrade.

8. Supporting old app versions

MechanismDesign (Example)
Version signalEvery request carries App-Version, App-Build and Platform headers
Support windowVersions released in the last 12 months are supported; older versions receive an upgrade prompt for 60 days and are then blocked
Minimum versionBFF configuration per platform; requests below it receive a specific problem type that the app shows as an update screen
Soft promptRemote configuration shows an upgrade suggestion from a version threshold
API compatibilityAdditive changes only within a BFF API version; removals wait until no supported app version uses the field
Feature gatingServer-side flags by app version and platform; new features off for versions that cannot handle them
Kill switchAbility to disable a feature for one app version within [5 min] if it misbehaves
Store review delayAssume [1 to 3 days] before a fix reaches users; server fixes first where possible

Track usage of every BFF field by app version before removing it. Publish the policy in the API deprecation policy (architecture/api-deprecation-policy).

9. Rate limiting and abuse protection

LayerKeyLimit (Example)Response
EdgeIP address, coarse1,000 requests per minuteHTTP 429
BFFUser and device120 requests per minute; sync push 10 per minuteHTTP 429 with Retry-After
Sign-inAccount and device10 attempts per 15 minutesStep-up or temporary lock
Media uploadUser2 GB per dayHTTP 429 with problem type

The app must honour Retry-After and use exponential backoff with jitter; a retry storm after an outage is the most common self-inflicted load spike. Design the algorithms with the rate limiter design (system-design/design-rate-limiter).

10. Observability

SignalDesign
Trace propagationApp sends a W3C Trace Context traceparent header; the BFF continues the trace into domain services
Metrics dimensionsEndpoint, app version, platform, region, network type reported by the app
Client metricsApp start time, screen load time, sync duration, sync failures, crash-free sessions
Server metricsLatency per endpoint and dependency, error rate, aggregation partial-result rate, sync conflict and rejection rates
Push metricsSent, accepted by provider, invalid-token rate, time from event to provider acceptance
LogsStructured, no tokens or personal data; correlation by trace ID

Define dashboards per app version and alert when one version's error rate exceeds the others by a set margin. Specify the platform conventions with the observability specification (ops/observability-spec).

11. Security and MASVS mapping

OWASP MASVS v2.1.0 (January 2024) groups controls into eight categories. The backend contributes to the groups below; verify app-side controls with the OWASP Mobile Application Security Testing Guide.

MASVS groupBackend contribution
MASVS-STORAGEMinimise data sent to the device; short sync scope; server-driven remote wipe of local data on revocation
MASVS-CRYPTOServer-side key management; no secrets shipped in the app binary
MASVS-AUTHOAuth 2.0 with PKCE; authorisation enforced server-side on every call; step-up for sensitive actions
MASVS-NETWORKTLS 1.2 or later only, modern cipher suites, HSTS on web endpoints; certificate rotation plan agreed with the app team
MASVS-PLATFORMDeep links and push payloads carry identifiers only, never data or tokens
MASVS-CODEMinimum version enforcement and input validation of every field from the app
MASVS-RESILIENCEAttestation verdicts used as risk signals, not as the only control
MASVS-PRIVACYData minimisation in APIs, events and logs; consent state honoured by analytics endpoints

Treat the app as an untrusted client: validate every input, authorise every object access (broken object-level authorisation is the most common mobile API flaw), and never rely on hidden UI to prevent an action. Threat-model the BFF with the threat model template (security/threat-model).

12. Reliability and operations

IndicatorTarget (Example)
BFF availability99.9 % monthly per region
GET /v1/home latencyUnder 800 ms at the 95th percentile, server side
Sync push success99.95 % of mutations applied, merged or rejected with reason (none lost)
Event to push acceptance95 % within 30 s

Degraded modes: when a dependency fails, the BFF returns partial results with section status; when the sync service is down, the app keeps working offline and queues changes; when push providers are degraded, the app's foreground refresh still finds new jobs. Write runbooks for forced minimum version changes, mass token revocation, push provider credential rotation (APNs signing key, FCM service account) and sync change log replay.

13. Trade-offs, decisions and risks

DecisionOptionsChoice (Example)ReasonRevisit if
BFF granularityOne per platform; one per experience; noneOne per experienceSame screens on both platformsPlatforms diverge in features
API styleREST; GraphQLREST with screen-shaped endpointsSimple caching and versioningMany new screens per release
SyncCustom change log; vendor sync product; CRDT libraryCustom change log with per-entity rulesBusiness rules and audit needsCollaborative editing appears
Refresh token protectionRotation; DPoP; bothRotation now, DPoP for release 6Identity provider supportProvider supports DPoP for all clients
At 10x load (600,000 daily devices)Scale BFF horizontally; regional sync storesRegional sync stores and CDN for reference dataShift-start burst grows to about 890 MB/sBurst exceeds CDN commitment
At 0.1x load (6,000 daily devices)Keep BFF; merge into one serviceKeep the BFF, scale to two instancesVersion handling still neededNever merge into domain services
Failure modeEffectMitigation
Change log retention shorter than offline periodDevices need full resyncRetention 30 days; full resync path tested
Duplicate mutations after timeoutsDuplicate recordsMutation IDs stored and checked
Invalid tokens accumulateWasted sends, provider throttlingRemove on APNs 410 or FCM UNREGISTERED (HTTP 404)
Old app sends removed fieldErrors for a user groupField usage tracked per version before removal
Retry storm after outageOverload on recoveryRetry-After, jittered backoff, edge limits
IDRiskMitigationOwner
MBE-R-001 (Example)Users stay on unsupported versionsUpgrade prompts, minimum version enforcement, support comms[@mobile-lead]
MBE-R-002 (Example)Push credentials expire unnoticedExpiry monitoring and rotation runbook[@sre-lead]
MBE-R-003 (Example)Conflict rules lose dataConflict metrics and field-level merge tests[@mobile-backend-lead]
[MBE-R-NNN][Risk][Mitigation][@owner]

14. Glossary and references

TermMeaning in this document
BFFBackend for frontend: a server layer shaped for one client experience
CursorPosition in a change feed from which the next pull continues
TombstoneRecord that tells clients an item was deleted
PKCEProof Key for Code Exchange: binds the authorization code to the app instance that requested it
DPoPDemonstrating Proof of Possession: binds tokens to a key held by the client
Device tokenAddress issued by APNs or FCM for one app installation
ReferenceVersion or date checkedUse
RFC 8252, OAuth 2.0 for Native Apps (BCP 212)October 2017Section 5
RFC 7636, Proof Key for Code Exchange2015Section 5
RFC 9700, Best Current Practice for OAuth 2.0 Security (BCP 240)2025Refresh token protection
RFC 9449, OAuth 2.0 Demonstrating Proof of Possession (DPoP)2023Sender-constrained tokens
RFC 9457, Problem Details for HTTP APIs2023Error format
Apple Developer Documentation, Sending notification requests to APNsChecked 2026-10-23Section 7
Firebase documentation, FCM HTTP v1 API and migration from legacy APIsChecked 2026-10-23Section 7
OWASP MASVS, mas.owasp.orgv2.1.0, released 18 January 2024, CC BY-SA 4.0Section 11

Standard and licence note

Based on the public IETF RFCs 8252, 7636, 9700, 9449 and 9457 and on the public Apple Push Notification service and Firebase Cloud Messaging documentation. The security section maps backend controls to the control group names of the OWASP Mobile Application Security Verification Standard (MASVS) v2.1.0 by the OWASP Mobile Application Security project, licensed under CC BY-SA 4.0; only group identifiers are used and the mapping text is original. If you adapt or redistribute OWASP material from the MASVS itself, attribute OWASP and share your adaptation under CC BY-SA 4.0 (ShareAlike). The rest of the structure and wording is original to this collection. Check the current official versions before use. Apple, APNs, App Attest, Google, Firebase, Android and Play Integrity are trademarks of their owners; this template is not affiliated with or endorsed by them. Template licence: MIT.

Related templates