SevyDevy

Design an API gateway and backend-for-frontend

PremiumAPI designMedium

  • API gateway
  • Backend for frontend
  • Response aggregation

Quick answer

This API design interview question asks you to design an API gateway and backend-for-frontend. Aim for a design that exposes a clear, consistent and safe interface, then explain the resources, requests, responses and error handling. Interviewers want to see how you name resources, version the interface and handle failure cases.

The problem

Design an API gateway and backend-for-frontend (BFF) layer for a food delivery app like Swiggy or DoorDash. The gateway handles auth, routing and rate limits for every client; each BFF turns 40 internal services into one response per screen. The hard parts are partial failures, timeouts and old app versions.

Today the Android, iOS and web apps call the services (restaurants, menus, pricing, offers, orders, delivery tracking, users, payments) directly through a thin proxy. The mobile home screen makes 11 calls on launch, each app re-implements the same joins, and every internal rename breaks an old app version that users never update.

What must an API gateway and backend-for-frontend do?

  • Gateway: TLS termination, authentication, request IDs, routing by path to a BFF or the public partner API, per-user and per-IP rate limits.
  • Mobile BFF: One call per screen for home, restaurant page, cart and order tracking, returning exactly the fields the screen renders.
4 more requirementsUnlock to see all

How well must it do it?

  • Latency: Home screen response under 400 ms at p95 at the server; the app on 4G should render in under 1 second.
  • Availability: The gateway is 99.99%; a single failing downstream service must not fail a whole screen.
2 more requirementsUnlock to see all

What scale should you design for?

Use these numbers in your estimates.

The scale numbers unlock with this questionUnlock

Key concepts

  • API gateway
  • Backend for frontend
  • Response aggregation
  • Partial responses
  • Edge authentication
  • Timeout budgets

How you’ll practise

6 short steps · save and come back any time
  1. Use cases
  2. Resources
  3. Endpoints
  4. Errors, auth and limits
  5. Versioning
  6. Wrap-up

Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.

What do interviewers look for?

In any API design round.

  • Starts from the clients and the use cases
  • Names resources and operations consistently
  • Defines request and response shapes and status codes
  • Covers authentication, rate limits and idempotency
  • Plans pagination, filtering and versioning
  • Explains how clients learn about and recover from errors

Questions people ask about this interview question

Which design type is this question?
It is an API design question. You design an API gateway and backend-for-frontend and explain your choices the way you would in an interview.
Is this question asked at entry level?
It is marked Medium. Entry-level engineers can practise it, but it expects you to reason about requirements and trade-offs, not only list components.
What should I cover first?
Start with the clients, the main use cases and the resources they need. Agree on scope with the interviewer before you design anything.
Can I practise it for free?
It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.

Related questions

Updated · Written by the SevyDevy team

Premium questionSign up free, then unlock it