@multisystemsuite/create-mf-app 1.0.11 → 1.0.13

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 +400 -65
  2. package/dist/index.js +10510 -2470
  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)
@@ -108,10 +112,11 @@ Then use the scripts in [How to use the generated project](#how-to-use-the-gener
108
112
  - **`task-runner/`** — parallel builds + hash cache (`.mf/cache`)
109
113
  - **`plugins/`** — React, Vite, Federation, MUI, Auth, Charts, Workflow, Monitoring
110
114
  - **`devtools/`** — federation inspector, profiler, theme inspector
111
- - **`runtime-config/`** — tenant configs, remote manifests, feature flags
115
+ - **`runtime-config/`** — tenant configs, remote manifests, pillar configs (scaling, resilience, structure, observability, architect roadmap)
112
116
  - **`templates/`** — LIMS, ERP, HMS, SaaS enterprise blueprints
113
117
  - **`ai/`** — AI-ready prompt engine + semantic search hooks
114
118
  - **`governance/`** — import boundaries, CODEOWNERS, dependency rules
119
+ - **Enterprise pillar docs + audits** — security, DX, observability, a11y, CI/CD, scalability, failure recovery, folder structure, architect capstone
115
120
  - **CI/CD** — GitHub Actions, GitLab CI, Helm chart
116
121
  - Root scripts for dev, watch, preview, release, affected builds, **per-child dev shortcuts**
117
122
 
@@ -181,6 +186,7 @@ npm run local # build all apps → watch → preview all ports → live-r
181
186
  | Command | When to use |
182
187
  |---------|-------------|
183
188
  | `npm run local` | **Default daily dev** — all apps (main + every child + shared lib) |
189
+ | `npm run local:fast` | Smart build (skip unchanged) + watch + preview — faster iteration |
184
190
  | `npm run dev` | Print env + run each app's Vite dev server (no federation build watch) |
185
191
  | `npm run dev:fast` | Dev build once, then preview + live-reload |
186
192
  | `npm run dev:safe` | Production build, then preview only |
@@ -462,9 +468,170 @@ See generated `docs/FEDERATION_OS.md` for full architecture.
462
468
  | Federation registry | `apps/corelib/src/federation/` |
463
469
  | Command palette | `apps/corelib/src/command-palette/` (Ctrl+K) |
464
470
  | Production hardening | `apps/corelib/src/production/` (CSP, env validation, diagnostics) |
471
+ | React architecture | `apps/corelib/src/architecture/` + `docs/REACT_ARCHITECTURE.md` |
472
+ | Security hardening | `apps/corelib/src/security/` + `docs/FRONTEND_SECURITY.md` |
473
+ | Observability | `apps/corelib/src/monitoring/`, `observability/` + `docs/OBSERVABILITY.md` |
474
+ | Accessibility | `apps/corelib/src/accessibility/` + `docs/ACCESSIBILITY.md` |
475
+ | Release engineering | `apps/corelib/src/release/` + `docs/CICD_RELEASE_ENGINEERING.md` |
476
+ | Scalability | `apps/corelib/src/scalability/` + `docs/ENTERPRISE_SCALABILITY.md` |
477
+ | Failure recovery | `apps/corelib/src/resilience/` + `docs/FAILURE_RECOVERY.md` |
478
+ | Folder structure | `apps/corelib/src/structure/` + `docs/ENTERPRISE_FOLDER_STRUCTURE.md` |
479
+ | Architect capstone | `apps/corelib/src/architect/` + `docs/ARCHITECT_LEVEL_GUIDE.md` |
465
480
  | MF Platform CLI | `tools/mf-cli/` |
466
481
  | Project graph | `tools/project-graph/` |
467
482
  | Task runner + cache | `task-runner/` + `.mf/cache` |
483
+ | Smart build | `smart-build.js` — dependency-order parallel builds |
484
+ | Developer experience | `docs/DEVELOPER_EXPERIENCE.md`, `turbo.json`, root `tsconfig.json` refs |
485
+
486
+ ---
487
+
488
+ ## Enterprise architect pillars
489
+
490
+ 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.
491
+
492
+ ### Capstone — start here
493
+
494
+ ```bash
495
+ npm run architect-level:audit
496
+ ```
497
+
498
+ | Artifact | Purpose |
499
+ |----------|---------|
500
+ | `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 |
501
+ | `runtime-config/architect-roadmap.json` | Phased roadmap: Foundation → Hardening → Scale → Platform → Optimize |
502
+ | `apps/corelib/src/architect/` | Capstone checklist + domain definitions |
503
+
504
+ ### All enterprise pillar audits
505
+
506
+ | Pillar | Audit command | Documentation |
507
+ |--------|---------------|---------------|
508
+ | **Architect capstone** | `npm run architect-level:audit` | `docs/ARCHITECT_LEVEL_GUIDE.md` |
509
+ | **Folder structure** | `npm run folder-structure:audit` | `docs/ENTERPRISE_FOLDER_STRUCTURE.md` |
510
+ | **React architecture** | `npm run react:architecture-audit` | `docs/REACT_ARCHITECTURE.md` |
511
+ | **Security hardening** | `npm run security:hardening-audit` | `docs/FRONTEND_SECURITY.md` |
512
+ | **Developer experience** | `npm run dx:audit` | `docs/DEVELOPER_EXPERIENCE.md` |
513
+ | **Observability** | `npm run observability:audit` | `docs/OBSERVABILITY.md` |
514
+ | **Accessibility (WCAG)** | `npm run a11y:audit` | `docs/ACCESSIBILITY.md` |
515
+ | **CI/CD + release** | `npm run cicd:audit` | `docs/CICD_RELEASE_ENGINEERING.md` |
516
+ | **Scalability** | `npm run scalability:audit` | `docs/ENTERPRISE_SCALABILITY.md` |
517
+ | **Failure recovery** | `npm run failure-recovery:audit` | `docs/FAILURE_RECOVERY.md` |
518
+ | **Platform health** | `npm run mf:doctor` | `docs/ENTERPRISE_ARCHITECTURE.md` |
519
+ | **Federation contracts** | `npm run federation:verify` | `apps/corelib/src/federation/` |
520
+
521
+ `npm run mf:doctor` prints reminders for every pillar audit after scaffold.
522
+
523
+ ### Pillar summaries
524
+
525
+ #### 1. Security hardening
526
+
527
+ XSS prevention, CSP, secure token handling, refresh strategy (`--auth`), cookie flags, dependency audit, supply chain, federation remote trust, runtime script injection prevention.
528
+
529
+ - **Corelib:** `src/security/frontendSecurityAudit.ts`, `src/federation/remoteTrust.ts`, `src/auth/refreshTokenStrategy.ts`
530
+ - **Config:** hardened CSP in `src/production/csp.ts`
531
+ - **Scripts:** `npm run security:hardening-audit`, `npm run security:audit`
532
+
533
+ #### 2. Developer experience (DX)
534
+
535
+ Smart parallel builds, incremental cache, live reload (SSE), affected detection, project graph.
536
+
537
+ - **Root:** `smart-build.js` (topo-sort + parallel waves), `live-reload.js` (port 35729), `turbo.json`
538
+ - **Scripts:** `npm run local:fast`, `node smart-build.js localdev --skip-unchanged`, `npm run dx:audit`
539
+ - **CLI:** `mf cache invalidate`, `mf affected build`
540
+
541
+ #### 3. Observability (`--monitoring` for full stack)
542
+
543
+ Telemetry, distributed tracing, session replay, error tracking, user journey, performance budgets, RUM, OpenTelemetry.
544
+
545
+ - **Corelib:** `src/monitoring/*` (frontendTelemetry, distributedTracing, sessionReplay, errorTracking, userJourney, performanceBudgets, rum, opentelemetry)
546
+ - **Config:** `runtime-config/observability.config.json`
547
+ - **Bootstrap:** `bootstrapObservability()` via `warmupCorelibShell()` when `--monitoring`
548
+ - **Scripts:** `npm run observability:audit`
549
+
550
+ #### 4. Accessibility (WCAG)
551
+
552
+ Focus management, live announcer, contrast checks, skip links, landmarks, eslint-plugin-jsx-a11y.
553
+
554
+ - **Corelib:** `src/accessibility/focusManagement.ts`, `liveAnnouncer.ts`, `contrastCheck.ts`
555
+ - **Host:** skip link, `#main-content`, `LiveAnnouncerRegion`, `:focus-visible` CSS
556
+ - **Scripts:** `npm run a11y:audit`
557
+
558
+ #### 5. CI/CD + release engineering
559
+
560
+ Parallel CI builds, incremental deploy, federation rollout order, canary, rollback, feature-flag rollouts.
561
+
562
+ - **Workflows:** `mf-platform-ci.yml`, `mf-affected-deploy.yml`, `mf-canary-deploy.yml`, `mf-rollback.yml`
563
+ - **Corelib:** `src/release/` (deploy strategy, federation rollout, rollback)
564
+ - **Scripts:** `npm run cicd:audit`, `npm run release:plan`, `node scripts/release-deploy.js plan`
565
+
566
+ #### 6. Enterprise scalability
567
+
568
+ 100k+ users, multi-tenant, CDN edge, runtime remote discovery, asset distribution, federation scaling, independent deployments.
569
+
570
+ - **Corelib:** `src/scalability/` (multiTenant, cdnEdge, remoteDiscovery, assetDistribution, federationScaling)
571
+ - **Config:** `runtime-config/scaling.config.json`
572
+ - **Scripts:** `npm run scalability:audit`, `npm run mf:graph`
573
+
574
+ #### 7. Production failure recovery
575
+
576
+ Remote fallbacks, offline strategy, retry, circuit breakers, graceful degradation, runtime remote failure handling.
577
+
578
+ - **Corelib:** `src/resilience/` (circuitBreaker, retryPolicy, offlineStrategy, remoteFailureHandler, gracefulDegradation)
579
+ - **UI:** `FederationFallback` + `RemoteRouteBoundary` (emits `mf:remote-failure` events)
580
+ - **Config:** `runtime-config/resilience.config.json`
581
+ - **Federation expose:** `corelib/resilience` — `loadRemoteWithResilience()`, `installRemoteFailureListener()`
582
+ - **Scripts:** `npm run failure-recovery:audit`
583
+
584
+ #### 8. Enterprise folder structure
585
+
586
+ Domain-driven frontend, feature modules, shared packages, federation boundaries, dependency isolation, plugin architecture.
587
+
588
+ - **Corelib:** `src/structure/` (domainMap, boundaryRules, featureModules, dependencyIsolation, pluginArchitecture)
589
+ - **Config:** `runtime-config/structure.config.json` — bounded context → remote map
590
+ - **Governance:** `governance/module-boundaries.json`, `mf.json` tags
591
+ - **Scripts:** `npm run folder-structure:audit`
592
+
593
+ #### 9. React architecture
594
+
595
+ State colocation, context splitting, server vs client state, feature-based layout, atomic design, smart/dumb components, Suspense/error boundaries, concurrent rendering.
596
+
597
+ - **Corelib:** `src/architecture/reactArchitectureAudit.ts`
598
+ - **Scripts:** `npm run react:architecture-audit`
599
+
600
+ #### 10. Architect-level guide (capstone)
601
+
602
+ Enterprise-grade architecture, production optimization, scalability, security, maintainability, developer productivity, deployment strategy, observability strategy, future scalability roadmap.
603
+
604
+ - **Roles:** Senior Frontend Architect, Performance Engineer, Platform Engineer, Enterprise UI Architect, Microfrontend Specialist, DevOps-aware Frontend Engineer
605
+ - **Roadmap:** `runtime-config/architect-roadmap.json` — 5 phases with milestones
606
+ - **Scripts:** `npm run architect-level:audit`
607
+
608
+ ### Runtime configs (generated)
609
+
610
+ ```text
611
+ runtime-config/
612
+ ├── remote-manifest.json # Remote entry URLs + versions
613
+ ├── tenant-config.js # Multi-tenant SaaS
614
+ ├── observability.config.json # Telemetry, RUM, OTel settings
615
+ ├── scaling.config.json # 100k+ user targets, CDN, federation scaling
616
+ ├── resilience.config.json # Retry, circuit breaker, offline policy
617
+ ├── structure.config.json # Domain → remote bounded context map
618
+ ├── architect-roadmap.json # Foundation → Optimize phase tracker
619
+ ├── deployment.config.json # Rollout strategy (release engineering)
620
+ └── feature-flags.js # Runtime feature toggles
621
+ ```
622
+
623
+ ### Pre-production checklist
624
+
625
+ ```bash
626
+ npm run architect-level:audit # capstone — verifies all pillar docs/scripts
627
+ npm run mf:doctor # workspace health + pillar reminders
628
+ npm run federation:verify # remoteEntry health
629
+ npm run folder-structure:audit # DDD layout + import boundaries
630
+ npm run security:hardening-audit # CSP, remote trust, auth
631
+ npm run failure-recovery:audit # circuit breakers + fallbacks
632
+ npm run cicd:audit # CI/CD + canary + rollback workflows
633
+ npm run build # production build all apps
634
+ ```
468
635
 
469
636
  ---
470
637
 
@@ -504,13 +671,46 @@ my-platform/
504
671
  ├── plugins/
505
672
  ├── devtools/
506
673
  ├── runtime-config/
674
+ │ ├── remote-manifest.json
675
+ │ ├── observability.config.json
676
+ │ ├── scaling.config.json
677
+ │ ├── resilience.config.json
678
+ │ ├── structure.config.json
679
+ │ └── architect-roadmap.json
507
680
  ├── templates/
508
681
  ├── ai/
509
682
  ├── governance/
510
683
  ├── k8s/helm/mf-platform/
511
684
  ├── docs/
685
+ │ ├── ENTERPRISE_ARCHITECTURE.md
686
+ │ ├── ARCHITECT_LEVEL_GUIDE.md # capstone architect guide
687
+ │ ├── ENTERPRISE_FOLDER_STRUCTURE.md
688
+ │ ├── REACT_ARCHITECTURE.md
689
+ │ ├── FRONTEND_SECURITY.md
690
+ │ ├── DEVELOPER_EXPERIENCE.md
691
+ │ ├── OBSERVABILITY.md
692
+ │ ├── ACCESSIBILITY.md
693
+ │ ├── CICD_RELEASE_ENGINEERING.md
694
+ │ ├── ENTERPRISE_SCALABILITY.md
695
+ │ ├── FAILURE_RECOVERY.md
696
+ │ └── PLATFORM_ARCHITECTURE.md
512
697
  ├── scripts/
698
+ │ ├── architect-level-audit.js
699
+ │ ├── folder-structure-audit.js
700
+ │ ├── react-architecture-audit.js
701
+ │ ├── security-hardening-audit.js
702
+ │ ├── dx-audit.js
703
+ │ ├── observability-audit.js
704
+ │ ├── a11y-audit.js
705
+ │ ├── cicd-audit.js
706
+ │ ├── scalability-audit.js
707
+ │ ├── failure-recovery-audit.js
708
+ │ └── release-deploy.js
513
709
  ├── .github/workflows/
710
+ │ ├── mf-platform-ci.yml
711
+ │ ├── mf-affected-deploy.yml
712
+ │ ├── mf-canary-deploy.yml
713
+ │ └── mf-rollback.yml
514
714
  ├── docker-compose.yml
515
715
  ├── .env, .env.dev, .env.staging, .env.uat, .env.prod
516
716
  ├── live-reload.js
@@ -611,7 +811,7 @@ node tools/mf-cli/bin/mf.js <command>
611
811
  | `mf federation doctor` | Check host/remotes/shared lib wiring |
612
812
  | `mf federation graph` | Export federation dependency graph |
613
813
  | `mf federation sync` | Sync remote manifests from `mf.json` |
614
- | `mf doctor` | Workspace health (circular deps, boundaries, mf.json, architecture protection) |
814
+ | `mf doctor` | Workspace health (circular deps, boundaries, mf.json, architecture protection, **pillar audit reminders**) |
615
815
  | `npm run federation:verify` | HEAD-check remoteEntry URLs (`MF_REMOTES` env) |
616
816
 
617
817
  ### Architecture protection (`mss-mf`)
@@ -662,43 +862,43 @@ Emergency architect override: `MSS_PROTECT_OVERRIDE=1 mss-mf delete <path> --arc
662
862
 
663
863
  **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
864
 
665
- ### Host (`apps/main`) — wrap shell with providers
865
+ ### Host (`apps/main`) — single `HostShell` expose
866
+
867
+ 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
868
 
667
869
  ```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"));
870
+ const HostShell = React.lazy(() => import("corelib/HostShell"));
674
871
 
675
872
  export default function App() {
676
873
  return (
677
- <React.Suspense fallback={<div>Loading…</div>}>
678
- <AppConfigProvider>
679
- <RoleProvider>
680
- {/* navbar, sidebar, routes */}
681
- </RoleProvider>
682
- </AppConfigProvider>
874
+ <React.Suspense fallback={<ShellSkeleton />}>
875
+ <HostShell navLinks={<HostNavLinks />} onItemPrefetch={prefetchRemotePath}>
876
+ <AppRouter />
877
+ </HostShell>
683
878
  </React.Suspense>
