API Gateway vs BFF vs Direct Service Access
API Gateway
Infrastructure edge
- - Routing/auth/rate controls
- - Not UI contract shaping
BFF
Frontend-oriented layer
- - Aggregate + shape responses
- - Client-specific orchestration
Direct access
No middle adaptation
- - Simple topology
- - Higher frontend coupling risk
Selection
Fit-for-context decision
- - Product/client diversity
- - Ownership + ops capacity
Core Lens
Choose boundaries by responsibility and team topology, not by naming convention.
Flow
These patterns are often discussed together, but they should not be treated as interchangeable. A good architecture uses each layer for a clear purpose. The gateway should remain focused on platform-level concerns. The BFF should improve frontend delivery speed and contract quality without becoming a replacement domain service. Direct service access should stay simple and intentional, not become accidental tight coupling. Strong frontend engineers know when each model improves developer experience and when it only adds extra hops and duplicated logic.
Quick Decision Guide
Senior-Level Decision Guide:
- API Gateway is the platform entry layer for cross-cutting concerns like routing, auth enforcement, quotas, rate limiting, and traffic policy. - BFF is a client-focused application layer that shapes payloads, orchestrates backend calls, and optimizes contracts for a specific frontend surface. - Direct service access can be a valid choice when the system is simple, the service contracts are stable, and frontend-specific shaping is minimal. - Do not pick these patterns by trend. Choose them based on number of clients, contract diversity, ownership boundaries, security constraints, and iteration speed needs. - The biggest mistake is letting every layer absorb partial business logic until responsibilities become blurred.
Why This Matters
This topic matters because frontend teams often feel the pain first when backend boundaries are unclear. Symptoms include:
In interviews, a strong answer shows that you understand why these layers exist and how to keep them from becoming architectural clutter.
Pattern Definitions
API Gateway
An API Gateway is the common entry point into backend systems. It usually handles:
The gateway is primarily an infrastructure and platform boundary, not a frontend-specific view layer.
BFF (Backend for Frontend)
A BFF is a backend layer designed around the needs of a specific client or product surface. It usually handles:
A BFF is an experience and contract optimization boundary, not a home for core domain rules.
Direct Service Access
Direct service access means the frontend calls backend services directly, with little or no intermediate client-specific backend layer. This can work well when:
Direct access is not automatically bad. It becomes risky when complexity grows but boundaries do not evolve.
Typical Request Flow
Gateway Only
Client -> API Gateway -> Backend Services
This is common when platform policies matter, but client-specific shaping is still limited.
Gateway + BFF
Client -> API Gateway -> BFF -> Backend Services
This is common when the organization wants a shared entry layer plus a client-specific shaping layer.
Direct Service Access
Client -> Backend Service
This is simplest operationally, but it exposes the frontend more directly to backend contract changes.
A strong answer should explain not only the flow, but also why each hop exists.
Responsibility Split
A good architecture keeps each layer narrow and explicit.
What belongs in the API Gateway
What belongs in the BFF
What belongs in domain services
What should stay in the frontend
If the BFF starts owning domain truth, the boundary becomes dangerous. If the frontend starts orchestrating too much, the client becomes fragile and hard to evolve.
Tradeoffs by Pattern
API Gateway
Strengths
Weaknesses
BFF
Strengths
Weaknesses
Direct Service Access
Strengths
Weaknesses
When BFF Is Especially Useful
A BFF becomes very valuable when:
Example:
A dashboard page may need profile data, feature flags, notifications, recommendations, and usage summaries. Without a BFF, the client may issue many calls and own retry/orchestration complexity. With a BFF, the client can call one contract designed for that surface.
When Direct Access Is Enough
Direct service access can be the right choice when:
Example:
A simple settings page that reads and updates profile preferences from one service may not need a BFF. Adding a BFF there could add complexity without meaningful product benefit.
Team Topology and Ownership
Boundary decisions should reflect how teams actually work.
Small team or early product
A direct model or light gateway can be enough.
Multiple frontend clients
A BFF often helps when web, mobile, and partner clients need different payloads or release independently.
Platform-heavy organization
A gateway plus BFF layering is common when the platform team owns shared edge concerns and product teams own client-specific contracts.
The wrong architecture often comes from ignoring team boundaries. A technically elegant model can still fail if no team clearly owns the layer.
State Management and Frontend Impact
These backend boundary choices directly affect frontend state architecture.
With direct service access
The frontend may need to:
With a BFF
The frontend often becomes simpler because:
Important nuance
A BFF does not remove the need for good frontend state management. It only reduces unnecessary backend-topology awareness in the client.
Failure Modes
Common mistakes include:
1. Frontend recreates orchestration because BFF is too thin
This defeats the purpose of the BFF.
2. BFF becomes a hidden domain layer
This causes business logic duplication and long-term maintenance pain.
3. Gateway absorbs frontend-specific shaping
This makes the gateway harder to maintain and turns infrastructure into product logic.
4. Direct access survives too long as complexity grows
The frontend becomes tightly coupled to too many backend services.
5. Ownership is unclear
Teams do not know who should change contracts, fix bugs, or evolve payloads.
Selection Heuristics
Use these questions:
1. How many clients do we have?
2. Do they need different payload shapes?
3. Is the frontend currently orchestrating multiple services?
4. Are security and token handling simple enough for direct access?
5. Does the org have clear ownership for a BFF layer?
6. Would a BFF meaningfully improve frontend speed and reduce coupling?
A simple heuristic:
Interview Rubric
A weak answer says:
A better answer says:
A strong answer should include:
Responsibility Boundaries
A good rule of thumb:
The more clearly you can say this in an interview, the stronger your answer sounds.
Topology and Team Fit
Do not choose architecture by fashion. Choose it by:
A simpler architecture with clean ownership is often better than a layered one with vague boundaries.
Interview Deep Dive
A staff-level answer usually includes both:
1. the best choice for the current system
2. the likely evolution path as product scope grows
Example:
This kind of answer shows architectural judgment instead of pattern memorization.