{"success":true,"name":"add-a-bff-or-gateway-layer-when-many-clients-reshape-the-sam","description":"Multiple frontends each fight to adapt the same backend APIs","category":"ai-brimind","path":"ai-brimind/add-a-bff-or-gateway-layer-when-many-clients-reshape-the-sam/SKILL.md","file":"SKILL.md","content":"---\nname: add-a-bff-or-gateway-layer-when-many-clients-reshape-the-sam\ndescription: \"Multiple frontends each fight to adapt the same backend APIs\"\n---\n\n# Add a BFF or Gateway Layer When Many Clients Reshape the Same APIs\n\n## When to use\nSeveral client types (web, mobile, partner) consume your services, and each one is stitching, reshaping, and re-securing the same backend calls on its own.\n\n## Example request\nMobile app makes 7 calls and throws away 80% of the data → the reshaping belongs server-side; a backend-for-frontend serves the screen's exact shape. — Every client re-implements auth, retries, and rate limits → the same plumbing written three times; a gateway owns cross-cutting concerns once. — Internal service URLs exposed directly to browsers → internal topology becomes public contract; the edge layer is the stable face. — A BFF added for one client slowly serves all clients → it becomes a second general API nobody designed; one BFF per client experience is the pattern's actual shape.\n\n## Instructions\nAct as an edge architect who decides deliberately what stands between clients and services. Before adding or skipping the layer: 1) Map the pain: list each client, the calls it makes per screen/flow, and the reshaping it does — if clients aggregate and transform heavily, that logic is server work living in the wrong place. 2) Name the layer correctly: a gateway handles cross-cutting plumbing (auth, rate limits, routing) for all clients; a BFF serves one client experience with tailored shapes — mixing the two roles creates an accidental monolith at the edge. 3) Check the existing infrastructure first: the platform's gateway, the framework's route handlers, an existing aggregation layer — reuse before introducing a new deployable. 4) Keep the layer thin and dumb about business rules: it aggregates, reshapes, and protects; domain logic stays in the owning services, or the edge becomes the place where ownership dies. 5) If only one client exists and calls map cleanly, say so and skip the layer — an edge nobody needs is pure operational cost. Only introduce it once the client pain is confirmed and named, and explain how the layer removes duplicated client work rather than adding a fashionable hop.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #923\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}