684
879
  );
685
880
  }
686
881
  ```
687
882
 
688
- ### Child remote use shared badge, RBAC, tokens
883
+ `main.tsx` bootstraps runtime remotes (manifest prefetch) before render:
884
+
885
+ ```tsx
886
+ await bootstrapRuntimeRemotes();
887
+ warmupCorelibShell();
888
+ ```
889
+
890
+ ### Child remote — `RemoteAppShell` (skips duplicate providers)
891
+
892
+ When embedded in the host, **`RoleProvider` is not mounted twice**. Standalone dev still wraps with `RoleProvider`:
689
893
 
690
894
  ```tsx
691
- const SharedBadge = React.lazy(() => import("corelib/SharedBadge"));
692
- const RoleProvider = React.lazy(() => import("corelib/RoleProvider"));
895
+ import RemoteAppShell from "corelib/RemoteAppShell";
693
896
 
694
897
  export default function App() {
695
898
  return (
696
- <div className="remote-shell">
697
- <RoleProvider>
698
- <SharedBadge />
699
- <AppRouter />
700
- </RoleProvider>
701
- </div>
899
+ <RemoteAppShell>
900
+ <AppRouter />
901
+ </RemoteAppShell>
702
902
  );
703
903
  }
704
904
  ```
@@ -708,14 +908,18 @@ export default function App() {
708
908
  | Export | Purpose |
709
909
  |--------|---------|
710
910
  | `./App` | Standalone corelib demo app |
911
+ | `./HostShell` | **Host shell bundle** — AppConfig, RoleProvider, Navbar, Sidebar, CommandPalette |
912
+ | `./RemoteAppShell` | **Embedded remote wrapper** — skips RoleProvider when host is active |
711
913
  | `./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 |
