One API for Web and Mobile? That’s the Problem...
Why mobile and web apps need different API responses and how BFF makes it possible!

You’ve ordered something on Flipkart on your phone and probably on a laptop too.
Have you noticed how the mobile app feels faster?
The checkout is simpler, with fewer elements on screen, and it loads quickly even on an average 4G connection. The website, on the other hand, offers more - filters, recommendations, detailed descriptions and promotional banners.
Same company. Same products. Same database. Yet two very different experiences.
That’s not an accident. It’s powered by a pattern called Backend for Frontend (BFF).
The problem...
When you open the checkout on the Flipkart app, your phone doesn’t need everything. It only needs:
What’s in your cart
Your saved address
The total price
That’s it.
But if the app talks directly to the same API as the website, it receives a much larger response, say 9KB of data, while it actually uses only around 2KB. On a slow connection, that extra weight directly impacts loading time.
Now flip to the website. It actually needs all that extra data - the “you might also like” section, full product details, promotional banners, and more.
BFF puts a layer in between
Instead of the app and website both hitting the core API directly, each gets its own small backend layer, i.e; its own backend for frontend.
The Mobile BFF knows what the app needs. It calls the core API, cuts out everything unnecessary, and sends back a smaller response.
The Web BFF knows the website needs more. It calls the core API, pulls in recommendations and promo data from other services, stitches it together, and sends one rich response to the browser.
The core API doesn't change. It just serves the same data. The BFF decides what shape that data takes for each client.
Why this makes development easier?
Let’s say the mobile app needs to show checkout data in one go instead of making three separate API calls.
Without BFF, the frontend team has to ask the backend team to create a new API for this, and wait until it’s ready.
With BFF, the app team can do this themselves. They use their BFF to call those three APIs, combine the data, and send a single response to the app.
Now take the website. It might need extra data like recommendations or banners.
With BFF, the website team can update their own BFF to include this - without affecting the mobile app at all.
So each team works on their own layer and doesn’t have to wait on others.
What this looks like in code?
Say the core API returns this for a product:
{
"id": "prod_123",
"name": "Anime t-shirt",
"price": 100,
"stock": 42,
"images": ["img1.jpg", "img2.jpg", "img3.jpg"],
"description": "Description...",
"seo_tags": ["naruto", "anime", "manga"],
"recommendations": ["prod_456", "prod_789"],
"warehouse_code": "HYD-B4",
"internal_margin": 0.34
}
The Mobile BFF strips it down to just what the app needs:
// mobile-bff/product.js
app.get('/mobile/product/:id', async (req, res) => {
const product = await coreAPI.getProduct(req.params.id);
res.json({
id: product.id,
name: product.name,
price: product.price,
stock: product.stock,
image: product.images[0], // just one image, not all three
});
});
The Web BFF keeps the full response and pulls in recommendations on top:
// web-bff/product.js
app.get('/web/product/:id', async (req, res) => {
const [product, recommendations] = await Promise.all([
coreAPI.getProduct(req.params.id),
recommendationService.getRelated(req.params.id), // extra call, only web needs this
]);
res.json({
...product,
recommendations,
});
});
Same core API. The mobile app gets a clean ~0.8KB response. The website gets a rich 6KB response with everything it needs. Neither team had to touch the core API to make this happen.
Caching - the cherry on top
BFF is also a great place to cache. The product name and image on Flipkart aren't changing every second - so why fetch them fresh every time?
// mobile-bff/product.js
app.get('/mobile/product/:id', async (req, res) => {
const cached = await cache.get(`mobile:product:${req.params.id}`);
if (cached) return res.json(cached);
const product = await coreAPI.getProduct(req.params.id);
const response = { id: product.id, name: product.name, price: product.price, image: product.images[0] };
await cache.set(`mobile:product:${req.params.id}`, response, { ttl: 60 });
res.json(response);
});
Mobile caches for 60 seconds. Web might cache recommendations for 5 minutes but keep stock fresh. Each client decides what's okay to cache - without touching the core API.
BFF is simple: each client gets a backend designed just for it.
The app stays fast with minimal data, while the website gets a fuller experience.
— AbhignaConsole Diaries — a developer’s notes
Connect with me on LinkedIn: a6h1gna
Comments
Join the discussionNo comments yet. Be the first to comment.



