Building a Server Driven Frontend Application using Micro Frontend Architecture

Aug 8, 2024

Building a Server Driven Frontend Application using Micro Frontend Architecture

Explore how micro frontend architecture revolutionizes frontend development by breaking down monolithic apps into scalable, maintainable, and modular systems.

There is a continuous pursuit of scalability, maintainability, and agility, and traditional monolithic architectures often hit roadblocks in large-scale applications. The constraints of monolithic architecture, characterized by tightly coupled components and a single, monolithic codebase, pose significant challenges as applications grow in complexity and user base. 

Micro frontend architecture, inspired by the success of microservices on the backend, presents a revolutionary approach to frontend development. By breaking down monolithic frontend applications into smaller, self-contained units, known as micro frontends, this architectural style offers a pathway to overcome the constraints of monolithic architecture. Each micro frontend operates independently, focusing on a specific feature or functionality, yet seamlessly integrates with other micro frontends to form a cohesive user experience. This modular and decentralized approach not only enhances scalability and maintainability but also fosters a culture of innovation, empowering development teams to iterate rapidly and deliver value to users with greater efficiency. 

We utilized the Build Time Integration Pattern to Implement the Micro-Frontend Architecture .

The goal is to build a low-code/no-code tool with a server-driven UI. To achieve a completely configurable UI, we have divided the features into small micro frontends called patterns. The patterns were broadly categorized into -  

  1. Simple UI patterns. 
  2. Complex patterns, which were itself like a micro App.

The patterns were completely independent of each other, and hence there was no tight coupling. Each pattern was developed separately that required a configuration json to perform the initial render.

We divided our codebase into four separate repositories, as shown below.

UI Components: This contains all the UI atoms and molecule elements needed to construct the patterns. Each UI element is given a specific name used during JSON formation. It contains a UI Render Engine responsible for setting up the UI layout as per the JSON Configuration coming from the server. The patterns further import this to configure their UI using the atomic UI elements. 

Integrated: This contains all the business logic-related code necessary to connect to the server and make the API calls to fetch the data. It also contains all the project dependencies. It is an integrated package, like a single dependency for the Patterns.  

Patterns: This contains all the Patterns/Micro-Frontends required for the project. It imports the UI render engine to form the necessary UI.  

Container Shell: This is the main container shell that renders the patterns. It contains an App Spec Render Engine responsible for setting up the layout and pages with the App Layout Specification from the server.  

We used NX mono-repo setup to improve the developer experience to manage and handle all four repositories independently.

Building the UI Rendering Engine

Here’s a high-level overview of how we built the UI rendering engine: 

1. Define the JSON Schema: 

The first step was to design a comprehensive JSON schema describing various UI components such as forms, buttons, tables, and charts. This schema includes properties for each component, like type, label, value, and actions.

[ 
 { 
 "grid": { 
 "maxRow": "2", 
 "content": [ 
 { 
 "label": { 
 "title": "Senior citizen", 
 "status": "RED", 
 "type": "SIMPLE" 
 } 
 }, 
 { 
 "label": { 
 "title": "Call Forward", 
 "status": "RED", 
 "type": "SIMPLE" 
 } 
 } 
 ] 
 } 
 } 
] 

2. Build the Rendering Engine:

We created a rendering engine that parses the JSON configuration and dynamically generates the corresponding UI components.

export function uiGenerator(jsonSchema, additionalProps = und  if (!jsonSchema || (Array.isArray(jsonSchema) && jsonSchema  //return null if empty json 
 return null; 
 if (!Array.isArray(jsonSchema)) { 
 const {type, props} = getTypeAndProps(jsonSchema);  return ComponentGenerator(type, props, additionalProps);  } 
 // loop through the array and return individual component i  return jsonSchema.map((componentJson) => { 
 if (!componentJson) return null; 
 const {type, props} = getTypeAndProps(componentJson);  return ComponentGenerator(type, props, additionalProps);  }); 
} 
//generates the component 
function ComponentGenerator(componentType, props, additionalP  const Component = componentMap[componentType];  return React.createElement(Component, { 
 ...props, 
 ...additionalProps, 
 key: getNewId(), 
 }); 
} 
function getTypeAndProps(obj) { 
 const type = Object.keys(obj)[0]; 
 const props = Object.values(obj)[0];

 return {type, props}; 
}