914
+ | `./useAppConfig` | Combined hook (backward compatible) |
915
+ | `./AppNavbar`, `./AppSidebar`, `./ThemeToggle` | Shell UI (also inside HostShell) |
916
+ | `./EnterpriseSidebarNav` | Role-filtered sidebar menu + route prefetch hook |
715
917
  | `./RouteGuard`, `./RoleProvider`, `./usePermission` | RBAC |
716
- | `./CommandPalette` | Ctrl+K palette |
918
+ | `./CommandPalette` | Ctrl+K palette (returns `null` when closed) |
717
919
  | `./DashboardLayout` | Dashboard shell layout |
718
920
  | `./PermissionProvider`, `./FederationFallback` | Permissions + error UI |
921
+ | `./resilience` | Circuit breakers, retry, offline, `loadRemoteWithResilience()`, `installRemoteFailureListener()` |
922
+ | `./ProfilerGate` | Dev-only React Profiler wrapper |
719
923
  | `./designTokens` | Token registry |
720
924
 
721
925
  ### TypeScript — add declarations in host/child
@@ -750,19 +954,30 @@ apps/corelib/src/
750
954
 
751
955
  ### Runtime theme in your components
752
956
 
957
+ Split config hooks reduce re-renders (prefer these over the combined hook in hot paths):
958
+
753
959
  ```tsx
754
- import { useAppConfig } from "corelib/useAppConfig";
960
+ import {
961
+ useAppConfigPick,
962
+ useAppConfigActions,
963
+ useAppTheme,
964
+ useAppConfig, // backward compatible
965
+ } from "corelib/useAppConfig";
755
966
 
756
967
  function MyWidget() {
757
- const { config, palette, shell, toggleColorMode } = useAppConfig();
968
+ const { tenantId } = useAppConfigPick("tenantId");
969
+ const { toggleColorMode } = useAppConfigActions();
970
+ const { palette } = useAppTheme();
758
971
  return (
759
972
  <div style={{ color: palette.textPrimary, background: palette.surface }}>
760
- {config.appName}
973
+ Tenant: {tenantId}
761
974
  </div>
762
975
  );
763
976
  }
764
977
  ```
