BLUEPRINT #03Mobile & Offline Architecture
Design Mobile Stock Trading & Market Ticker App
Referenced Architecture Primitives (6)
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 mission-critical, low-latency mobile stock trading application and real-time market data streaming pipeline supporting live price tickers, server-side data conflation, hardware-backed biometric cryptographic order signing, strict idempotent order routing, and zero double-execution guarantees during network transitions.
Interactive Architecture DiagramSynthesizing vector architecture diagram...
Functional Requirements
- Live Market Price Streaming: Stream real-time Level 1 quotes (Bid, Ask, Last Price, Volume) with sub-second chart updating for watchlists and detail views.
- Biometric Cryptographic Order Signing: Require biometric verification (FaceID / TouchID / Android BiometricPrompt) to sign order payloads using private keys locked inside hardware Secure Enclaves.
- Idempotent Order Placement: Support Market, Limit, and Stop orders with client-side purchasing power validation and bulletproof idempotency across network retries.
- Order State Lifecycle & Push Notifications: Track real-time order states (
PENDING_SUBMISSIONRECEIVEDROUTED_TO_EXCHANGEFILLED/REJECTED) with instant push execution receipts. - Stale Data Protection: Automatically flag market prices as "STALE" and disable order placement if market data heartbeat is interrupted for .
Non-Functional Requirements (SLAs/SLOs)
- Order Routing Latency: Client submission to exchange gateway receipt ().
- Zero Double-Execution: Absolute idempotency guarantee (zero duplicate orders created under network retransmission).
- UI Responsiveness & Frame Rate: Strict 120 FPS rendering without frame stutter or battery drainage during extreme market volatility.
- High Availability: uptime during active market trading hours ( downtime allowed/day).
- Security & Compliance: Zero plaintext storage of API tokens; FIPS 140-2 Level 3 hardware security compliance.
Out-of-Scope
- Complex algorithmic high-frequency options pricing Black-Scholes engines.
- Decentralized crypto blockchain settlement layer.
2. Capacity & Scale Estimation
Traffic & Scale Math
- Active Mobile Traders: accounts ( concurrent during market open/close).
- Watchlist Symbol Distribution: Average trader watches .
- Raw Exchange Ticker Frequency: per volatile symbol.
- Raw Ticks/sec without Conflation: (Would destroy mobile batteries in 15 minutes).
- Server-Side Conflation Engine:
- The backend conflates raw ticks into 2 updates/sec per symbol per mobile client.
- Conflated Stream: delivered via HTTP/2 Server-Sent Events (SSE) or WebSocket streams ( reduction in event traffic).
- Order Placement Throughput:
- Average . Peak during market opening bell () .
3. High-Level Architecture & AWS Component Mapping
Interactive Architecture DiagramSynthesizing vector architecture diagram...
Component Responsibility Breakdown
| Component | Technology | Operational Role & Configuration |
|---|---|---|
| Biometric Key Vault | iOS Secure Enclave / Android KeyStore | Generates non-exportable 256-bit ECDSA key pair (secp256r1). Private key is invoked only upon successful FaceID/TouchID prompt. |
| Market Conflation Engine | Amazon ECS Fargate + Kinesis | Aggregates sub-millisecond market ticks into fixed 500ms snapshots per symbol before multicasting to connected mobile clients. |
| Idempotency Registry | Amazon DynamoDB | Enforces strict conditional write locks on Idempotency-Key (TTL 24 hours), guaranteeing zero duplicate order executions. |
| Transactional Ledger | Amazon Aurora PostgreSQL | Stores ACID-compliant double-entry account balances, buying power reservations, and order state audit histories. |
| Exchange Dispatch Queue | Amazon SQS FIFO | Guarantees strictly ordered, exactly-once delivery of FIX (Financial Information eXchange) protocol messages to equity market makers. |
4. API Interface Design & Wire Protocols
1. Submit Biometrically Signed Order
httpPOST /v1/trading/orders HTTP/1.1 Host: trade.production.aws.internal Idempotency-Key: mob_ord_88a91c74_f0b21a_20260904 Authorization: Bearer <jwt_session_token> X-Biometric-Signature: MEUCIQDN3b6r8vK... (ECDSA P-256 Signature) X-Client-Timestamp: 1718000005120 Content-Type: application/json { "account_id": "acc_998124a87", "symbol": "NVDA", "side": "BUY", "order_type": "LIMIT", "limit_price": 125.50, "quantity": 100, "time_in_force": "DAY", "estimated_total_usd": 12550.00 }
Response: 201 Created
json{ "order_id": "ord_20260904_998124", "status": "ACCEPTED", "symbol": "NVDA", "side": "BUY", "quantity": 100, "limit_price": 125.50, "reserved_funds_usd": 12550.00, "created_at": 1718000005210 }
2. Market Ticker Stream (Server-Sent Events)
httpGET /v1/marketdata/tickers/stream?symbols=NVDA,AAPL,MSFT HTTP/1.1 Host: stream.trade.aws.internal Accept: text/event-stream
Response Stream: 200 OK
textevent: tick data: {"symbol":"NVDA","bid":125.48,"ask":125.52,"last":125.50,"vol":4829340,"ts":1718000005500} event: tick data: {"symbol":"AAPL","bid":220.10,"ask":220.15,"last":220.12,"vol":1928340,"ts":1718000005500}
5. Data Models & Storage Architecture
Interactive Architecture DiagramSynthesizing vector architecture diagram...
PostgreSQL Schema (trading_core_db)
sqlCREATE TABLE trading_orders ( order_id VARCHAR(64) PRIMARY KEY, account_id VARCHAR(64) NOT NULL, idempotency_key VARCHAR(128) UNIQUE NOT NULL, symbol VARCHAR(16) NOT NULL, side VARCHAR(4) CHECK (side IN ('BUY', 'SELL')), order_type VARCHAR(16) CHECK (order_type IN ('MARKET', 'LIMIT', 'STOP')), limit_price NUMERIC(12, 4), quantity INTEGER NOT NULL CHECK (quantity > 0), filled_quantity INTEGER NOT NULL DEFAULT 0, status VARCHAR(32) NOT NULL CHECK (status IN ('PENDING', 'ACCEPTED', 'ROUTED', 'FILLED', 'REJECTED', 'CANCELLED')), created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); CREATE INDEX idx_orders_account ON trading_orders(account_id, created_at DESC);
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 (~43%). 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