API Architecture Styles
REST vs GraphQL tradeoffs
- REST maps cleanly to HTTP caching and simple CDNs; multiple round trips can hurt mobile UIs.
- GraphQL reduces over-fetching with field selection but needs query cost limits and careful N+1 data loading.
- Pick per boundary: public mobile BFF might use GraphQL; internal infra often stays REST/gRPC.
gRPC basics
- IDL-first (Protobuf), binary on the wire, strong typing, streaming primitives.
- Excellent for low-latency service meshes; less browser-friendly than JSON HTTP.
- Version messages carefully; unknown fields are ignored by design in protobuf.
Webhooks (event-driven APIs)
- You push events to subscriber URLs over HTTPS with signatures and retries.
- Subscribers must be idempotent and fast (ack quickly, process async).
- Offer delivery logs, replay, and DLQ patterns for reliability.
Polling vs push models
- Polling is simple but wastes traffic; use conditional requests or cursors to reduce cost.
- Push (webhooks, SSE, WebSockets) improves latency when clients can receive inbound connections.
- Mobile often needs FCM/APNs instead of raw persistent sockets for background events.