765
978
 
979
+ **Config architecture:** `AppConfigProvider` uses three contexts — **State** (config object), **Actions** (stable mutations), **Theme** (resolved palette). Sidebar/nav components use CSS variables (`--ds-*`) where possible.
980
+
766
981
  **Features:**
767
982
 
768
983
  - Enterprise-light / enterprise-dark presets + Azure, Atlassian, Linear-dark, etc.
@@ -784,38 +999,41 @@ Then hard-refresh the browser.
784
999
 
785
1000
  ## Module Federation
786
1001
 
787
- ### Architecture
1002
+ ### Architecture (tiered host / shared / remotes)
788
1003
 
789
1004
  ```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, …
1005
+ ┌──────────────────────────────────────────────────────────────┐
1006
+ │ apps/main (host) :3000 — CSS shell ~137 KB gzip
1007
+ │ ├── eager shared: react, react-dom only
1008
+ │ ├── lazy shared: react-router-dom, @tanstack/react-query
1009
+ ├── corelib/HostShell (single federation expose)
1010
+ │ └── feature remotes on /admin-app/*, /analytics-app/*, … │
1011
+ └──────────────────────────────────────────────────────────────┘
1012
+
797
1013
 
798
- ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
799
- apps/billing apps/orders │ │ apps/corelib
800
- :3001 │ :3002 │ :3003 │
801
- └──────────────┘ └──────────────┘ └──────────────┘
1014
+ ┌──────────────────┐ ┌─────────────────────────────────────┐
1015
+ apps/corelib │ apps/<child> (feature remotes)
1016
+ MUI, RBAC, DS │◀────│ RemoteAppShell when embedded
1017
+ :3006 │ │ standard / control-plane share tiers│
1018
+ └──────────────────┘ └─────────────────────────────────────┘
802
1019
  ```
