RADIO — Interface Definition
Defining clean interfaces between client and server, and between components.
Components and the server depend on each other — but how do they talk? The I step defines the contracts: the interfaces (APIs) that sit between any two parts of the system and spell out exactly what flows across.
Where we are in RADIO
We have components and data. Now we define how they communicate. Tap I:
What an interface is
Say “API” and everyone pictures the frontend calling the backend. That's one case — but an interface is more general: it's the agreed-upon layer between any two parts of a system that depend on each other. Define that layer well and the two sides can evolve independently.
The layers an API connects
The same idea shows up at three boundaries. In frontend system design we focus on the first two:
Anatomy of an API
Every interface — at any layer — has the same three parts. Step through them on our feed endpoint:
Client ↔ server
For the feed, the contract is a paginated fetch. The functionality is getFeed; the parameters are a page size and a cursor marking the last post you saw; the response is the next batch of posts plus a nextCursor. Send no cursor and the server can't know where to continue — it might hand back the same posts every time.
Watch the contract in motion — each request carries the cursor, each response brings the next page and a fresh one. Flip it to Autoplay to let it run, or drive it yourself in Manual:
Client ↔ client
Inside the UI, the same anatomy maps onto props and events. A Post passes its comments down to CommentsList (parameters), and the list sends events up when something changes (response). Tap the boxes:
Classify the API parts
Drop each item into the part of the API it represents:
Check your understanding
Design challenge
Define the interfaces for a “like” feature:
- Write the client↔server API: functionality, parameters, response.
- Write the client↔client contract between the post and its like button (props down, events up).
- Note what the response should include so the UI can update optimistically.
- →An interface is the contract between any two parts that depend on each other — not just frontend↔backend.
- →It appears at three layers: client↔server, client↔client, and server↔server (mostly backend).
- →Every interface has three parts: functionality, parameters, and response.
- →In the UI, parameters are
propspassed down and the response iseventsemitted up.