API Gateway & Service Boundaries

Difficulty
Importance

The problem

When a system is split into many services, clients shouldn't need to know about every single one, their addresses, or their individual failure modes — an API gateway gives clients one stable entry point, hiding the internal service topology and handling cross-cutting concerns (auth, rate limiting) in one place instead of duplicating them in every service.

Why now

Monolith vs. microservices already established that splitting a system creates many independently addressable services; middleware and request pipelines already established that shared concerns (auth, logging) benefit from being handled once rather than duplicated. An API gateway is that middleware pattern, applied at the boundary of an entire distributed system rather than inside one server.

Mental model

An API gateway is a single front door: clients only ever talk to it, and it routes each request to the correct internal service, hiding exactly how many services exist or how they're organized behind that door. It's also the natural place to put anything every request needs regardless of which service handles it — authentication, rate limiting, logging — the same middleware-chain idea already covered, just positioned at the system's edge instead of inside one server.

Requires

Used in

Projects

  • Set up a simple API gateway in front of two backend services, routing requests to the correct one based on path, with authentication handled once at the gateway
  • Refactor an internal service split (e.g. splitting one service into two) and confirm external clients see zero difference because the gateway's public interface didn't change

Examples

  • A client calling api.example.com/orders never needs to know that request is actually routed internally to an orders-service running on a completely different set of machines
  • Centralizing authentication at the gateway means adding a new internal service doesn't require reimplementing auth — it inherits the gateway's already-verified identity

Resources

Mastery checklist