803
1020
 
804
- ### Shared dependency rules (important)
805
-
806
- The generator configures federation so **one React/MUI instance** is shared:
1021
+ Shared policy lives in **`packages/shared-config/src/federationShared.ts`**:
807
1022
 
808
- **Host (`apps/main/federation.config.ts`):**
1023
+ | Tier | Packages | Host | corelib / remotes |
1024
+ |------|----------|------|-------------------|
1025
+ | 0 | `react`, `react-dom` | eager singleton | singleton |
1026
+ | 1 | `react-router-dom`, `@tanstack/react-query` | lazy shared | shared |
1027
+ | 2 | MUI, Emotion | **not on host** | corelib + remotes |
1028
+ | 3 | `zustand`, `@xyflow/react`, … | per-app only | control-plane remotes |
809
1029
 
810
- - Provides shared deps with **exact semver** keys: `version: "19.0.0"` (not `^19.0.0`)
811
- - `singleton: true`, `import: true`
1030
+ **Production:** `strictVersion: true` is enabled automatically for `prod`, `staging`, and `uat` builds (or set `VITE_MF_STRICT_SHARED=1`).
812
1031
 
813
- **Remotes (children + corelib):**
1032
+ **Remote URLs:** env-driven via `packages/shared-config/src/federationRemotes.ts` (`VITE_<APP>_REMOTE_ENTRY`). Local default:
814
1033
 
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`
1034
+ ```text
1035
+ http://localhost:<port>/assets/remoteEntry.js
1036
+ ```
819
1037
 
820
1038
  **After changing federation config:**
821
1039
 
@@ -826,15 +1044,66 @@ npm run local # restart
826
1044
 
827
1045
  Use **hoisted install** (generated `.npmrc`: `install-strategy=hoisted`).
828
1046
 
829
- ### Remote URLs (local dev)
1047
+ ---
830
1048
 
831
- Each app's `federation.config.ts` points to:
1049
+ ## Performance & federation architecture
832
1050
 
833
- ```text
834
- http://localhost:<port>/assets/remoteEntry.js
1051
+ 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.
1052
+
1053
+ ### Bundle size & Vite
1054
+
1055
+ | Feature | Location | Purpose |
1056
+ |---------|----------|---------|
1057
+ | Shared Vite base | `apps/vite.config.base.ts` | `mfSafeManualChunks`, `resolve.dedupe`, gzip/brotli in prod |
1058
+ | Host thin shell | `apps/main` | No MUI/Emotion on host boot path |
1059
+ | Lazy DataGrid | `corelib/AppDataGrid` | `@mui/x-data-grid` dynamic import |
1060
+ | Route prefetch | `main/src/routes/remoteLoaders.ts` | Hover/focus prefetch before navigation |
1061
+ | `RemoteSkeleton` | `main/src/components/RemoteSkeleton.tsx` | Non-blocking loading UI |
1062
+
1063
+ Run bundle analysis:
1064
+
1065
+ ```bash
1066
+ npm run analyze:bundle
1067
+ # or per app: cd apps/main && npm run analyze
1068
+ ```
1069
+
1070
+ ### Runtime remote loading
1071
+
1072
+ | Feature | Location | Purpose |
1073
+ |---------|----------|---------|
1074
+ | Runtime manifest | `runtime-config/remote-manifest.json` | CDN/prod remote entry map |
1075
+ | Bootstrap | `main/src/module-federation/bootstrapRemotes.ts` | Fetch manifest, preconnect, prefetch `remoteEntry` |
1076
+ | Dev manifest server | `apps/main/vite.config.ts` | Serves `/runtime-config/*` in local dev |
1077
+ | Idle warm-up | `warmupCorelibShell()` in `main.tsx` | Idle-import `corelib/HostShell` |
1078
+ | Error boundaries | `main/src/components/RemoteRouteBoundary.tsx` | Per-remote fallback + retry |
1079
+ | nginx caching | `infrastructure/nginx/conf.d/federation.conf` | Short cache on `remoteEntry`, manifest at `/runtime-config/` |
1080
+
1081
+ Env override for manifest URL:
1082
+
1083
+ ```bash
1084
+ VITE_REMOTE_MANIFEST_URL=/runtime-config/remote-manifest.json
835
1085
  ```
