The Intershop Progressive Web App (PWA) is a scalable and modular eCommerce storefront built on Angular. It acts as a frontend for the Intershop Commerce Suite (ICM) backend platform, delivering modern eCommerce features like responsiveness, offline support, and fast user experiences.
Here’s a detailed breakdown of how the Intershop PWA works and communicates:
1. Architecture Overview
Frontend Framework
The PWA is based on Angular and uses Angular modules, dependency injection, and component-based architecture to build a dynamic and flexible storefront.
It supports Server-side Rendering (SSR) for better SEO and performance.
Backend Communication
The PWA communicates with the Intershop Commerce Suite (ICM) via REST APIs.
The API endpoints are dynamically constructed based on the PWA configuration and user’s locale, currency, and session.
Main Features
Modular Design:
The app is divided into core modules (CoreModule, ShellModule, etc.) and feature modules (e.g., QuickorderRoutingModule, QuotingRoutingModule).
Features like comparison, quoting, wishlist sharing, and store locator are implemented as extensions.
State Management:
It uses NgRx for application-wide state management, ensuring predictable state transitions.
Customization:
Environment-specific configurations (e.g., themes like B2B or B2C) are supported for flexibility.
The docker-compose file allows for deploying custom configurations.
2. Communication Flow
The communication flow in the Intershop PWA revolves around API requests, dynamic configuration, and real-time state updates. Below is how this works in detail:
a) API Service
The ApiService (api.service.ts) is the core utility for backend communication. It handles HTTP requests and applies additional functionality like headers, parameters, and error handling.
Key Responsibilities of ApiService:
Dynamic URL Construction:
URLs for REST endpoints are dynamically built using:
REST API Base URL: Retrieved from the ICM configuration.
Locale and Currency: Automatically appended to the URLs (e.g., ;loc=en_US, ;cur=USD).
Personalization Parameters: pgid and spgid are optional parameters for personalized content.
Basket API: Handles requests related to the current basket (cart), e.g., adding items, updating quantities.
B2B User API: Constructs endpoints for authenticated B2B users, allowing operations like managing users or roles.
ts
b) State Management with NgRx
The PWA uses NgRx to manage application state and synchronize API data with the frontend.
Key stores include:
core/configuration: Handles global configurations like locale, currency, and ICM server URL.
customer/basket: Manages the shopping basket state (current basket ID or details).
customer/user: Tracks user authentication and profile data.
Example: When the API retrieves the basket data, it dispatches an action to update the customer/basket state, ensuring the UI reflects the latest basket contents.
c) Server-side Rendering (SSR)
The PWA supports SSR via Angular Universal, ensuring SEO-friendly pages and better initial load performance.
The AppServerModule (app.server.module.ts) implements custom interceptors (UniversalCacheInterceptor, UniversalLogInterceptor, etc.) to handle SSR-specific requirements like caching and logging.
d) Environment Configuration
Environment-specific settings are managed via the environment files and Docker setup (docker-compose.yml).
Examples of configurable parameters:
ICM Base URL: Backend URL for API requests.
Themes: Choose between B2B or B2C themes.
Service Worker: Enable or disable offline support.
The PWA can run in a containerized environment using Docker Compose.
The docker-compose.yml file defines services like:
PWA (Frontend): Runs the Angular application.
Nginx: Acts as a reverse proxy, serving the PWA and handling caching, compression, and SSL.
Redis (Optional): Can be used for caching.
b) Development Workflow
Install dependencies:
bash
npm install
Start the development server:
bash
npm start
Build for production:
bash
npm run build
4. Error Handling
The PWA has robust error-handling mechanisms:
Global Error Handler (DefaultErrorHandler):
Logs errors and provides fallback behavior.
HTTP Error Interceptors:
Handles server errors or communication issues and triggers appropriate actions in the store.
For example, a 500 error from the API triggers a serverError action:
ts
this.store.dispatch(serverError({ error }));
5. Key Functionalities
CoreModule
Central module for core services like HTTP interceptors, error handling, and internationalization.
API Services
Centralized service for all communication with the ICM backend.
Feature Modules
Extensible modular structure for adding features like quoting, comparison, and wishlist sharing.
Dynamic Configuration
Supports multiple locales, currencies, and themes, enabling seamless customization.
Conclusion
The Intershop PWA is a modern, modular, and scalable eCommerce frontend that communicates with the Intershop Commerce Suite through REST APIs. Its architecture ensures flexibility, extensibility, and performance, making it suitable for complex eCommerce requirements.