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

2. Runtime Integration (Module Federation)

Section titled “2. Runtime Integration (Module Federation)”
  • 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!