09 / 25 · Service boundaries

API gateway

An API gateway is an entry layer that applies shared API policies and routes requests to services. Authentication, quotas and request validation may live there, but business authorization still belongs near the protected data.

What you will practise

  • Separate authentication from authorization
  • trace routing
  • bound fan-out

Before you start: Authentication, service and record ownership.

About 4 minutes · offline-generated English female narration · captions included. Diagrams are conceptual; timings are illustrative.

Download MP4Captions

Listen without the videoDownload audio

The same pre-recorded voice as the video. Starting audio pauses the video, and starting the video pauses audio.

Chapters and full transcript

Let us understand api gateway. A school reception desk checks visitor identity and sends visitors to the right office. Passing reception does not mean a visitor can open every cupboard. Services still decide which records or actions that person is permitted to access. An API gateway is an entry layer that applies shared API policies and routes requests to services. Authentication, quotas and request validation may live there, but business authorization still belongs near the protected data.

Follow the normal path. The client calls a public API address. The gateway provides a shared routing boundary instead of requiring clients to know every internal service location. Validate the request and supported identity credentials with maintained security libraries. Reject oversized or invalid traffic before forwarding expensive work. SeatSpot exposes event, order and payment services through one public API. Shared routing and coarse policies can be managed consistently, while each service owns its business rules.

Now change one condition. Event requests go to the event service; order requests go to the order service. API versions and paths should have deliberate routing rules. A common misunderstanding is this: The gateway replaces all service authorization. Each service must protect its business actions and resources. Think about this. A valid user changes /orders/17 to /orders/18. Which boundary must still verify ownership? Pause the video and make your prediction. The order service or data-access boundary must authorize that record. Passing gateway authentication is insufficient.

Let us reason with a concrete example. A mobile screen calls events and orders through one gateway. Its latency includes gateway work plus downstream waits. Two parallel calls take approximately the slower path plus overhead; two sequential calls add their delays. Real dependency behavior and timeouts determine the result. Keep routing/coarse policy central but preserve domain authorization and tracing in services. Test a gateway outage and a single unhealthy downstream service. These figures are teaching examples, not production guarantees.

Turn the idea into a design decision. The order service checks ownership and allowed actions using verified identity. Passing gateway authentication does not grant access to another visitor order. If one API request fans out, set deadlines and partial-failure behavior. A slow optional service should not hold every gateway worker indefinitely. When you try the practice task, look for this result. A verified identity does not grant access to every record.

Check your understanding. Trace requests through the boundary and test gateway capacity and redundancy. Centralizing policy is useful, but it also creates an important operational dependency. Here is a challenge. A signed-in user changes an order ID in the URL. Which component must stop cross-user access? Pause before the answer. The order service must perform resource-level authorization using verified identity. Gateway checks are useful but cannot replace ownership enforcement. For an interview, explain token checks, quotas, deadlines and resource ownership. Say what you would measure, not only which tool you would buy.

Start with an everyday picture

A school reception desk checks visitor identity and sends visitors to the right office. Passing reception does not mean a visitor can open every cupboard. Services still decide which records or actions that person is permitted to access.

Why SeatSpot needs this

SeatSpot exposes event, order and payment services through one public API. Shared routing and coarse policies can be managed consistently, while each service owns its business rules.

Trace one step at a time

Move through the diagram at your pace. Teal paths are active; unavailable components are labelled.

API clientGatewayEvent serviceOrder serviceOrders DB

Step 1 of 6 · One public API surface

Enter one API boundary

The client calls a public API address. The gateway provides a shared routing boundary instead of requiring clients to know every internal service location.

Read all six mechanism steps
  1. Enter one API boundary

    The client calls a public API address. The gateway provides a shared routing boundary instead of requiring clients to know every internal service location.

  2. Apply coarse policy

    Validate the request and supported identity credentials with maintained security libraries. Reject oversized or invalid traffic before forwarding expensive work.

  3. Route by responsibility

    Event requests go to the event service; order requests go to the order service. API versions and paths should have deliberate routing rules.

  4. Authorize the record

    The order service checks ownership and allowed actions using verified identity. Passing gateway authentication does not grant access to another visitor order.

  5. Bound aggregation

    If one API request fans out, set deadlines and partial-failure behavior. A slow optional service should not hold every gateway worker indefinitely.

  6. Operate the entry tier

    Trace requests through the boundary and test gateway capacity and redundancy. Centralizing policy is useful, but it also creates an important operational dependency.

Pause and make a prediction

A valid user changes /orders/17 to /orders/18. Which boundary must still verify ownership?

Answer aloud or write your reasoning in the lesson notes before revealing the explanation.

Correct a common misunderstanding

Claim to question: The gateway replaces all service authorization.

Better explanation: Each service must protect its business actions and resources.

Trace a protected order request

A paper or whiteboard task. No cloud account or paid infrastructure is required.

  1. Draw the client, gateway and order owner.
  2. Mark token validation at the gateway.
  3. Mark record ownership at the service and test another user’s order ID.

Check what you can explain

This is your self-check, not an automated grade. Try again without the diagram tomorrow.

0 of 3 goals checked. Choose one remaining idea to practise next.

These checkboxes reset when you leave. Use your saved lesson notes and completion marker to record lasting progress.

Teach it back

Without looking, explain what this component changes, what it does not solve and what happens if it fails. Use the animation to check your explanation, then switch to Engineering.

Try it before viewing the solution

A signed-in user changes an order ID in the URL. Which component must stop cross-user access?

Check one key idea

A valid access token means:

Your explanation and interview notes

Saved only in this browser when storage is available. Export a backup from the course page before clearing browser data or moving devices.

Loading your local notes…

Official references and next reading

The explanation, fictional examples and animations are original teaching material. Vendor behavior depends on the specific product/version; use its documentation before deploying.