836
1086
 
837
- Match ports from root `.env` when customizing.
1087
+ ### Re-render performance (corelib)
1088
+
1089
+ - **Split contexts:** `useAppConfigState`, `useAppConfigActions`, `useAppTheme`, `useAppConfigPick`
1090
+ - **Memo shell:** `EnterpriseSidebarNav`, `AppTable`, `AppDataGrid`, host nav links
1091
+ - **Command palette:** no render when closed
1092
+ - **Control plane dashboard:** tab-isolated data (health WebSocket only in Monitor tab)
1093
+ - **Dev profiling:** `ProfilerGate` wraps host navbar, sidebar, and router regions
1094
+
1095
+ ### Host / remote communication
1096
+
1097
+ | Channel | Mechanism |
1098
+ |---------|-----------|
1099
+ | Navigation | Host owns `BrowserRouter`; remotes use nested `<Routes>` |
1100
+ | Server state | Singleton `@my-platform/query-client` at host |
1101
+ | Theme / RBAC | corelib contexts via `HostShell` (single provider tree) |
1102
+ | Cross-MFE events | Extend with event bus / shared query keys as needed |
1103
+
1104
+ ### Reference platform
1105
+
1106
+ 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
1107
 
839
1108
  ---
840
1109
 
@@ -886,10 +1155,27 @@ task-runner/
886
1155
 
