@multisystemsuite/create-mf-app 1.0.11 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +459 -68
  2. package/dist/index.js +11407 -2910
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  **`@multisystemsuite/create-mf-app`** — TypeScript CLI that scaffolds production-grade **enterprise microfrontend platforms** using React 19, Vite 7, Module Federation, React Router, Material UI, Docker, and npm workspaces.
4
4
 
5
+ Includes **10+ architect-level pillars** — security, observability, scalability, failure recovery, folder structure, CI/CD, accessibility, DX, and a capstone architect guide with audit scripts for every pillar.
6
+
5
7
  Inspired by **Module Federation** — optimized for React microfrontends, Vite, runtime federation, SaaS dashboards, and internal developer platforms.
6
8
 
7
9
  ---
@@ -15,12 +17,14 @@ Inspired by **Module Federation** — optimized for React microfrontends, Vite,
15
17
  - [CLI reference (create-mf-app)](#cli-reference-create-mf-app)
16
18
  - [Custom child & shared app names](#custom-child--shared-app-names)
17
19
  - [Enterprise platform flags](#enterprise-platform-flags)
20
+ - [Enterprise architect pillars](#enterprise-architect-pillars)
18
21
  - [Generated monorepo structure](#generated-monorepo-structure)
19
22
  - [Infrastructure & deployment (parent workspaces)](#infrastructure--deployment-parent-workspaces)
20
23
  - [MF Platform CLI (inside generated projects)](#mf-platform-cli-inside-generated-projects)
21
24
  - [Using corelib (shared library)](#using-corelib-shared-library)
22
25
  - [Enterprise design system & theming](#enterprise-design-system--theming)
23
26
  - [Module Federation](#module-federation)
27
+ - [Performance & federation architecture](#performance--federation-architecture)
24
28
  - [SDK packages](#sdk-packages)
25
29
  - [Task runner & build cache](#task-runner--build-cache)
26
30
  - [Plugins & devtools](#plugins--devtools)
@@ -57,6 +61,7 @@ npx create-mf-app my-platform --type=parent --children=billing,orders --shared=c
57
61
  npm run build
58
62
  node dist/index.js my-platform --control-plane -y
59
63
  node dist/index.js my-platform --type=parent --children=admin,billing --shared=corelib -y
64
+ node dist/index.js add-child analytics --cwd=./my-platform --port=4205 -y
60
65
  ```
61
66
 
62
67
  **Global install** (optional):
@@ -108,10 +113,11 @@ Then use the scripts in [How to use the generated project](#how-to-use-the-gener
108
113
  - **`task-runner/`** — parallel builds + hash cache (`.mf/cache`)
109
114
  - **`plugins/`** — React, Vite, Federation, MUI, Auth, Charts, Workflow, Monitoring
110
115
  - **`devtools/`** — federation inspector, profiler, theme inspector
111
- - **`runtime-config/`** — tenant configs, remote manifests, feature flags
116
+ - **`runtime-config/`** — tenant configs, remote manifests, pillar configs (scaling, resilience, structure, observability, architect roadmap)
112
117
  - **`templates/`** — LIMS, ERP, HMS, SaaS enterprise blueprints
113
118
  - **`ai/`** — AI-ready prompt engine + semantic search hooks
114
119
  - **`governance/`** — import boundaries, CODEOWNERS, dependency rules
120
+ - **Enterprise pillar docs + audits** — security, DX, observability, a11y, CI/CD, scalability, failure recovery, folder structure, architect capstone
115
121
  - **CI/CD** — GitHub Actions, GitLab CI, Helm chart
116
122
  - Root scripts for dev, watch, preview, release, affected builds, **per-child dev shortcuts**
117
123
 
@@ -181,6 +187,7 @@ npm run local # build all apps → watch → preview all ports → live-r
181
187
  | Command | When to use |
182
188
  |---------|-------------|
183
189
  | `npm run local` | **Default daily dev** — all apps (main + every child + shared lib) |
190
+ | `npm run local:fast` | Smart build (skip unchanged) + watch + preview — faster iteration |
184
191
  | `npm run dev` | Print env + run each app's Vite dev server (no federation build watch) |
185
192
  | `npm run dev:fast` | Dev build once, then preview + live-reload |
186
193
  | `npm run dev:safe` | Production build, then preview only |
@@ -251,11 +258,24 @@ npm run release:major
251
258
 
252
259
  ### Add a new remote after scaffold
253
260
 
254
- Use the built-in MF CLI (recommended):
261
+ **Recommended use `create-mf-app add-child`** (fully wires federation, host routes, `mf.json`, env ports, and npm scripts):
262
+
263
+ ```bash
264
+ npx create-mf-app add-child analytics --cwd=./my-platform --port=4205 -y
265
+ ```
266
+
267
+ From the CLI repo during development:
268
+
269
+ ```bash
270
+ node dist/index.js add-child analytics --cwd=./mf-structure-test --port=4205 -y
271
+ ```
272
+
273
+ This scaffolds `apps/analytics/`, updates the host router (`/analytics/*`), corelib registries, `remote-manifest.json`, root `package.json` scripts (`npm run analytics`), and `.env` port entries — the same wiring as children created at initial scaffold time.
274
+
275
+ **Alternative — MF CLI inside the monorepo** (minimal scaffold; manual federation wiring may still be needed):
255
276
 
256
277
  ```bash
257
278
  npm run mf -- generate app inventory
258
- # wires federation, port, mf.json, and npm scripts
259
279
  ```
260
280
 
261
281
  Or copy an existing child app folder and update `mf.json`, `federation.config.ts`, host routes, and root `package.json` scripts manually.
@@ -264,6 +284,8 @@ Or copy an existing child app folder and update `mf.json`, `federation.config.ts
264
284
 
265
285
  ## CLI reference (create-mf-app)
266
286
 
287
+ ### Create a new project
288
+
267
289
  ```bash
268
290
  npx create-mf-app <project-name> [options]
269
291
  ```
@@ -284,6 +306,45 @@ npx create-mf-app <project-name> [options]
284
306
  | `-y`, `--yes` | Non-interactive (use defaults where applicable) |
285
307
  | `-h`, `--help` | Show help |
286
308
 
309
+ ### Add a child to an existing parent workspace
310
+
311
+ ```bash
312
+ npx create-mf-app add-child <child-name> --cwd=./my-platform [options]
313
+ ```
314
+
315
+ | Option | Description |
316
+ |--------|-------------|
317
+ | `--cwd=./my-platform` | Parent monorepo root (must contain `mf.json`; default: current directory) |
318
+ | `--port=4205` | Dev/preview port for the new remote (default: next free port after existing apps) |
319
+ | `-y`, `--yes` | Non-interactive |
320
+ | `-h`, `--help` | Show add-child help |
321
+
322
+ **Example:**
323
+
324
+ ```bash
325
+ npx create-mf-app add-child analytics --cwd=./my-platform --port=4205 -y
326
+ cd my-platform
327
+ npm run analytics
328
+ ```
329
+
330
+ **What gets updated:**
331
+
332
+ - `apps/<child-name>/` — full enterprise child remote scaffold
333
+ - `mf.json` — project registry + federation remotes
334
+ - `apps/main` — host routes, federation config, remote type declarations
335
+ - `apps/corelib` — permission/module/feature registries, sidebar menu
336
+ - `runtime-config/remote-manifest.json` — remote entry map
337
+ - Root `package.json` — `npm run <child>`, watch/preview/build scripts
338
+ - `.env` / env variants — port and remoteEntry URLs
339
+ - `docker-compose.yml` and `infrastructure/` — when present in the workspace
340
+
341
+ **Rules:**
342
+
343
+ - Workspace must be an existing **parent monorepo** with `mf.json`
344
+ - Child name: letters, numbers, dashes only (`^[a-z0-9-]+$`)
345
+ - Do not use `main` or the shared lib name (e.g. `corelib`)
346
+ - Child must not already exist under `apps/`
347
+
287
348
  **Parent mode rules:**
288
349
 
289
350
  - `main` is **always** created as the host — never pass it in `--children` or `--shared`
@@ -462,9 +523,170 @@ See generated `docs/FEDERATION_OS.md` for full architecture.
462
523
  | Federation registry | `apps/corelib/src/federation/` |
463
524
  | Command palette | `apps/corelib/src/command-palette/` (Ctrl+K) |
464
525
  | Production hardening | `apps/corelib/src/production/` (CSP, env validation, diagnostics) |
526
+ | React architecture | `apps/corelib/src/architecture/` + `docs/REACT_ARCHITECTURE.md` |
527
+ | Security hardening | `apps/corelib/src/security/` + `docs/FRONTEND_SECURITY.md` |
528
+ | Observability | `apps/corelib/src/monitoring/`, `observability/` + `docs/OBSERVABILITY.md` |
529
+ | Accessibility | `apps/corelib/src/accessibility/` + `docs/ACCESSIBILITY.md` |
530
+ | Release engineering | `apps/corelib/src/release/` + `docs/CICD_RELEASE_ENGINEERING.md` |
531
+ | Scalability | `apps/corelib/src/scalability/` + `docs/ENTERPRISE_SCALABILITY.md` |
532
+ | Failure recovery | `apps/corelib/src/resilience/` + `docs/FAILURE_RECOVERY.md` |
533
+ | Folder structure | `apps/corelib/src/structure/` + `docs/ENTERPRISE_FOLDER_STRUCTURE.md` |
534
+ | Architect capstone | `apps/corelib/src/architect/` + `docs/ARCHITECT_LEVEL_GUIDE.md` |
465
535
  | MF Platform CLI | `tools/mf-cli/` |
466
536
  | Project graph | `tools/project-graph/` |
467
537
  | Task runner + cache | `task-runner/` + `.mf/cache` |
538
+ | Smart build | `smart-build.js` — dependency-order parallel builds |
539
+ | Developer experience | `docs/DEVELOPER_EXPERIENCE.md`, `turbo.json`, root `tsconfig.json` refs |
540
+
541
+ ---
542
+
543
+ ## Enterprise architect pillars
544
+
545
+ Every **federated parent workspace** ships a full **architect-level** toolkit — docs, audit scripts, corelib modules, and runtime configs. Run the **capstone audit** first, then drill into individual pillars.
546
+
547
+ ### Capstone — start here
548
+
549
+ ```bash
550
+ npm run architect-level:audit
551
+ ```
552
+
553
+ | Artifact | Purpose |
554
+ |----------|---------|
555
+ | `docs/ARCHITECT_LEVEL_GUIDE.md` | Synthesizes all pillars — act as Senior Frontend Architect, Performance Engineer, Platform Engineer, Enterprise UI Architect, Microfrontend Specialist, DevOps-aware Frontend Engineer |
556
+ | `runtime-config/architect-roadmap.json` | Phased roadmap: Foundation → Hardening → Scale → Platform → Optimize |
557
+ | `apps/corelib/src/architect/` | Capstone checklist + domain definitions |
558
+
559
+ ### All enterprise pillar audits
560
+
561
+ | Pillar | Audit command | Documentation |
562
+ |--------|---------------|---------------|
563
+ | **Architect capstone** | `npm run architect-level:audit` | `docs/ARCHITECT_LEVEL_GUIDE.md` |
564
+ | **Folder structure** | `npm run folder-structure:audit` | `docs/ENTERPRISE_FOLDER_STRUCTURE.md` |
565
+ | **React architecture** | `npm run react:architecture-audit` | `docs/REACT_ARCHITECTURE.md` |
566
+ | **Security hardening** | `npm run security:hardening-audit` | `docs/FRONTEND_SECURITY.md` |
567
+ | **Developer experience** | `npm run dx:audit` | `docs/DEVELOPER_EXPERIENCE.md` |
568
+ | **Observability** | `npm run observability:audit` | `docs/OBSERVABILITY.md` |
569
+ | **Accessibility (WCAG)** | `npm run a11y:audit` | `docs/ACCESSIBILITY.md` |
570
+ | **CI/CD + release** | `npm run cicd:audit` | `docs/CICD_RELEASE_ENGINEERING.md` |
571
+ | **Scalability** | `npm run scalability:audit` | `docs/ENTERPRISE_SCALABILITY.md` |
572
+ | **Failure recovery** | `npm run failure-recovery:audit` | `docs/FAILURE_RECOVERY.md` |
573
+ | **Platform health** | `npm run mf:doctor` | `docs/ENTERPRISE_ARCHITECTURE.md` |
574
+ | **Federation contracts** | `npm run federation:verify` | `apps/corelib/src/federation/` |
575
+
576
+ `npm run mf:doctor` prints reminders for every pillar audit after scaffold.
577
+
578
+ ### Pillar summaries
579
+
580
+ #### 1. Security hardening
581
+
582
+ XSS prevention, CSP, secure token handling, refresh strategy (`--auth`), cookie flags, dependency audit, supply chain, federation remote trust, runtime script injection prevention.
583
+
584
+ - **Corelib:** `src/security/frontendSecurityAudit.ts`, `src/federation/remoteTrust.ts`, `src/auth/refreshTokenStrategy.ts`
585
+ - **Config:** hardened CSP in `src/production/csp.ts`
586
+ - **Scripts:** `npm run security:hardening-audit`, `npm run security:audit`
587
+
588
+ #### 2. Developer experience (DX)
589
+
590
+ Smart parallel builds, incremental cache, live reload (SSE), affected detection, project graph.
591
+
592
+ - **Root:** `smart-build.js` (topo-sort + parallel waves), `live-reload.js` (port 35729), `turbo.json`
593
+ - **Scripts:** `npm run local:fast`, `node smart-build.js localdev --skip-unchanged`, `npm run dx:audit`
594
+ - **CLI:** `mf cache invalidate`, `mf affected build`
595
+
596
+ #### 3. Observability (`--monitoring` for full stack)
597
+
598
+ Telemetry, distributed tracing, session replay, error tracking, user journey, performance budgets, RUM, OpenTelemetry.
599
+
600
+ - **Corelib:** `src/monitoring/*` (frontendTelemetry, distributedTracing, sessionReplay, errorTracking, userJourney, performanceBudgets, rum, opentelemetry)
601
+ - **Config:** `runtime-config/observability.config.json`
602
+ - **Bootstrap:** `bootstrapObservability()` via `warmupCorelibShell()` when `--monitoring`
603
+ - **Scripts:** `npm run observability:audit`
604
+
605
+ #### 4. Accessibility (WCAG)
606
+
607
+ Focus management, live announcer, contrast checks, skip links, landmarks, eslint-plugin-jsx-a11y.
608
+
609
+ - **Corelib:** `src/accessibility/focusManagement.ts`, `liveAnnouncer.ts`, `contrastCheck.ts`
610
+ - **Host:** skip link, `#main-content`, `LiveAnnouncerRegion`, `:focus-visible` CSS
611
+ - **Scripts:** `npm run a11y:audit`
612
+
613
+ #### 5. CI/CD + release engineering
614
+
615
+ Parallel CI builds, incremental deploy, federation rollout order, canary, rollback, feature-flag rollouts.
616
+
617
+ - **Workflows:** `mf-platform-ci.yml`, `mf-affected-deploy.yml`, `mf-canary-deploy.yml`, `mf-rollback.yml`
618
+ - **Corelib:** `src/release/` (deploy strategy, federation rollout, rollback)
619
+ - **Scripts:** `npm run cicd:audit`, `npm run release:plan`, `node scripts/release-deploy.js plan`
620
+
621
+ #### 6. Enterprise scalability
622
+
623
+ 100k+ users, multi-tenant, CDN edge, runtime remote discovery, asset distribution, federation scaling, independent deployments.
624
+
625
+ - **Corelib:** `src/scalability/` (multiTenant, cdnEdge, remoteDiscovery, assetDistribution, federationScaling)
626
+ - **Config:** `runtime-config/scaling.config.json`
627
+ - **Scripts:** `npm run scalability:audit`, `npm run mf:graph`
628
+
629
+ #### 7. Production failure recovery
630
+
631
+ Remote fallbacks, offline strategy, retry, circuit breakers, graceful degradation, runtime remote failure handling.
632
+
633
+ - **Corelib:** `src/resilience/` (circuitBreaker, retryPolicy, offlineStrategy, remoteFailureHandler, gracefulDegradation)
634
+ - **UI:** `FederationFallback` + `RemoteRouteBoundary` (emits `mf:remote-failure` events)
635
+ - **Config:** `runtime-config/resilience.config.json`
636
+ - **Federation expose:** `corelib/resilience` — `loadRemoteWithResilience()`, `installRemoteFailureListener()`
637
+ - **Scripts:** `npm run failure-recovery:audit`
638
+
639
+ #### 8. Enterprise folder structure
640
+
641
+ Domain-driven frontend, feature modules, shared packages, federation boundaries, dependency isolation, plugin architecture.
642
+
643
+ - **Corelib:** `src/structure/` (domainMap, boundaryRules, featureModules, dependencyIsolation, pluginArchitecture)
644
+ - **Config:** `runtime-config/structure.config.json` — bounded context → remote map
645
+ - **Governance:** `governance/module-boundaries.json`, `mf.json` tags
646
+ - **Scripts:** `npm run folder-structure:audit`
647
+
648
+ #### 9. React architecture
649
+
650
+ State colocation, context splitting, server vs client state, feature-based layout, atomic design, smart/dumb components, Suspense/error boundaries, concurrent rendering.
651
+
652
+ - **Corelib:** `src/architecture/reactArchitectureAudit.ts`
653
+ - **Scripts:** `npm run react:architecture-audit`
654
+
655
+ #### 10. Architect-level guide (capstone)
656
+
657
+ Enterprise-grade architecture, production optimization, scalability, security, maintainability, developer productivity, deployment strategy, observability strategy, future scalability roadmap.
658
+
659
+ - **Roles:** Senior Frontend Architect, Performance Engineer, Platform Engineer, Enterprise UI Architect, Microfrontend Specialist, DevOps-aware Frontend Engineer
660
+ - **Roadmap:** `runtime-config/architect-roadmap.json` — 5 phases with milestones
661
+ - **Scripts:** `npm run architect-level:audit`
662
+
663
+ ### Runtime configs (generated)
664
+
665
+ ```text
666
+ runtime-config/
667
+ ├── remote-manifest.json # Remote entry URLs + versions
668
+ ├── tenant-config.js # Multi-tenant SaaS
669
+ ├── observability.config.json # Telemetry, RUM, OTel settings
670
+ ├── scaling.config.json # 100k+ user targets, CDN, federation scaling
671
+ ├── resilience.config.json # Retry, circuit breaker, offline policy
672
+ ├── structure.config.json # Domain → remote bounded context map
673
+ ├── architect-roadmap.json # Foundation → Optimize phase tracker
674
+ ├── deployment.config.json # Rollout strategy (release engineering)
675
+ └── feature-flags.js # Runtime feature toggles
676
+ ```
677
+
678
+ ### Pre-production checklist
679
+
680
+ ```bash
681
+ npm run architect-level:audit # capstone — verifies all pillar docs/scripts
682
+ npm run mf:doctor # workspace health + pillar reminders
683
+ npm run federation:verify # remoteEntry health
684
+ npm run folder-structure:audit # DDD layout + import boundaries
685
+ npm run security:hardening-audit # CSP, remote trust, auth
686
+ npm run failure-recovery:audit # circuit breakers + fallbacks
687
+ npm run cicd:audit # CI/CD + canary + rollback workflows
688
+ npm run build # production build all apps
689
+ ```
468
690
 
469
691
  ---
470
692
 
@@ -504,13 +726,46 @@ my-platform/
504
726
  ├── plugins/
505
727
  ├── devtools/
506
728
  ├── runtime-config/
729
+ │ ├── remote-manifest.json
730
+ │ ├── observability.config.json
731
+ │ ├── scaling.config.json
732
+ │ ├── resilience.config.json
733
+ │ ├── structure.config.json
734
+ │ └── architect-roadmap.json
507
735
  ├── templates/
508
736
  ├── ai/
509
737
  ├── governance/
510
738
  ├── k8s/helm/mf-platform/
511
739
  ├── docs/
740
+ │ ├── ENTERPRISE_ARCHITECTURE.md
741
+ │ ├── ARCHITECT_LEVEL_GUIDE.md # capstone architect guide
742
+ │ ├── ENTERPRISE_FOLDER_STRUCTURE.md
743
+ │ ├── REACT_ARCHITECTURE.md
744
+ │ ├── FRONTEND_SECURITY.md
745
+ │ ├── DEVELOPER_EXPERIENCE.md
746
+ │ ├── OBSERVABILITY.md
747
+ │ ├── ACCESSIBILITY.md
748
+ │ ├── CICD_RELEASE_ENGINEERING.md
749
+ │ ├── ENTERPRISE_SCALABILITY.md
750
+ │ ├── FAILURE_RECOVERY.md
751
+ │ └── PLATFORM_ARCHITECTURE.md
512
752
  ├── scripts/
753
+ │ ├── architect-level-audit.js
754
+ │ ├── folder-structure-audit.js
755
+ │ ├── react-architecture-audit.js
756
+ │ ├── security-hardening-audit.js
757
+ │ ├── dx-audit.js
758
+ │ ├── observability-audit.js
759
+ │ ├── a11y-audit.js
760
+ │ ├── cicd-audit.js
761
+ │ ├── scalability-audit.js
762
+ │ ├── failure-recovery-audit.js
763
+ │ └── release-deploy.js
513
764
  ├── .github/workflows/
765
+ │ ├── mf-platform-ci.yml
766
+ │ ├── mf-affected-deploy.yml
767
+ │ ├── mf-canary-deploy.yml
768
+ │ └── mf-rollback.yml
514
769
  ├── docker-compose.yml
515
770
  ├── .env, .env.dev, .env.staging, .env.uat, .env.prod
516
771
  ├── live-reload.js
@@ -611,7 +866,7 @@ node tools/mf-cli/bin/mf.js <command>
611
866
  | `mf federation doctor` | Check host/remotes/shared lib wiring |
612
867
  | `mf federation graph` | Export federation dependency graph |
613
868
  | `mf federation sync` | Sync remote manifests from `mf.json` |
614
- | `mf doctor` | Workspace health (circular deps, boundaries, mf.json, architecture protection) |
869
+ | `mf doctor` | Workspace health (circular deps, boundaries, mf.json, architecture protection, **pillar audit reminders**) |
615
870
  | `npm run federation:verify` | HEAD-check remoteEntry URLs (`MF_REMOTES` env) |
616
871
 
617
872
  ### Architecture protection (`mss-mf`)
@@ -662,43 +917,43 @@ Emergency architect override: `MSS_PROTECT_OVERRIDE=1 mss-mf delete <path> --arc
662
917
 
663
918
  **corelib** (or your `--shared` name) is a **Module Federation remote** that exposes shared UI, config, and RBAC. Child remotes and the host import it at runtime.
664
919
 
665
- ### Host (`apps/main`) — wrap shell with providers
920
+ ### Host (`apps/main`) — single `HostShell` expose
921
+
922
+ The host uses a **CSS-only boot shell** (~137 KB gzip) and loads the MUI/RBAC shell from corelib in **one federation request** via `corelib/HostShell`:
666
923
 
667
924
  ```tsx
668
- const AppConfigProvider = React.lazy(() => import("corelib/AppConfigProvider"));
669
- const AppNavbar = React.lazy(() => import("corelib/AppNavbar"));
670
- const AppSidebar = React.lazy(() => import("corelib/AppSidebar"));
671
- const EnterpriseSidebarNav = React.lazy(() => import("corelib/EnterpriseSidebarNav"));
672
- const RoleProvider = React.lazy(() => import("corelib/RoleProvider"));
673
- const CommandPalette = React.lazy(() => import("corelib/CommandPalette"));
925
+ const HostShell = React.lazy(() => import("corelib/HostShell"));
674
926
 
675
927
  export default function App() {
676
928
  return (
677
- <React.Suspense fallback={<div>Loading…</div>}>
678
- <AppConfigProvider>
679
- <RoleProvider>
680
- {/* navbar, sidebar, routes */}
681
- </RoleProvider>
682
- </AppConfigProvider>
929
+ <React.Suspense fallback={<ShellSkeleton />}>
930
+ <HostShell navLinks={<HostNavLinks />} onItemPrefetch={prefetchRemotePath}>
931
+ <AppRouter />
932
+ </HostShell>
683
933
  </React.Suspense>
684
934
  );
685
935
  }
686
936
  ```
687
937
 
688
- ### Child remote use shared badge, RBAC, tokens
938
+ `main.tsx` bootstraps runtime remotes (manifest prefetch) before render:
689
939
 
690
940
  ```tsx
691
- const SharedBadge = React.lazy(() => import("corelib/SharedBadge"));
692
- const RoleProvider = React.lazy(() => import("corelib/RoleProvider"));
941
+ await bootstrapRuntimeRemotes();
942
+ warmupCorelibShell();
943
+ ```
944
+
945
+ ### Child remote — `RemoteAppShell` (skips duplicate providers)
946
+
947
+ When embedded in the host, **`RoleProvider` is not mounted twice**. Standalone dev still wraps with `RoleProvider`:
948
+
949
+ ```tsx
950
+ import RemoteAppShell from "corelib/RemoteAppShell";
693
951
 
694
952
  export default function App() {
695
953
  return (
696
- <div className="remote-shell">
697
- <RoleProvider>
698
- <SharedBadge />
699
- <AppRouter />
700
- </RoleProvider>
701
- </div>
954
+ <RemoteAppShell>
955
+ <AppRouter />
956
+ </RemoteAppShell>
702
957
  );
703
958
  }
704
959
  ```
@@ -708,14 +963,18 @@ export default function App() {
708
963
  | Export | Purpose |
709
964
  |--------|---------|
710
965
  | `./App` | Standalone corelib demo app |
966
+ | `./HostShell` | **Host shell bundle** — AppConfig, RoleProvider, Navbar, Sidebar, CommandPalette |
967
+ | `./RemoteAppShell` | **Embedded remote wrapper** — skips RoleProvider when host is active |
711
968
  | `./AppConfigProvider` | Theme + MUI provider + CSS variables |
712
- | `./useAppConfig` | Hook: config, palette, shell colors, toggle theme |
713
- | `./AppNavbar`, `./AppSidebar`, `./ThemeToggle` | Shell UI |
714
- | `./EnterpriseSidebarNav` | Role-filtered sidebar menu |
969
+ | `./useAppConfig` | Combined hook (backward compatible) |
970
+ | `./AppNavbar`, `./AppSidebar`, `./ThemeToggle` | Shell UI (also inside HostShell) |
971
+ | `./EnterpriseSidebarNav` | Role-filtered sidebar menu + route prefetch hook |
715
972
  | `./RouteGuard`, `./RoleProvider`, `./usePermission` | RBAC |
716
- | `./CommandPalette` | Ctrl+K palette |
973
+ | `./CommandPalette` | Ctrl+K palette (returns `null` when closed) |
717
974
  | `./DashboardLayout` | Dashboard shell layout |
718
975
  | `./PermissionProvider`, `./FederationFallback` | Permissions + error UI |
976
+ | `./resilience` | Circuit breakers, retry, offline, `loadRemoteWithResilience()`, `installRemoteFailureListener()` |
977
+ | `./ProfilerGate` | Dev-only React Profiler wrapper |
719
978
  | `./designTokens` | Token registry |
720
979
 
721
980
  ### TypeScript — add declarations in host/child
@@ -750,19 +1009,30 @@ apps/corelib/src/
750
1009
 
751
1010
  ### Runtime theme in your components
752
1011
 
1012
+ Split config hooks reduce re-renders (prefer these over the combined hook in hot paths):
1013
+
753
1014
  ```tsx
754
- import { useAppConfig } from "corelib/useAppConfig";
1015
+ import {
1016
+ useAppConfigPick,
1017
+ useAppConfigActions,
1018
+ useAppTheme,
1019
+ useAppConfig, // backward compatible
1020
+ } from "corelib/useAppConfig";
755
1021
 
756
1022
  function MyWidget() {
757
- const { config, palette, shell, toggleColorMode } = useAppConfig();
1023
+ const { tenantId } = useAppConfigPick("tenantId");
1024
+ const { toggleColorMode } = useAppConfigActions();
1025
+ const { palette } = useAppTheme();
758
1026
  return (
759
1027
  <div style={{ color: palette.textPrimary, background: palette.surface }}>
760
- {config.appName}
1028
+ Tenant: {tenantId}
761
1029
  </div>
762
1030
  );
763
1031
  }
764
1032
  ```
765
1033
 
1034
+ **Config architecture:** `AppConfigProvider` uses three contexts — **State** (config object), **Actions** (stable mutations), **Theme** (resolved palette). Sidebar/nav components use CSS variables (`--ds-*`) where possible.
1035
+
766
1036
  **Features:**
767
1037
 
768
1038
  - Enterprise-light / enterprise-dark presets + Azure, Atlassian, Linear-dark, etc.
@@ -784,38 +1054,41 @@ Then hard-refresh the browser.
784
1054
 
785
1055
  ## Module Federation
786
1056
 
787
- ### Architecture
1057
+ ### Architecture (tiered host / shared / remotes)
788
1058
 
789
1059
  ```text
790
- ┌─────────────────────────────────────────────────────────┐
791
- │ apps/main (host) :3000
792
- │ ├── loads corelib remote (shared UI, theme, RBAC)
793
- │ ├── loads billing remote on /billing/*
794
- └── loads orders remote on /orders/*
795
- └─────────────────────────────────────────────────────────┘
796
- │ shared singletons: react, react-dom, MUI, …
1060
+ ┌──────────────────────────────────────────────────────────────┐
1061
+ │ apps/main (host) :3000 — CSS shell ~137 KB gzip
1062
+ │ ├── eager shared: react, react-dom only
1063
+ │ ├── lazy shared: react-router-dom, @tanstack/react-query
1064
+ ├── corelib/HostShell (single federation expose)
1065
+ │ └── feature remotes on /admin-app/*, /analytics-app/*, … │
1066
+ └──────────────────────────────────────────────────────────────┘
1067
+
797
1068
 
798
- ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
799
- apps/billing apps/orders │ │ apps/corelib
800
- :3001 │ :3002 │ :3003 │
801
- └──────────────┘ └──────────────┘ └──────────────┘
1069
+ ┌──────────────────┐ ┌─────────────────────────────────────┐
1070
+ apps/corelib │ apps/<child> (feature remotes)
1071
+ MUI, RBAC, DS │◀────│ RemoteAppShell when embedded
1072
+ :3006 │ │ standard / control-plane share tiers│
1073
+ └──────────────────┘ └─────────────────────────────────────┘
802
1074
  ```
803
1075
 
804
- ### Shared dependency rules (important)
1076
+ Shared policy lives in **`packages/shared-config/src/federationShared.ts`**:
805
1077
 
806
- The generator configures federation so **one React/MUI instance** is shared:
1078
+ | Tier | Packages | Host | corelib / remotes |
1079
+ |------|----------|------|-------------------|
1080
+ | 0 | `react`, `react-dom` | eager singleton | singleton |
1081
+ | 1 | `react-router-dom`, `@tanstack/react-query` | lazy shared | shared |
1082
+ | 2 | MUI, Emotion | **not on host** | corelib + remotes |
1083
+ | 3 | `zustand`, `@xyflow/react`, … | per-app only | control-plane remotes |
807
1084
 
808
- **Host (`apps/main/federation.config.ts`):**
1085
+ **Production:** `strictVersion: true` is enabled automatically for `prod`, `staging`, and `uat` builds (or set `VITE_MF_STRICT_SHARED=1`).
809
1086
 
810
- - Provides shared deps with **exact semver** keys: `version: "19.0.0"` (not `^19.0.0`)
811
- - `singleton: true`, `import: true`
1087
+ **Remote URLs:** env-driven via `packages/shared-config/src/federationRemotes.ts` (`VITE_<APP>_REMOTE_ENTRY`). Local default:
812
1088
 
813
- **Remotes (children + corelib):**
814
-
815
- - Consume host share scope: `requiredVersion: "^19.0.0"`
816
- - `singleton: true`
817
-
818
- **Shared packages:** `react`, `react-dom`, `react-router-dom`, `@mui/material`, `@mui/icons-material`, `@emotion/react`, `@emotion/styled`, `@mui/x-data-grid`
1089
+ ```text
1090
+ http://localhost:<port>/assets/remoteEntry.js
1091
+ ```
819
1092
 
820
1093
  **After changing federation config:**
821
1094
 
@@ -826,15 +1099,66 @@ npm run local # restart
826
1099
 
827
1100
  Use **hoisted install** (generated `.npmrc`: `install-strategy=hoisted`).
828
1101
 
829
- ### Remote URLs (local dev)
1102
+ ---
830
1103
 
831
- Each app's `federation.config.ts` points to:
1104
+ ## Performance & federation architecture
832
1105
 
833
- ```text
834
- http://localhost:<port>/assets/remoteEntry.js
1106
+ Enterprise parent workspaces (and the reference **`my-platform/`** in this repo) include the optimizations below. Generated scaffolds follow the same patterns via `apps/vite.config.base.ts`, `federationShared.ts`, and corelib shell modules.
1107
+
1108
+ ### Bundle size & Vite
1109
+
1110
+ | Feature | Location | Purpose |
1111
+ |---------|----------|---------|
1112
+ | Shared Vite base | `apps/vite.config.base.ts` | `mfSafeManualChunks`, `resolve.dedupe`, gzip/brotli in prod |
1113
+ | Host thin shell | `apps/main` | No MUI/Emotion on host boot path |
1114
+ | Lazy DataGrid | `corelib/AppDataGrid` | `@mui/x-data-grid` dynamic import |
1115
+ | Route prefetch | `main/src/routes/remoteLoaders.ts` | Hover/focus prefetch before navigation |
1116
+ | `RemoteSkeleton` | `main/src/components/RemoteSkeleton.tsx` | Non-blocking loading UI |
1117
+
1118
+ Run bundle analysis:
1119
+
1120
+ ```bash
1121
+ npm run analyze:bundle
1122
+ # or per app: cd apps/main && npm run analyze
835
1123
  ```
836
1124
 
837
- Match ports from root `.env` when customizing.
1125
+ ### Runtime remote loading
1126
+
1127
+ | Feature | Location | Purpose |
1128
+ |---------|----------|---------|
1129
+ | Runtime manifest | `runtime-config/remote-manifest.json` | CDN/prod remote entry map |
1130
+ | Bootstrap | `main/src/module-federation/bootstrapRemotes.ts` | Fetch manifest, preconnect, prefetch `remoteEntry` |
1131
+ | Dev manifest server | `apps/main/vite.config.ts` | Serves `/runtime-config/*` in local dev |
1132
+ | Idle warm-up | `warmupCorelibShell()` in `main.tsx` | Idle-import `corelib/HostShell` |
1133
+ | Error boundaries | `main/src/components/RemoteRouteBoundary.tsx` | Per-remote fallback + retry |
1134
+ | nginx caching | `infrastructure/nginx/conf.d/federation.conf` | Short cache on `remoteEntry`, manifest at `/runtime-config/` |
1135
+
1136
+ Env override for manifest URL:
1137
+
1138
+ ```bash
1139
+ VITE_REMOTE_MANIFEST_URL=/runtime-config/remote-manifest.json
1140
+ ```
1141
+
1142
+ ### Re-render performance (corelib)
1143
+
1144
+ - **Split contexts:** `useAppConfigState`, `useAppConfigActions`, `useAppTheme`, `useAppConfigPick`
1145
+ - **Memo shell:** `EnterpriseSidebarNav`, `AppTable`, `AppDataGrid`, host nav links
1146
+ - **Command palette:** no render when closed
1147
+ - **Control plane dashboard:** tab-isolated data (health WebSocket only in Monitor tab)
1148
+ - **Dev profiling:** `ProfilerGate` wraps host navbar, sidebar, and router regions
1149
+
1150
+ ### Host / remote communication
1151
+
1152
+ | Channel | Mechanism |
1153
+ |---------|-----------|
1154
+ | Navigation | Host owns `BrowserRouter`; remotes use nested `<Routes>` |
1155
+ | Server state | Singleton `@my-platform/query-client` at host |
1156
+ | Theme / RBAC | corelib contexts via `HostShell` (single provider tree) |
1157
+ | Cross-MFE events | Extend with event bus / shared query keys as needed |
1158
+
1159
+ ### Reference platform
1160
+
1161
+ The **`my-platform/`** directory in this repository is a fully wired reference implementation with all of the above. See [`my-platform/README.md`](my-platform/README.md) for app ports, scripts, and platform-specific notes.
838
1162
 
839
1163
  ---
840
1164
 
@@ -886,10 +1210,27 @@ task-runner/
886
1210
 
887
1211
  ```text
888
1212
  runtime-config/
889
- ├── tenant-config.js # Multi-tenant SaaS configs
890
- ├── manifest-loader.js # CDN remote manifest fetch
891
- ├── feature-flags.js # Runtime feature toggles
892
- └── branding.js # Dynamic logo/colors injection
1213
+ ├── remote-manifest.json # Remote entry URLs + versions (host bootstrap)
1214
+ ├── tenant-config.js # Multi-tenant SaaS configs
1215
+ ├── observability.config.json # Telemetry, RUM, OTel settings
1216
+ ├── scaling.config.json # Scalability targets, CDN, multi-tenant
1217
+ ├── resilience.config.json # Retry, circuit breaker, offline policy
1218
+ ├── structure.config.json # Domain → remote bounded context map
1219
+ ├── architect-roadmap.json # Foundation → Optimize phase tracker
1220
+ ├── deployment.config.json # Rollout strategy (release engineering)
1221
+ ├── manifest-loader.js # CDN remote manifest fetch
1222
+ ├── feature-flags.js # Runtime feature toggles
1223
+ └── branding.js # Dynamic logo/colors injection
1224
+ ```
1225
+
1226
+ The host loads `remote-manifest.json` at startup (`bootstrapRuntimeRemotes`) to preconnect and prefetch `remoteEntry.js` files. In production, nginx serves `/runtime-config/` with short cache headers (`max-age=30`, stale-while-revalidate).
1227
+
1228
+ Per-remote env overrides (build time):
1229
+
1230
+ ```bash
1231
+ VITE_CORELIB_REMOTE_ENTRY=http://localhost:3006/assets/remoteEntry.js
1232
+ VITE_ADMIN_APP_REMOTE_ENTRY=http://localhost:3001/assets/remoteEntry.js
1233
+ # … see packages/shared-config/src/federationRemotes.ts
893
1234
  ```
894
1235
 
895
1236
  ---
@@ -914,8 +1255,10 @@ Enterprise blueprints in `templates/`:
914
1255
 
915
1256
  **GitHub Actions:**
916
1257
 
917
- - `.github/workflows/mf-platform-ci.yml` — doctor, affected lint/test/build, security audit
1258
+ - `.github/workflows/mf-platform-ci.yml` — doctor, affected lint/test/build, security audit, pillar audits
918
1259
  - `.github/workflows/mf-affected-deploy.yml` — affected deploy on main
1260
+ - `.github/workflows/mf-canary-deploy.yml` — canary promotion with health checks
1261
+ - `.github/workflows/mf-rollback.yml` — federation rollback workflow
919
1262
 
920
1263
  **Also generated:**
921
1264
 
@@ -948,6 +1291,16 @@ Generated parent workspaces include:
948
1291
  | `npm run cleanup` | lint:fix → imports → type-check |
949
1292
  | `npm run analyze:bundle` | Rollup visualizer per app |
950
1293
  | `npm run security:audit` | npm audit |
1294
+ | `npm run security:hardening-audit` | Frontend security pillar audit |
1295
+ | `npm run architect-level:audit` | Capstone — verifies all enterprise pillar docs/scripts |
1296
+ | `npm run folder-structure:audit` | DDD layout, federation boundaries, dependency isolation |
1297
+ | `npm run react:architecture-audit` | React architecture pillars |
1298
+ | `npm run dx:audit` | Developer experience maturity |
1299
+ | `npm run observability:audit` | Telemetry, RUM, tracing, error tracking |
1300
+ | `npm run a11y:audit` | WCAG accessibility checklist |
1301
+ | `npm run cicd:audit` | CI/CD + release engineering |
1302
+ | `npm run scalability:audit` | 100k+ users, CDN, multi-tenant |
1303
+ | `npm run failure-recovery:audit` | Circuit breakers, retry, fallbacks |
951
1304
  | `npm run production:hygiene` | Fail on console/debugger in sources |
952
1305
 
953
1306
  Husky: lint-staged + type-check + tests on pre-commit; lint + tests on pre-push. Commitlint for Conventional Commits.
@@ -961,6 +1314,8 @@ Husky: lint-staged + type-check + tests on pre-commit; lint + tests on pre-push.
961
1314
  | Script | Purpose |
962
1315
  |--------|---------|
963
1316
  | `local` | **Main dev command** — build:local + watch + preview + live-reload (all apps) |
1317
+ | `local:fast` | Smart build (skip unchanged) + watch + preview + live-reload |
1318
+ | `build:local` | `node smart-build.js localdev` — parallel dependency-order build |
964
1319
  | `dev` | print-env + parallel Vite dev servers |
965
1320
  | `dev:watch` | Same as `local` |
966
1321
  | `dev:fast` | dev build once + preview + live-reload |
@@ -972,6 +1327,17 @@ Husky: lint-staged + type-check + tests on pre-commit; lint + tests on pre-push.
972
1327
  | `preview:<app>` | Vite preview for one app |
973
1328
  | `release` / `release:minor` / `release:major` | Version bump + build |
974
1329
  | `federation:verify` | Remote entry health check |
1330
+ | `architect-level:audit` | Capstone enterprise platform audit |
1331
+ | `folder-structure:audit` | Domain-driven folder structure audit |
1332
+ | `react:architecture-audit` | React architecture audit |
1333
+ | `security:hardening-audit` | Frontend security hardening audit |
1334
+ | `dx:audit` | Developer experience audit |
1335
+ | `observability:audit` | Observability stack audit |
1336
+ | `a11y:audit` | Accessibility (WCAG) audit |
1337
+ | `cicd:audit` | CI/CD + release engineering audit |
1338
+ | `scalability:audit` | Enterprise scalability audit |
1339
+ | `failure-recovery:audit` | Production failure recovery audit |
1340
+ | `release:plan` | Deployment rollout plan |
975
1341
  | `mf`, `mf:graph`, `mf:affected`, `mf:doctor`, `mss-mf`, `mf:protect` | Platform CLI + architecture protection |
976
1342
  | `infra:gateway`, `infra:deploy:{dev,qa,uat,prod}`, `infra:detect`, `infra:routing`, `infra:health` | Auto-generated reverse proxy + deployment (parent workspaces) |
977
1343
  | `control-plane`, `federation-os:infra` | Control-plane API + Federation OS observability stack |
@@ -1022,8 +1388,20 @@ For container-to-container federation, replace `localhost` remote URLs with Dock
1022
1388
  | File | Contents |
1023
1389
  |------|----------|
1024
1390
  | `README.md` | Ports, quick start, Docker, quality scripts |
1025
- | `docs/ENTERPRISE_ARCHITECTURE.md` | Design system, RBAC, federation, SDK, deployment |
1391
+ | `docs/ARCHITECT_LEVEL_GUIDE.md` | **Capstone** all architect roles, 9 deliverables, master audit suite, roadmap |
1392
+ | `docs/ENTERPRISE_ARCHITECTURE.md` | Design system, RBAC, federation, SDK, deployment, all pillar links |
1393
+ | `docs/ENTERPRISE_FOLDER_STRUCTURE.md` | DDD, feature modules, packages, federation boundaries, plugins |
1394
+ | `docs/REACT_ARCHITECTURE.md` | State, context, Suspense, error boundaries, feature layout |
1395
+ | `docs/FRONTEND_SECURITY.md` | XSS, CSP, remote trust, auth, supply chain |
1396
+ | `docs/DEVELOPER_EXPERIENCE.md` | Smart build, live reload, affected builds, caching |
1397
+ | `docs/OBSERVABILITY.md` | Telemetry, tracing, RUM, session replay, OTel |
1398
+ | `docs/ACCESSIBILITY.md` | WCAG, keyboard, ARIA, focus management |
1399
+ | `docs/CICD_RELEASE_ENGINEERING.md` | Parallel CI, canary, rollback, federation rollout |
1400
+ | `docs/ENTERPRISE_SCALABILITY.md` | Multi-tenant, CDN, remote discovery, 100k+ users |
1401
+ | `docs/FAILURE_RECOVERY.md` | Circuit breakers, retry, offline, graceful degradation |
1402
+ | `docs/RUNTIME_PERFORMANCE.md` | Runtime profiler (`--monitoring`) |
1026
1403
  | `docs/PLATFORM_ARCHITECTURE.md` | MF CLI, graph, cache, plugins, CI/CD |
1404
+ | `docs/ARCHITECTURE_PROTECTION.md` | Protected structure, `.mss-protected.json` |
1027
1405
  | `docs/CONTROL_PLANE.md` | Workflow designer, monitor, registry (with `--control-plane`) |
1028
1406
  | `docs/FEDERATION_OS.md` | Full Federation OS architecture (with `--federation-os`) |
1029
1407
  | `mf.json` | Project registry, tags, federation config |
@@ -1093,6 +1471,18 @@ node dist/index.js my-platform --control-plane -y
1093
1471
  node dist/index.js my-platform --type=parent --children=admin,billing --shared=corelib -y
1094
1472
  node dist/index.js my-federation-platform --federation-os -y
1095
1473
  node dist/index.js test-app --type=child --port=3001 --template=tsx
1474
+ node dist/index.js add-child analytics --cwd=./mf-structure-test --port=4205 -y
1475
+
1476
+ # patch in-repo test workspaces (mf-test-jsx, my-platform-cp) after pillar changes
1477
+ node scripts/patch-architect-level-test-repos.js
1478
+ node scripts/patch-folder-structure-test-repos.js
1479
+ node scripts/patch-failure-recovery-test-repos.js
1480
+ node scripts/patch-scalability-test-repos.js
1481
+ node scripts/patch-cicd-test-repos.js
1482
+ node scripts/patch-a11y-test-repos.js
1483
+ node scripts/patch-observability-test-repos.js
1484
+ node scripts/patch-security-test-repos.js
1485
+ node scripts/patch-dx-test-repos.js
1096
1486
 
1097
1487
  # optional: link CLI globally
1098
1488
  npm link
@@ -1123,8 +1513,9 @@ npm publish --access public
1123
1513
  | **Federation OS preset** | `--federation-os` → full runtime, governance, observability stack |
1124
1514
  | **Daily dev** | `npm run local` (all apps) or `npm run billing` (one module) |
1125
1515
  | **Shared UI / theme** | Import from `corelib/*` federation exposes |
1126
- | **New remote** | `npm run mf -- generate app <name>` |
1516
+ | **New remote** | `npx create-mf-app add-child <name> --cwd=./my-platform` or `npm run mf -- generate app <name>` |
1127
1517
  | **Enterprise modules** | Flags: `--auth`, `--charts`, `--i18n`, … |
1518
+ | **Architect pillars** | 10 enterprise audits — start with `npm run architect-level:audit` |
1128
1519
  | **Monorepo platform** | `mf graph`, `mf affected build`, `mf doctor` |
1129
1520
  | **Architecture protection** | `.mss-protected.json` + `mss-mf protect` / `delete` guards |
1130
1521
  | **Infrastructure** | Auto `infrastructure/` — nginx, docker, k8s, SSL, env deploy scripts |