Technical Glossary
Backend for Frontend (BFF) Pattern
Exact Definition
The Backend for Frontend (BFF) pattern is an API design strategy that creates a dedicated backend service for each type of frontend client (web, mobile, IoT), optimizing data fetching and response shaping for each client's specific needs.
Architectural Deep Dive
A single universal API often over-fetches data for mobile clients (which need minimal fields) and under-fetches for admin dashboards (which need nested relations). BFF creates separate Next.js API route groups — /api/web/* for the web portal, /api/mobile/* for the React Native app — each fetching and shaping data specifically for its consumer. This dramatically reduces mobile network payload and eliminates client-side data transformation logic.
The ERPStack Approach
We implement BFF patterns using Next.js Route Groups and tRPC router namespaces, allowing mobile apps and web dashboards to share the same PostgreSQL backend while receiving optimized, client-specific response shapes.