887
1156
  ```text
888
1157
  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
1158
+ ├── remote-manifest.json # Remote entry URLs + versions (host bootstrap)
1159
+ ├── tenant-config.js # Multi-tenant SaaS configs
1160
+ ├── observability.config.json # Telemetry, RUM, OTel settings
1161
+ ├── scaling.config.json # Scalability targets, CDN, multi-tenant
1162
+ ├── resilience.config.json # Retry, circuit breaker, offline policy
1163
+ ├── structure.config.json # Domain → remote bounded context map
1164
+ ├── architect-roadmap.json # Foundation → Optimize phase tracker
1165
+ ├── deployment.config.json # Rollout strategy (release engineering)
1166
+ ├── manifest-loader.js # CDN remote manifest fetch
1167
+ ├── feature-flags.js # Runtime feature toggles
1168
+ └── branding.js # Dynamic logo/colors injection
1169
+ ```
1170
+
1171
+ 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).
1172
+
1173
+ Per-remote env overrides (build time):
1174
+
1175
+ ```bash
1176
+ VITE_CORELIB_REMOTE_ENTRY=http://localhost:3006/assets/remoteEntry.js
1177
+ VITE_ADMIN_APP_REMOTE_ENTRY=http://localhost:3001/assets/remoteEntry.js
1178
+ # … see packages/shared-config/src/federationRemotes.ts
893
1179
  ```
894
1180
 
895
1181
  ---
@@ -914,8 +1200,10 @@ Enterprise blueprints in `templates/`:
914
1200
 
915
1201
  **GitHub Actions:**
916
1202
 
917
- - `.github/workflows/mf-platform-ci.yml` — doctor, affected lint/test/build, security audit
1203
+ - `.github/workflows/mf-platform-ci.yml` — doctor, affected lint/test/build, security audit, pillar audits
918
1204
  - `.github/workflows/mf-affected-deploy.yml` — affected deploy on main
1205
+ - `.github/workflows/mf-canary-deploy.yml` — canary promotion with health checks
1206
+ - `.github/workflows/mf-rollback.yml` — federation rollback workflow
919
1207
 
920
1208
  **Also generated:**
921
1209
 
@@ -948,6 +1236,16 @@ Generated parent workspaces include:
948
1236
  | `npm run cleanup` | lint:fix → imports → type-check |
949
1237
  | `npm run analyze:bundle` | Rollup visualizer per app |
950
1238
  | `npm run security:audit` | npm audit |
1239
+ | `npm run security:hardening-audit` | Frontend security pillar audit |
1240
+ | `npm run architect-level:audit` | Capstone — verifies all enterprise pillar docs/scripts |
1241
+ | `npm run folder-structure:audit` | DDD layout, federation boundaries, dependency isolation |
1242
+ | `npm run react:architecture-audit` | React architecture pillars |
1243
+ | `npm run dx:audit` | Developer experience maturity |
1244
+ | `npm run observability:audit` | Telemetry, RUM, tracing, error tracking |
1245
+ | `npm run a11y:audit` | WCAG accessibility checklist |
1246
+ | `npm run cicd:audit` | CI/CD + release engineering |
1247
+ | `npm run scalability:audit` | 100k+ users, CDN, multi-tenant |
1248
+ | `npm run failure-recovery:audit` | Circuit breakers, retry, fallbacks |
951
1249
  | `npm run production:hygiene` | Fail on console/debugger in sources |
952
1250
 
953
1251
  Husky: lint-staged + type-check + tests on pre-commit; lint + tests on pre-push. Commitlint for Conventional Commits.
@@ -961,6 +1259,8 @@ Husky: lint-staged + type-check + tests on pre-commit; lint + tests on pre-push.
961
1259
  | Script | Purpose |
962
1260
  |--------|---------|
963
1261
  | `local` | **Main dev command** — build:local + watch + preview + live-reload (all apps) |
1262
+ | `local:fast` | Smart build (skip unchanged) + watch + preview + live-reload |
1263
+ | `build:local` | `node smart-build.js localdev` — parallel dependency-order build |
964
1264
  | `dev` | print-env + parallel Vite dev servers |
965
1265
  | `dev:watch` | Same as `local` |
966
1266
  | `dev:fast` | dev build once + preview + live-reload |
@@ -972,6 +1272,17 @@ Husky: lint-staged + type-check + tests on pre-commit; lint + tests on pre-push.
972
1272
  | `preview:<app>` | Vite preview for one app |
973
1273
  | `release` / `release:minor` / `release:major` | Version bump + build |
974
1274
  | `federation:verify` | Remote entry health check |
1275
+ | `architect-level:audit` | Capstone enterprise platform audit |
1276
+ | `folder-structure:audit` | Domain-driven folder structure audit |
1277
+ | `react:architecture-audit` | React architecture audit |
1278
+ | `security:hardening-audit` | Frontend security hardening audit |
1279
+ | `dx:audit` | Developer experience audit |
1280
+ | `observability:audit` | Observability stack audit |
1281
+ | `a11y:audit` | Accessibility (WCAG) audit |
1282
+ | `cicd:audit` | CI/CD + release engineering audit |
1283
+ | `scalability:audit` | Enterprise scalability audit |
1284
+ | `failure-recovery:audit` | Production failure recovery audit |
1285
+ | `release:plan` | Deployment rollout plan |
975
1286
  | `mf`, `mf:graph`, `mf:affected`, `mf:doctor`, `mss-mf`, `mf:protect` | Platform CLI + architecture protection |
