BLUEPRINT #01Mobile & Offline Architecture
Design Mobile News Feed with Offline-First Architecture
Referenced Architecture Primitives (4)
Click any primitive to study its algorithmic deep dive10-Stage Structure:1. Requirementsβ2. Sizingβ3. Topologyβ4. Data Modelβ5. AWS Topologyβ6. Deep-Diveβ7. Failuresβ8. SRE Playbooks
1. Problem Statement & Scope
System Mission
Design a state-of-the-art, offline-first mobile news feed client and backend synchronization architecture delivering instantaneous () feed rendering from local persistent cache, robust background delta synchronization via GraphQL/Protobuf, optimistic mutation pipelines with deterministic rollback, and intelligent battery/network-aware media prefetching.
Interactive Architecture DiagramSynthesizing vector architecture diagram...
Functional Requirements
- Zero-Latency Feed Rendering: Cold launch renders cached feed items from local SQLite storage instantly without waiting for network I/O.
- Bidirectional Delta Synchronization: Exchange only mutated/new posts since the client's last synchronized cursor/timestamp, including soft-deleted tombstone records.
- Optimistic Local Mutations: Post creations, likes, comments, and bookmark actions immediately update local SQLite and UI state; mutations queue in a durable local write-ahead log for background replay.
- Adaptive Media Prefetching: Prefetch high-resolution images/videos on unmetered high-speed WiFi; restrict prefetching to low-resolution WebP/AVIF thumbnails on cellular metered connections.
- Conflict Resolution & Monotonic Versioning: Resolve server-client data collisions deterministically using version vectors and monotonic entity timestamps.
Non-Functional Requirements (SLAs/SLOs)
- App Cold Start Time-To-Content (TTC): read latency from local SQLite ().
- UI Smoothness & Frame Rate: 120 FPS ( frame budget) on modern 120Hz ProMotion/LTPO displays; zero main-thread database or network disk I/O.
- Bandwidth Consumption: Delta sync payloads per poll ( compression vs full JSON payload).
- Battery & Thermal Budget: Minimized background wakeups utilizing WorkManager / BGAppRefreshTask; zero battery drain while app is suspended.
- Offline Durability: Local mutation queue survives app crashes, OS process kills, and device reboots.
Out-of-Scope
- Peer-to-peer (P2P) mesh feed distribution (e.g. Bluetooth LE mesh feed sharing).
- Live real-time video stream broadcasting (covered in YouTube / Live Streaming blueprints).
2. Capacity & Scale Estimation
Device & Traffic Scale
- Mobile Active Installs: devices ( DAU).
- Daily Feed Refreshes: Average .
Bandwidth & Storage Calculations
- Full Feed Payload vs Delta Sync Payload:
- Full Feed Page (20 posts with author metadata): .
- Delta Sync Payload (Protobuf delta with cursor): ( cellular data savings).
- Mobile Local Storage Budget:
- Store max 500 cached posts in local SQLite: .
- Local image/thumbnail LRU disk cache: .
3. High-Level Architecture & AWS Component Mapping
Interactive Architecture DiagramSynthesizing vector architecture diagram...
Component Responsibility Breakdown
| Layer / Component | Technology | Role & Architectural Guarantees |
|---|---|---|
| Local Persistent Store | SQLite / Android Room / iOS CoreData | Single Source of Truth. The UI never observes network responses directly; it binds reactively to local database tables. |
| Mutation State Machine | Local SQLite Queue | Manages lifecycle of offline mutations (QUEUED IN_FLIGHT COMMITTED / FAILED_RETRY). |
| Cloud Delta Gateway | AWS AppSync | Managed GraphQL gateway supporting delta synchronization, automatic Conflict Detection & Resolution (Optimistic Concurrency / Auto-Merge). |
| Backend Data Store | Amazon DynamoDB | Single-table storage maintaining post data and a dedicated Change Data Capture (CDC) Delta Table with TTL-based tombstone tracking. |
| Media Delivery CDN | Amazon CloudFront | Edge caching of resized, compressed WebP/AVIF images with Cache-Control: public, max-age=31536000, immutable. |
4. API Interface Design & Wire Protocols
1. GraphQL Delta Sync Query
graphqlquery SyncFeedTimeline($lastSyncCursor: AWSTimestamp!, $limit: Int!) { syncFeedPosts(lastSync: $lastSyncCursor, limit: $limit) { items { id authorId authorName content mediaUrl likesCount commentsCount userHasLiked version _deleted updatedAt } nextToken newSyncCursor serverTimestamp } }
2. Optimistic Like Mutation
graphqlmutation OptimisticLikePost($postId: ID!, $clientMutationId: String!, $version: Int!) { likePost(input: { postId: $postId clientMutationId: $clientMutationId expectedVersion: $version }) { postId likesCount userHasLiked version updatedAt } }
Mutation Response: 200 OK
json{ "data": { "likePost": { "postId": "post_881293a", "likesCount": 142, "userHasLiked": true, "version": 6, "updatedAt": 1718000045120 } } }
5. Data Models & Storage Architecture
Interactive Architecture DiagramSynthesizing vector architecture diagram...
Local SQLite Schema (mobile_feed_database.db)
sql-- Cached Feed Posts Table CREATE TABLE local_feed_posts ( post_id TEXT PRIMARY KEY, author_id TEXT NOT NULL, author_name TEXT NOT NULL, content TEXT NOT NULL, media_url TEXT, likes_count INTEGER NOT NULL DEFAULT 0, user_has_liked INTEGER NOT NULL DEFAULT 0, -- 0 = false, 1 = true server_version INTEGER NOT NULL DEFAULT 1, sync_status INTEGER NOT NULL DEFAULT 1, -- 1=SYNCED, 2=OPTIMISTIC_DIRTY, 3=FAILED is_deleted INTEGER NOT NULL DEFAULT 0, updated_at INTEGER NOT NULL ); CREATE INDEX idx_feed_sort ON local_feed_posts(updated_at DESC); -- Durable Mutation Queue Table CREATE TABLE local_mutation_queue ( mutation_id TEXT PRIMARY KEY, post_id TEXT NOT NULL, action_type TEXT CHECK (action_type IN ('LIKE', 'UNLIKE', 'CREATE_POST', 'COMMENT')), payload_json TEXT NOT NULL, state TEXT CHECK (state IN ('QUEUED', 'IN_FLIGHT', 'FAILED_RETRY')), retry_count INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL ); CREATE INDEX idx_mutation_state ON local_mutation_queue(created_at ASC);
Part 2: Production Deep-Dive Locked1 Coin = 24 Hours
Unlock Complete Architecture & Production Runbooks
Your Balance:40 Coins
You have explored the free architectural preview (~41%). Spend 1 Coin to unlock the remaining 6 production deep-dive sections for a full 24 hours.
Sections Included in This 24-Hour Pass:
6. Core Algorithms & Deep-Dive Workflows
7. Architectural Trade-Off Matrix & Primitive Links
8. Critical Failure Modes, Resiliency & Edge Cases
9. Production Pitfalls & Anti-Patterns (The "Top 5 Gotchas")
10. Production Runbook & Observability Guide
11. System Design Interview Rubric & Deep-Dive Strategy
Keeps page unlocked for exactly 24 hoursSpend coins to fund LLM & compute infrastructure