This project demonstrates a complete Micro Frontend (MFE) architecture using Webpack Module Federation with React 17. It's designed to teach you everything from basic concepts to advanced production-ready patterns.
┌─────────────────────────────────────────────────────────────────────────────┐
│ SHELL APP │
│ (Port: 3000) │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ HEADER MFE (Component) │ │
│ │ (Port: 3001) │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ PRODUCTS MFE │ │ ORDERS MFE │ │
│ │ (Full Page) │ │ (Full Page) │ │
│ │ Port: 3002 │ │ Port: 3003 │ │
│ └─────────────────┘ └─────────────────┘ │
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ USER PROFILE MFE (Component) │ │
│ │ (Port: 3004) │ │
│ │ (Embedded in Products MFE) │ │
│ └─────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────┐
│ JSON SERVER API │
│ (Port: 3005) │
│ User Data & More │
└─────────────────────┘
- 5 Micro Frontends: Shell, Header, Products, Orders, User Profile
- Webpack Module Federation: Dynamic runtime integration
- Shared Dependencies: Optimized React sharing between MFEs
- Event Bus System: Cross-MFE communication
- Global Context: Shared state management
- JSON Server: Mock API for development
- AWS Deployment: Production-ready S3 and CloudFront deployment
- Development Workflow: Concurrent development of all MFEs
- Hot Module Replacement: Fast development experience
- Frontend: React 17, Webpack 5, Module Federation
- Styling: CSS3 with modern design patterns
- API: JSON Server for mock data
- AI Integration: OpenAI API for chatbot functionality
- Deployment: AWS S3, CloudFront, automated deployment scripts
- Development: Concurrently, Hot Module Replacement
mfe-project/
├── shell/ # Shell application (host)
├── header-mfe/ # Header component MFE
├── products-mfe/ # Products page MFE
├── orders-mfe/ # Orders page MFE
├── user-profile-mfe/ # User profile component MFE
├── docs/ # Comprehensive documentation
├── db.json # JSON server database
├── deploy.sh # AWS deployment script
└── package.json # Root package with all scripts
- Node.js 16+
- npm or yarn
- (Optional) AWS CLI for deployment
-
Clone and Install
git clone <repository-url> cd mfe-project npm install npm run install:all
-
Start Development Environment
# Starts all MFEs + JSON Server concurrently npm run devThis will start:
- Shell App: http://localhost:3000
- Header MFE: http://localhost:3001
- Products MFE: http://localhost:3002
- Orders MFE: http://localhost:3003
- User Profile MFE: http://localhost:3004
- JSON Server API: http://localhost:3005
-
Individual MFE Development
npm run dev:shell # Shell only npm run dev:header # Header MFE only npm run dev:products # Products MFE only npm run dev:orders # Orders MFE only npm run dev:profile # User Profile MFE only npm run api # JSON Server only
Mock API server provides user data and can be extended for more endpoints:
- Endpoint: http://localhost:3005
- User Data:
/user- Current user information - Extensible: Add more endpoints in
db.json
-
Configure Environment
# Create .env file with: AWS_ACCESS_KEY_ID=your_access_key AWS_SECRET_ACCESS_KEY=your_secret_key AWS_REGION=your_region S3_BUCKET_NAME=your_bucket_name CLOUD_FRONT_DISTRIBUTION_ID=your_distribution_id -
Deploy All MFEs
npm run deploy:all
-
Deploy Individual MFEs
npm run deploy:shell npm run deploy:header npm run deploy:products npm run deploy:orders npm run deploy:profile
Please refer to /docs for detailed explanation of the project.
Happy Learning! 🎉
This project covers everything you need to understand Micro Frontend architecture in a production environment.