← Module 07 · System Architecture
MODULE 07 · SYSTEM ARCHITECTURE

API Gateway

An API Gateway sits between clients and backend services, routing requests and applying shared controls.

01 · What is it?

An API gateway is a controlled entry point for API traffic.

Instead of every mobile app, browser, or partner integrating with every backend service, clients can call one public API boundary. The gateway decides where each request should go and applies rules that should be consistent across services.

Core idea: one managed API entry point can hide backend complexity while making shared policies easier to operate.

02 · Think of it like...

Think of an API gateway like the reception desk of an office building.

The desk checks who is allowed in, reads the visitor’s destination, applies building rules, and directs the visitor to the right department. The departments do the actual work; the desk creates a consistent front door.

Client
API Gateway
Backend Services

03 · What does it do?

A gateway concentrates cross-cutting API responsibilities at the boundary, so product teams do not have to rebuild the same controls in every service.

Authenticate

Check whether the caller presents a valid identity, token, or API key.

Authorize

Apply access rules before a request reaches a protected capability.

Route

Send a path such as /orders or /profile to the right service.

Rate limit

Control how many requests a client can make in a time window.

Validate

Reject malformed or disallowed requests at the boundary.

Observe

Record useful request logs, metrics, traces, and correlation IDs.

Trade-off: centralizing these controls improves consistency, but the gateway becomes an important dependency. It needs capacity, monitoring, safe deployments, and a clear failure plan.

04 · Where is it used?

API gateways are especially useful when several clients or services need one stable, policy-controlled API boundary.

Mobile and web apps

Give different clients a stable API surface while backend services evolve behind it.

Partner APIs

Apply authentication, quotas, versioning, and monitoring for external consumers.

Microservices

Keep service discovery and internal routing away from client code.

Multiple backends

Combine data from account, catalog, order, and payment services behind one request.

Different client needs

Shape a response so a mobile client receives less data or fewer round trips.

Migration periods

Route some traffic to a new service while the old implementation is retired.

05 · Example

Imagine a food-delivery app that serves customers, restaurants, and delivery partners.

Delivery App
API Gateway
Order · Payment · Courier

What happens

  1. The app sends one authenticated request to create an order.
  2. The gateway checks the token, validates the request shape, and applies a client rate limit.
  3. It routes order work to the order service, which coordinates with payment and courier services.
  4. The gateway returns a consistent response and records the request ID for support and debugging.

Why the product team cares

The mobile app has one address to integrate with even when backend ownership is split across teams.

During a promotion, the team can protect the API from abusive traffic, watch error rates by route, and release service changes without forcing every client to update at once.

The gateway coordinates the boundary; it does not replace the order, payment, or courier services that own the business rules.

06 · How it connects

Client
API Gateway
Load Balancer
Service Instances
Data / External APIs

A gateway and a load balancer can appear together, but they answer different questions. The gateway decides whether and where an API request should enter the system; the load balancer chooses a healthy instance among equivalent destinations.

PM Perspective: Ask which policies belong at the shared boundary, which team owns them, what happens when the gateway is slow or unavailable, and which metrics prove that the user experience is protected.

07 · Do Not Confuse

API Gateway ≠ Load Balancer

API gateway: manages an API boundary with authentication, rate limits, validation, and routing. Load balancer: distributes traffic across healthy instances.

API Gateway ≠ Backend Service

API gateway: directs and protects requests. Backend service: owns business logic such as calculating a price or creating an order.

API Gateway ≠ Authentication System

API gateway: enforces an access decision at the edge. Authentication system: proves or manages identity and issues credentials.

API Gateway ≠ Service Mesh

API gateway: usually manages traffic entering from clients. Service mesh: manages communication and policy between internal services.

API Gateway ≠ CDN

API gateway: handles API requests and shared controls. CDN: caches and serves content from edge locations close to users.

Gateway ≠ Automatic Scalability

A gateway can protect or route traffic, but it does not automatically add backend capacity. Scaling and capacity planning remain separate decisions.

09 · What to Remember

An API gateway is a managed front door for backend APIs.

It routes requests and centralizes shared controls such as authentication, rate limits, validation, and observability.

For a product decision, name the client promise, the policies being centralized, the gateway owner, the failure plan, and the metrics that show the boundary is helping.

↑