API & data modeling

Resource-oriented endpoints, pagination, idempotency, schema design for the access pattern. The bridge between LLD and HLD rounds.

About 37 min read3-question knowledge check

The mental model

An API is a contract, and a menu is the perfect analogy. A restaurant menu tells you exactly what you can order, in what form, and what you get back — you do not walk into the kitchen and rearrange the stove. The menu is stable even as the kitchen changes suppliers, cooks, and equipment. That stability is the whole point: the diner (the client) and the kitchen (the server) evolve independently because the menu (the contract) is the only thing they share, and it changes carefully and rarely.

A data model is the kitchen's layout — where ingredients are stored so that the dishes on the menu can be prepared efficiently. A kitchen organised for a breakfast menu (eggs and bread within reach) is terrible for a sushi menu (fish and rice cold and central). The critical insight, which trips up most beginners, is that you design the data model for the access pattern, not for some abstract notion of "correctness". The question is never "what is the perfectly normalized schema?" but "what queries will run, how often, and how do I lay out data so those queries are cheap?" A schema that is beautiful in the abstract and slow for the actual queries is a bad schema.

The two disciplines meet at the seam between them: the API contract should reflect the client's needs, and the data model should reflect the query patterns, and they are allowed to differ. A common mistake is exposing the database tables directly as API resources — coupling the menu to the kitchen layout, so you cannot reorganize the kitchen without reprinting every diner's menu.

Why this exists in interviews. API and data modeling is the bridge between low-level design (classes and objects) and high-level design (distributed systems). It is where "design Splitwise" meets "design it to serve 10 million users" — the LLD round asks for the objects, the HLD round asks for the scale, and this is the layer where the endpoints and the schema make both real. Interviewers probe it because a candidate who models resources cleanly and indexes for the access pattern has internalized how software actually gets built, while one who bikesheds REST verbs has read a tutorial.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision
API & data modeling — SWE lesson · PrepAtlas Tech