3. Integrate with the Backend: 

The backend service is responsible for generating and serving the JSON configurations using Mustache templates. Mustache is a logic-less template engine that allows you to create templates with placeholders. These placeholders are dynamically replaced with data at runtime. I used Mustache templates on the server to form the JSON configurations dynamically. This service can dynamically create the JSON based on user roles, data, or specific business logic. 

4. Implement Error Handling and Validation:  

Robust error handling and validation mechanisms were added to ensure the JSON configurations were correct and the UI components were rendered without issues. This includes validating the JSON schema and providing fallback UI components in case of errors. To ease the process, we used Zod with Typescript to handle runtime type validations.  

The UI Render Engine helped form the patterns. Each Pattern was configurable, with the data shown based on the User Access Role or other specific business logic.

Conclusion

We transformed our monolithic frontend into a scalable, maintainable, and modular system by adopting a micro frontend architecture and build time integration. Dividing the codebase into independent repositories for UI components, business logic, patterns, and the container shell allowed for focused development and seamless integration. This approach enabled us to create a fully configurable, server-driven UI that adapts to specific user needs, ensuring flexibility and efficiency in our application.

Subscribe to Our Newsletter

More from the engineering frontline.

Dive deep into our research and insights on design, development, and the impact of various trends to businesses.
Insight
Why Legacy Systems Make Business Growth More Expensive: Navigate A Smarter Path to Legacy Modernization
Sep 23, 2026

Why Legacy Systems Make Business Growth More Expensive: Navigate A Smarter Path to Legacy Modernization

Learn how legacy systems make business growth more expensive and how edge-first modernization can remove constraints without replacing the existing system.

Insight
SSO, Audit Logs and RBAC: The Enterprise Features AI Prototyping Tools Do Not Cover | Sarika Gautam
Sep 23, 2026

SSO, Audit Logs and RBAC: The Enterprise Features AI Prototyping Tools Do Not Cover | Sarika Gautam

Why AI-generated prototypes fail enterprise review: the context behind SSO, the cost of skipping audit logs, and how role explosion makes RBAC a product of its own.

Insight
Feature Flags as Technical Debt: The Cleanup Nobody Schedules
Sep 21, 2026

Feature Flags as Technical Debt: The Cleanup Nobody Schedules

This blog explains how unmanaged feature flags create technical debt and how teams can detect, manage, and remove them safely.

Insight
Building AI-First Enterprises: Why System Design Matters More Than AI Adoption
Sep 21, 2026

Building AI-First Enterprises: Why System Design Matters More Than AI Adoption

This blog explores how system design, architecture, and validation shape AI-first enterprises, while examining AI’s impact on software engineering and human decision-making.

Insight
The Product Studio in the AI Era: What Actually Changes | Sarika Gautam
Sep 21, 2026

The Product Studio in the AI Era: What Actually Changes | Sarika Gautam

What changes in product development when AI writes the code: the shift to architecture, the token cost of unplanned builds, and why juniors still matter.

Insight
AI and the Future of Digital Customer Experience: Where Technology Meets Human Creativity
Sep 18, 2026

AI and the Future of Digital Customer Experience: Where Technology Meets Human Creativity

A discussion on how AI, human creativity, research, and cross-functional collaboration are shaping the future of digital customer experience.

Insight
Scaling Down Before Scaling Up: Why Bigger Servers Don’t Fix Bad Architecture
Sep 17, 2026

Scaling Down Before Scaling Up: Why Bigger Servers Don’t Fix Bad Architecture

This blog explores how inefficient backend architecture can cause performance issues even under low traffic, covering practical ways to reduce database load, API latency, and resource usage before scaling infrastructure.

Footer

The Right Conversation Can

Save You Six Months.

Book a Call