# API Gateway

> One front door for all clients — routes, transforms, and fans out requests to the right services.

- **Category**: Microservices
- **Subcategory**: API Design
- **Canonical URL**: https://designpattern.fyi/patterns/api_gateway/

---

## Description
Clean, reusable architecture pattern.


## Use Cases
Mobile app hits POST /checkout — the gateway authenticates the JWT, routes to Order Service, fans out to Inventory and Payment, then returns a unified response. Mobile team never knows there are 3 services involved.





## Trade-offs


### Advantages

- Clients talk to one URL, not 50 service endpoints

- Centralize cross-cutting concerns (auth, tracing, rate limits)

- Backend services can change/move without breaking clients

- Enables protocol translation (REST → gRPC, HTTP → WebSocket)




### Considerations & Drawbacks

- Gateway becomes a critical single point of failure — must be HA

- Risk of becoming a "gateway monolith" if business logic creeps in

- Extra network hop adds latency

- Needs its own deployment, scaling, and maintenance







---
**Reference**: [Original Source](https://microservices.io/patterns/apigateway.html)

