API Gateways
One front door.
As Shoply grows, it splits into several services. Products, orders, payments, and users. Clients shouldn't need to know about all of them. An API gateway gives them one front door.

- Many services
- Clients shouldn't care
- One front door
Through the gateway
Every request from an app goes to the gateway first. The gateway checks who the user is. It applies rate limits. Then it routes the request to the right service, based on the path. Slash orders goes to the order service, and slash products goes to the product service.
- App
- Gateway
- Check user
- Rate limit
- Right service

What gateways handle
Gateways take care of shared jobs, so each service doesn't repeat them. Authentication, rate limiting, routing, logging, and sometimes caching. The risk is that the gateway is now in front of everything, so it must be fast, and run on several machines.
| key | value |
|---|---|
| Authentication | who is this? |
| Rate limiting | not too many requests |
| Routing | path to service |
| Logging | one place to watch |
Summary
An API gateway is one front door that handles authentication, limits, and routing for all your services. Next, let's practise. Design Shoply's API.
Key takeaways- One entry point
- Shared jobs in one place
- Must be fast and redundant