How americanexpress/one-app works
Main Components
• Node.js Server: This is implemented in the src/server directory. It handles server side rendering (SSR), API endpoints, middleware (e.g., security headers, CORS, logging), and configuration management.
• Client Application: Located in src/client, this contains the entry points for client-side rendering, service-worker code (with polyfills and lifecycle events), and publicPath settings.
• Holocron / Modular System: The system’s modular nature is reflected in how the “root module” (the entry point) loads other independent modules. Sample modules and versioned module folders in the prod-sample and one-app-statics directories, as well as the scripts for bundling (one-app-bundler), illustrate these dynamics.
• Universal/Shared Components: Code in src/universal (including reducers, routes, and ducks) that is used on both the client and server.
• Performance, Testing & CI/CD Infrastructure: The presence of directories like __performance__, __tests__, and various GitHub workflow configurations indicates automated testing, performance monitoring, and continuous integration/delivery processes.
• Static Assets & Deployment: The one-app-statics directory, Docker setups (Dockerfile, docker-compose files), and production samples hint at how modules and assets are bundled and served (possibly via a local dev CDN).
Relationships & Data Flows
• Client-to-Server Communication: Show the browser making HTTP requests to the Node.js server. Indicate SSR where the server pre-renders the React application and how the client then takes over hydration.
• Service Worker Interaction: Illustrate the service-worker components (from src/client/service-worker) that handle caching, polyfills, and potentially offline strategies.
• External Dependencies: Include key technologies such as React (for the UI), Node.js (for the server environment), Docker (for containerization), and any monitoring tools (metrics and logging frameworks) visible via directories like src/server/metrics and scripts in __performance__.
Architectural Patterns & Design Principles
• Modularity & Extensibility: Emphasize that each Holocron module can be independently developed, tested, and deployed, with a central “module map” coordinating the dynamic loading. Also note the role of the root module as the entry point that orchestrates other modules.
• Reusability Across Contexts: The existence of a universal code layer (src/universal) shows shared logic that operates on both client and server sides, reinforcing the isomorphic design.