976
1287
  | `infra:gateway`, `infra:deploy:{dev,qa,uat,prod}`, `infra:detect`, `infra:routing`, `infra:health` | Auto-generated reverse proxy + deployment (parent workspaces) |
977
1288
  | `control-plane`, `federation-os:infra` | Control-plane API + Federation OS observability stack |
@@ -1022,8 +1333,20 @@ For container-to-container federation, replace `localhost` remote URLs with Dock
1022
1333
  | File | Contents |
1023
1334
  |------|----------|
1024
1335
  | `README.md` | Ports, quick start, Docker, quality scripts |
1025
- | `docs/ENTERPRISE_ARCHITECTURE.md` | Design system, RBAC, federation, SDK, deployment |
1336
+ | `docs/ARCHITECT_LEVEL_GUIDE.md` | **Capstone** all architect roles, 9 deliverables, master audit suite, roadmap |
1337
+ | `docs/ENTERPRISE_ARCHITECTURE.md` | Design system, RBAC, federation, SDK, deployment, all pillar links |
1338
+ | `docs/ENTERPRISE_FOLDER_STRUCTURE.md` | DDD, feature modules, packages, federation boundaries, plugins |
1339
+ | `docs/REACT_ARCHITECTURE.md` | State, context, Suspense, error boundaries, feature layout |
1340
+ | `docs/FRONTEND_SECURITY.md` | XSS, CSP, remote trust, auth, supply chain |
1341
+ | `docs/DEVELOPER_EXPERIENCE.md` | Smart build, live reload, affected builds, caching |
1342
+ | `docs/OBSERVABILITY.md` | Telemetry, tracing, RUM, session replay, OTel |
1343
+ | `docs/ACCESSIBILITY.md` | WCAG, keyboard, ARIA, focus management |
1344
+ | `docs/CICD_RELEASE_ENGINEERING.md` | Parallel CI, canary, rollback, federation rollout |
1345
+ | `docs/ENTERPRISE_SCALABILITY.md` | Multi-tenant, CDN, remote discovery, 100k+ users |
1346
+ | `docs/FAILURE_RECOVERY.md` | Circuit breakers, retry, offline, graceful degradation |
1347
+ | `docs/RUNTIME_PERFORMANCE.md` | Runtime profiler (`--monitoring`) |
1026
1348
  | `docs/PLATFORM_ARCHITECTURE.md` | MF CLI, graph, cache, plugins, CI/CD |
1349
+ | `docs/ARCHITECTURE_PROTECTION.md` | Protected structure, `.mss-protected.json` |
1027
1350
  | `docs/CONTROL_PLANE.md` | Workflow designer, monitor, registry (with `--control-plane`) |
1028
1351
  | `docs/FEDERATION_OS.md` | Full Federation OS architecture (with `--federation-os`) |
1029
1352
  | `mf.json` | Project registry, tags, federation config |
@@ -1094,6 +1417,17 @@ node dist/index.js my-platform --type=parent --children=admin,billing --shared=c
1094
1417
  node dist/index.js my-federation-platform --federation-os -y
1095
1418
  node dist/index.js test-app --type=child --port=3001 --template=tsx
1096
1419
 
1420
+ # patch in-repo test workspaces (mf-test-jsx, my-platform-cp) after pillar changes
1421
+ node scripts/patch-architect-level-test-repos.js
1422
+ node scripts/patch-folder-structure-test-repos.js
1423
+ node scripts/patch-failure-recovery-test-repos.js
1424
+ node scripts/patch-scalability-test-repos.js
1425
+ node scripts/patch-cicd-test-repos.js
1426
+ node scripts/patch-a11y-test-repos.js
1427
+ node scripts/patch-observability-test-repos.js
1428
+ node scripts/patch-security-test-repos.js
1429
+ node scripts/patch-dx-test-repos.js
1430
+
1097
1431
  # optional: link CLI globally
1098
1432
  npm link
1099
1433
  create-mf-app my-platform --control-plane -y
@@ -1125,6 +1459,7 @@ npm publish --access public
1125
1459
  | **Shared UI / theme** | Import from `corelib/*` federation exposes |
1126
1460
  | **New remote** | `npm run mf -- generate app <name>` |
1127
1461
  | **Enterprise modules** | Flags: `--auth`, `--charts`, `--i18n`, … |
1462
+ | **Architect pillars** | 10 enterprise audits — start with `npm run architect-level:audit` |
1128
1463
  | **Monorepo platform** | `mf graph`, `mf affected build`, `mf doctor` |
1129
1464
  | **Architecture protection** | `.mss-protected.json` + `mss-mf protect` / `delete` guards |
1130
1465
  | **Infrastructure** | Auto `infrastructure/` — nginx, docker, k8s, SSL, env deploy scripts |