Container — Host Application
| Port | 8080 |
| Package | @vppos/container |
| MFE Role | Host (consumer) |
Mục đích
Container là host application — điểm vào duy nhất của hệ thống. Chịu trách nhiệm:
- Load và render tất cả Remote MFEs
- Quản lý layout (Sidebar, Header)
- Authentication & Authorization
- Routing chính
Chức năng chính
1. MFE Loading
MfeLoader— Suspense + ErrorBoundary wrapper cho mỗi MFEMfeErrorBoundary— Bắt lỗi MFE crash, hiển thị fallbackMfeSkeleton— Loading skeleton khi MFE đang load
2. Authentication
AuthInitializer— Restore token từ localStorage khi app loadAuthGuard— Redirect về/auth/loginnếu chưa đăng nhập
3. Store Selection
StoreInitializer— Auto-select store nếu chỉ có 1
4. Layout
MainLayout— Sidebar + Header + Content area- Sidebar auto-generated từ
routes.config.ts
Cấu trúc
container/src/
├── components/
│ ├── layout/ # MainLayout, Sidebar, Header
│ ├── mfe/ # MfeLoader, MfeErrorBoundary, MfeSkeleton
│ ├── guards/ # AuthGuard, RouteGuard
│ ├── AuthInitializer.tsx
│ └── StoreInitializer.tsx
├── config/
│ ├── routes.config.ts # Source of truth cho routing
│ └── mfeRegistry.ts # MFE registry
├── routes/
│ └── index.tsx # AppRoutes component
├── services/ # API cho auth, store, etc.
├── store/ # Redux store (auth, storeSelection slices)
└── App.tsx