Typorithm · medium

API Gateway & BFF

api-gatewayarchitecturebffrouting
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn API Gateway & BFF

0%

Microservices

An API gateway is the single public entry point that routes to internal services and handles cross-cutting concerns (auth, rate limiting, caching). A BFF — backend-for-frontend — tailors the API per client type; keep business logic out of the gateway.

An API gateway sits at the edge as the single public endpoint. Clients never call services directly; they call the gateway, which routes each request to the appropriate internal service and hides the topology behind it.

Because it sees every request, the gateway is the natural place for cross-cutting concerns: authentication, rate limiting, and response caching, so individual services need not reimplement them.

A BFF (backend-for-frontend) is a gateway tailored to one client type — for example separate web and mobile BFFs that shape responses for each. Crucially, keep business logic out: a gateway that accumulates domain logic becomes a fragile, central bottleneck.

01

Gateway = single public entry that routes to services.

02

Edge concerns: auth, rate limiting, caching.

03

BFF tailors the API per client; no business logic in the gateway.

gateway:
  entry: single-public-endpoint
  routing: to-internal-services
  concerns: auth-ratelimit-cache
  bff: backend-for-frontend
  avoid: business-logic-here

Read the implementation

Connect each part of the code to the concept before you type.

1. Single entry

The gateway is the one public endpoint clients hit, hiding the internal service topology.

entry: single-public-endpoint

2. Routing

It routes each incoming request to the right internal service.

routing: to-internal-services

3. Cross-cutting

Auth, rate limiting, and caching live at the edge so every service doesn't reimplement them.

concerns: auth-ratelimit-cache

4. BFF

A backend-for-frontend tailors the API surface to one client type (web, mobile).

bff: backend-for-frontend

5. Keep it thin

Business logic belongs in the services; a gateway that grows logic becomes a bottleneck and a hidden monolith.

avoid: business-logic-here

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

API Gateway & BFF: Lesson & Practice · Typorithm | ApplyDjinn