System Design Basics: API Gateway
Learn what is an API Gateway? A beginner-friendly guide to understanding request routing, aggregation, and how gateways simplify microservices architecture.
Imagine you are building the next big e-commerce application.
You have a mobile app and a web dashboard.
Behind the scenes, you have built a modern system using microservices.
You have a service for users, one for products, one for orders, another for payments, and a notification service. It looks beautiful on your whiteboard.
But then you start writing the code for your mobile app.
To show the user their profile page, the mobile app needs to talk to the User Service.
To show the order history, it needs to call the Order Service.
To show shipping status, it calls the Shipping Service.
Suddenly, your mobile app is making dozens of different network calls just to load one screen. It knows the IP address of every single service you built.
If you change the name of the Product Service, the mobile app breaks.
If the User Service is down, the app crashes.
If you want to check if a user is logged in, you have to write that logic inside every single microservice.
This is the spaghetti problem. It is messy, hard to maintain, and a nightmare to scale.
This is why understanding the API Gateway is critical. It is the tool that saves us from this chaos.
So let’s start with a simple definition.
What is an API Gateway?
An API Gateway is a server that sits between a client (like a mobile app or browser) and a collection of backend services.
It acts as a single entry point for all traffic coming into your system.
Instead of the client talking to ten different services, it talks to the Gateway.
The Gateway then figures out where to send the request.
Think of it as the Receptionist of your system.
When you walk into a large office building, you don’t wander around kicking open doors looking for the person you need.
You stop at the front desk. You tell the receptionist, “I am here to see the marketing manager.”
The receptionist checks your ID (Authentication), gives you a badge (Authorization), and then points you to the correct elevator (Routing).
You don’t need to know the floor plan of the building.
You just need to know where the front desk is.
In software architecture, the API Gateway is that front desk.
Why Do We Need It?
To truly understand why we use this, we need to look at what happens without it.
The Problem of Chatty Clients
In a microservices architecture, a single user action might require data from five different places.
If you don’t use a gateway, the client (your phone) has to send five separate requests over the internet.
Mobile networks can be slow or unreliable. Sending five requests means the user waits longer.
This is called “network latency.”
Every round trip takes time.
If you have a chatty client asking for data piece by piece, your app will feel sluggish.



