The Grand Unified API: Multi-Protocol Architecture
You'll learn to
- -Place GraphQL, REST and gRPC each where it fits best in one system, and say why
- -See two outside protocols served by one internal service contract, with a fallback when a dependency fails
- -Close a large design by naming which technique justifies each decision
This closing chapter mirrors the schema-design capstone in the LLD course. Instead of one more isolated case study, it works through a scenario deliberately built to use nearly every module in this course, the way a real staff-level architecture review unfolds.
An Analogy: A Shopping Mall With Three Kinds of Visitors
A mall serves shoppers, delivery drivers and shop staff. Shoppers walk in through the glass front doors and ask for anything. Delivery drivers use a standard loading bay with the same rules for every company. The shops talk to each other through a fast private corridor. Three entrances are not showing off. They suit three different needs. The same is true of the three protocols below.
The Scenario: A Multi-Sided Commerce Platform
Picture a platform serving three very different consumers: a rich web dashboard for sellers managing their storefronts, a public developer ecosystem of third-party integrations, and a high-throughput internal system connecting order, inventory and payment services. Each genuinely needs a different protocol. This is not an excuse to name three technologies. It is what a system at this scale really requires.
Layer 1: GraphQL for the Seller Dashboard
type Query {
seller(id: ID!): Seller
}
type Seller {
storefront: Storefront!
orders(first: Int, after: String): OrderConnection!
analytics: SellerAnalytics!
}A rich dashboard shows many different, data-dense views: orders, analytics, storefront settings. It benefits directly from client-specified queries. Each dashboard page fetches a different slice of the same seller data in one request, using Relay connections for paged lists, with no bespoke REST endpoint per view.
Layer 2: REST for the Public Developer Platform
GET /v1/orders/501
Authorization: Bearer eyJhbGc...Third-party developers integrating from many languages and skill levels gain more from REST's universality and simplicity than they would from GraphQL's steeper learning curve. This layer reuses the OAuth2 authorization code flow, for apps acting for a particular seller, and URL-path versioning from the platform module.
Layer 3: gRPC for Internal Service-to-Service Calls
service InventoryService {
rpc ReserveStock (ReserveStockRequest) returns (ReservationResult);
}Calls between the order, inventory and payment services happen at far higher volume than any one outside client's traffic. Speed and strict typing matter more than readability there. That is the case for gRPC's binary format and compile-time contract from the protocol modules.
Tying the Layers Together: The Gateway
An API gateway sits in front of the GraphQL and REST layers. It handles authentication and tiered rate limiting from the throttling chapter, and translates external requests into the internal gRPC calls that fulfill them. It is the protocol-translation role from the gateway chapter, now bridging three protocols instead of two. The demo is a miniature of the whole platform. A REST gateway and a GraphQL gateway both call the same internal order service. Watch what the dashboard gets when the inventory service goes down.
Resilience Threaded Throughout
- -Idempotency keys on every payment-affecting write, whichever protocol layer it entered through.
- -Circuit breakers between internal gRPC services, with fallbacks such as cached inventory counts when a dependency struggles.
- -The outbox pattern, so order-placed events are never silently lost between the order service's database write and publishing to downstream services.
- -Deadline propagation across the internal gRPC chain, so a slow inventory check does not waste payment-service resources on a request the gateway already gave up on.
On a system this large, the strongest closing move is to name which technique from which module justifies each decision, and not to assume the diagram speaks for itself. A staff-level review is graded on that reasoning as much as on the architecture.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.
Design The Grand Unified API in the API Design Lab's Full System Design act.
Discussion0
Join the Discussion
Sign in to leave comments, reply to others, or like insights.
No comments yet. Be the first to start the thread!