Skip to content

Angular Micro Frontend (MFE) Introduction | Complete Guide

Micro Frontends extend the concept of microservices to frontend development. They allow you to break down a large, monolithic frontend application into smaller, independently deployable frontend applications that can be developed, tested, and deployed by different teams.

  • ๐Ÿ”ง Independent Development: Teams can work independently on different parts of the application
  • ๐Ÿš€ Independent Deployment: Deploy features without affecting the entire application
  • ๐Ÿ“ฆ Technology Diversity: Use different frameworks/versions for different parts
  • ๐ŸŽฏ Team Autonomy: Each team owns their domain completely
  • ๐Ÿ“ˆ Scalability: Scale development teams and application parts independently
  • ๐Ÿ”„ Legacy Migration: Gradually migrate from legacy systems

Angular Micro Frontends typically use Module Federation (Webpack 5 feature) to enable runtime sharing of code between applications.

  1. Host Application (Shell)

    • Main container application
    • Handles routing and navigation
    • Loads and manages remote applications
    • Shared layout and common functionality
  2. Remote Applications (Modules)

    • Independent Angular applications
    • Expose specific components/modules
    • Can be developed and deployed separately
    • Business domain-specific functionality
  3. Shared Libraries

    • Common utilities and components
    • Shared state management
    • Design system components
    • Authentication/authorization

  • Host: The application that consumes remote modules
  • Remote: The application that exposes modules to be consumed
  • Exposed Modules: Specific modules/components made available to other applications
  • Shared Dependencies: Libraries shared between host and remotes to avoid duplication
graph TB
A[Host Application] --> B[Remote 1: User Management]
A --> C[Remote 2: Product Catalog]
A --> D[Remote 3: Shopping Cart]
B --> E[Shared Library: Design System]
C --> E
D --> E

// Host Application Structure
Host App (Shell)
โ”œโ”€โ”€ Navigation & Layout
โ”œโ”€โ”€ Authentication
โ”œโ”€โ”€ Route Management
โ””โ”€โ”€ Remote Integrations
โ”œโ”€โ”€ Loan Calculator MFE
โ”œโ”€โ”€ Account Dashboard MFE
โ”œโ”€โ”€ Transaction History MFE
โ””โ”€โ”€ Investment Portfolio MFE
// Multi-team E-commerce Platform
E-commerce Host
โ”œโ”€โ”€ Header/Footer (Host)
โ”œโ”€โ”€ User Authentication (Host)
โ””โ”€โ”€ Business Domains
โ”œโ”€โ”€ Product Catalog (Team A)
โ”œโ”€โ”€ Shopping Cart (Team B)
โ”œโ”€โ”€ Checkout Process (Team C)
โ”œโ”€โ”€ User Profile (Team D)
โ””โ”€โ”€ Order History (Team E)

  • Components are built and bundled together
  • Shared at build time
  • Less flexible but simpler deployment
  • Components are loaded at runtime
  • More flexible and independent
  • Better for team autonomy
  • Server assembles the final page
  • Good for SEO and initial load performance
  • More complex infrastructure

TechnologyPurposeVersion
AngularFrontend Framework15+
Webpack Module FederationRuntime Module SharingWebpack 5+
Angular CLIDevelopment ToolingLatest
TypeScriptType Safety4.8+
RxJSReactive Programming7+
  • Azure Static Web Apps
  • AWS S3 + CloudFront
  • Netlify
  • Vercel
  • GitHub Pages

  1. Setup Module Federation: Configure webpack for each application
  2. Develop Independently: Teams work on their respective domains
  3. Integration Testing: Test remote integration in host application
  4. Deployment: Deploy remotes and host independently
  5. Monitoring: Track performance and errors across all MFEs
// Recommended Team Organization
Organization
โ”œโ”€โ”€ Platform Team
โ”‚ โ”œโ”€โ”€ Host Application
โ”‚ โ”œโ”€โ”€ Shared Libraries
โ”‚ โ””โ”€โ”€ Infrastructure
โ”œโ”€โ”€ Feature Team A (Loans)
โ”‚ โ””โ”€โ”€ Loan Calculator MFE
โ”œโ”€โ”€ Feature Team B (Accounts)
โ”‚ โ””โ”€โ”€ Account Dashboard MFE
โ””โ”€โ”€ Feature Team C (Investments)
โ””โ”€โ”€ Investment MFE

  • Angular Fundamentals: Components, modules, services, routing
  • TypeScript: Strong typing and ES6+ features
  • Webpack Basics: Understanding of bundling concepts
  • Git Workflow: Branching strategies for multiple repositories
  • CI/CD Pipelines: Automated deployment strategies
  • Node.js 18+
  • Angular CLI 15+
  • Git & GitHub/GitLab
  • Code Editor (VS Code recommended)
  • Cloud Platform Account (Azure/AWS/GCP)

Problem: Sharing state between different MFEs Solution:

  • Use shared libraries for state management
  • Implement event-driven communication
  • Consider micro-frontend communication patterns

Problem: Maintaining consistent UI across MFEs Solution:

  • Create shared design system library
  • Use CSS custom properties for theming
  • Implement style isolation strategies

Problem: Managing dependency versions across MFEs Solution:

  • Use shared dependencies in Module Federation
  • Implement version compatibility matrices
  • Automate dependency updates

Problem: Testing integrated MFE applications Solution:

  • Unit test each MFE independently
  • Integration tests for host-remote interactions
  • End-to-end tests for complete workflows

  1. Bundle Splitting: Split vendor and application code
  2. Lazy Loading: Load remotes only when needed
  3. Shared Dependencies: Avoid duplicate library downloads
  4. Caching: Implement proper caching strategies
  5. Tree Shaking: Remove unused code from bundles
  • Bundle Size Analysis: Track bundle sizes across MFEs
  • Load Performance: Monitor initial and remote load times
  • Error Tracking: Implement error boundaries and monitoring
  • User Experience: Track user interactions across MFEs

This introduction provides the foundation for understanding Angular Micro Frontends. In the following sections, weโ€™ll dive deep into:

  1. Prerequisites & Setup: Installing tools and preparing your environment
  2. Project Creation: Setting up repositories and initial project structure
  3. Module Federation: Configuring Webpack Module Federation
  4. Host Application: Building the shell application
  5. Remote Applications: Creating and configuring remote MFEs
  6. Local Development: Testing and debugging MFE integration
  7. Deployment: Publishing to Azure Static Web Apps
  8. Advanced Patterns: Best practices and advanced concepts

๐Ÿš€ Ready to get started? Continue to the Prerequisites section to set up your development environment!