API Gateway Architecture
The Tactical Entry Point
The Role of the Gateway
Without a gateway, a client (like a mobile app) would have to talk to 20 different microservices, each with its own IP and security protocol. The Gateway consolidates this into a single stable URL (e.g., `api.pingdo.com`).
API Gateway Aggregation
Pattern: Scatter-Gather
Limited by slowest service (Data Svc)
The Gateway merges 3 discrete JSON responses into a single UserProfile object, saving the client 3 round-trips and significant battery life.
Modern Pattern: The BFF (Backend for Frontends)
One gateway doesn't always fit all. A Mobile app might need a tiny, highly-compressed response, while a Desktop Dashboard needs a massive data set.
The BFF Pattern creates dedicated gateways for specific client types. This allows the front-end teams to 'own' their gateway and optimize the data aggregation specifically for their UI needs.
Conclusion
The API Gateway is the face of your infrastructure. Done right, it provides a seamless and secure experience for the developer and the user. Done wrong, it becomes a brittle shadow of the monolith we tried to escape.