Anti-Pattern: Monolithic BFF (Backend For Frontend)
Description
A Backend For Frontend (BFF) is typically a design pattern where a dedicated backend services a specific frontend user experience (e.g., Mobile App vs Web App).
The Monolithic BFF Anti-Pattern occurs when this "BFF" logic is not a separate lightweight service, but a massive Folder/Namespace inside the Core Monolith that couples the Monolith directly to the UI specifics.
Evidence
- Module:
FRONT. - Files:
FrontApiBiz(containing 71 classes/files). - Structure: A distinct namespace
WepBusiness.FRONT.FrontApiBizthat mirrors UI requirements.
Impact
- Coupling: The Monolith now knows about "Page Slugs", "View Models", and "Checkout Steps".
- Logic Drift:
- The
FrontApimight implementCalculatePricedifferently thanOMGT(Backoffice Order Management). - Result: A student sees price X on the website, but the staff sees price Y in the Backoffice.
- The
- Bloat: The core domain is polluted with presentation concerns (
FrontApi.ViewModels).
Remediation
- Extract to API: Move
FrontApito a separate deployable unit (e.g., a .NET Core WebAPI or Next.js Backend). - Consumer Driven Contracts: The Frontend should define what it needs, and the Monolith should expose generic APIs (e.g.,
GetProductPrice), which the BFF aggregates. - Use Core Logic: Ensure
FrontApicallsOMGT.PriceServiceinstead of reinventing the wheel.