BFF pattern: separate backend for each client type. Web, mobile, IoT — each has different needs.
The Problem with One API¶
Mobile needs different data than web. One API = over-fetching, under-fetching, compromises.
Architecture¶
Web UI → Web BFF → [Order Service, User Service, Analytics]
Mobile → Mobile BFF → [Order Service, User Service]
IoT → IoT BFF → [Telemetry Service]
Example¶
// Web BFF — full data
app.get('/api/dashboard', async (req, res) => {
const [orders, stats, notifs] = await Promise.all([
orderService.getRecent(20),
analyticsService.getDashboard(),
notificationService.getUnread()
]);
res.json({ orders, stats, notifs });
});
// Mobile BFF — optimized response
app.get('/api/dashboard', async (req, res) => {
const orders = await orderService.getRecent(5);
res.json({ orders: orders.map(o => ({ id: o.id, status: o.status })) });
});
Summary¶
BFF is the right choice with multiple client types. Each BFF should ideally be owned by the team developing that frontend.
Need Help with Implementation?¶
Our team has experience designing and implementing modern architectures. We’re happy to help.