Reading preferences
Concept

API Gateway

Route client requests through a shared entry point with clear boundaries.

system design, api gateway, routing

One front door

An API gateway is a service-facing entry point that can route requests and apply shared policies. It is not the same as a load balancer: a gateway may route by API path or apply authentication while a load balancer distributes traffic among instances. Products may combine these functions.

School app

  1. The school app sends a timetable request to the gateway.
  2. The gateway checks the configured credentials and routes the request to the timetable service.
  3. The service checks that the caller may see the requested timetable and returns a response through the gateway.

See the reasoning

Follow the example one step at a time

Follow a timetable request through a gateway and service. This is a prepared teaching demonstration, not live code execution.

Request

school app → gateway: timetable request

The app calls the shared entry point.

Store catalogue and checkout

A hypothetical store routes /catalogue to catalogue and /checkout to checkout. Their policies and timeouts may differ. The gateway should not log payment secrets; checkout still enforces its own authorization and validation. Routing a request is not a guarantee that the destination will succeed.

Trade-offs and failure

Central policies can simplify clients but add latency, configuration and a shared failure point. Scale and monitor the gateway, define timeouts, and protect internal service boundaries. For a small system direct service access may be simpler. Avoid turning the gateway into a tightly coupled home for all business logic.

Reflect on the concept

Four fixed questions to reinforce the reasoning. Answers are not saved or scored.

1. What can a gateway do with an incoming request?
2. Is a gateway authentication check enough to skip authorization everywhere?
3. What if the gateway is unavailable?
4. When might a gateway be unnecessary?

References and further reading