Multi-Zone Composition
Why BookWorm splits customer discovery and authenticated checkout into two zones behind one gateway origin, and how cross-zone navigation works.
Purpose & Scope
This reference explains BookWorm’s multi-zone microfrontend architecture for customer-facing experiences: Storefront (public discovery) and Commerce (authenticated shopping and account management). It defines why these two zones are separated behind a single API Gateway origin and how they coordinate routing, assets, and authentication.
Cross-Zone Sign-In Handoff
The visual below illustrates how an unauthenticated shopper crossing from Storefront into a protected Commerce route is redirected to Storefront’s identity handoff and returned seamlessly to their destination.
Loading graph...
Architectural Principles & Rules
- Workload isolation by caching profile: Public catalog discovery (Storefront) and private transactional workflows (Commerce) run as separate application deployments so aggressive component caching and SEO optimization never risk leaking user-specific basket or order state.
- Single-origin presentation: Both customer zones share one HTTPS origin via the API Gateway, eliminating cross-domain cookie complexity, extra identity redirect URIs, and CORS overhead.
- Shared routing manifest: Both the reverse proxy and the microfrontend framework read a single authoritative route manifest so path ownership and static asset prefixes stay synchronized.
- Document-level zone isolation: Transitions across the Storefront–Commerce boundary use full-document navigation with prefetching rather than runtime bundle federation, preventing React tree or global state coupling across independent deployments.
Storefront owns the customer authentication callback and identity provider integration. Commerce does not host its own login handler; it validates the shared origin-scoped session cookie and redirects unauthenticated visitors back to Storefront’s sign-in flow.
Patterns & Boundaries
| Concern / Surface | Architectural Approach | Responsibility Boundary | Key Trade-off |
|---|---|---|---|
| Zone Split | Two independent web runtimes behind one API Gateway | Storefront owns discovery and AI chat; Commerce owns basket, checkout, and orders | Two customer containers to operate, repaid by independent scaling and cache isolation |
| Asset Isolation | Dedicated asset prefix per non-root zone | Commerce serves static bundles under an isolated asset path | Prevents static asset collisions, but requires gateway route registration for zone assets |
| Shared Chrome | Build-time shared customer shell package | Shared shell owns header, footer, mobile nav, and basket indicator | Visual consistency without runtime federation; shell updates rebuild both customer apps |
| Cross-Zone Navigation | Prefetched cross-zone link abstraction | Shared shell provides zone-aware links; browser performs clean runtime handoff | Slightly heavier transition across zones than intra-app routing, mitigated by prefetching |
- Single customer monolith: Couples public catalog caching, heavy conversational AI dependencies, and private checkout routes into one build and failure domain.
- Separate subdomains: Simplifies path routing, but introduces cross-subdomain cookie scoping, fragmented SEO authority, and multiple identity callback registrations.
- Client-side Module Federation: Avoids document reloads across zones, but introduces bundler runtime coupling, version-skew risks across Server Components, and complex hydration.
Quality & Operational Impact
- Deployment Agility: Teams can release Storefront catalog or AI assistant updates without redeploying or risking Commerce checkout stability.
- Security & Privacy: Separating caching profiles at the application boundary provides defense-in-depth against accidental caching of authenticated customer data.
- Reliability: A fault or memory spike in conversational AI streaming remains isolated to Storefront and cannot degrade Commerce checkout.