# sap/spartacus architecture

> Architecture diagram of the GitHub repository sap/spartacus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sap/spartacus
- Repository: https://github.com/sap/spartacus

## Overview

Spartacus is an Angular composable storefront for SAP Commerce Cloud. A shopper uses storefront experiences for discovery, product details, cart, checkout, and order history; the storefront communicates with Commerce through its REST API, while CMS content supplies page structure and content. The repository also provides shared authentication, state/events, and server-side rendering. Feature and integration directories document substantial capabilities beyond the sampled implementation; links between those unsampled modules are omitted unless the README or excerpts support them.

Main entry points: [`projects/storefrontapp/src/app/app.module.ts`](https://github.com/sap/spartacus/blob/develop/projects/storefrontapp/src/app/app.module.ts) (Storefront app), [`feature-libs/checkout/base/core/facade/checkout-query.service.ts`](https://github.com/sap/spartacus/blob/develop/feature-libs/checkout/base/core/facade/checkout-query.service.ts) (Checkout query), [`core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts`](https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts) (SSR decorator), [`feature-libs/checkout/base/components/services/checkout-flow-orchestrator.service.ts`](https://github.com/sap/spartacus/blob/develop/feature-libs/checkout/base/components/services/checkout-flow-orchestrator.service.ts) (Checkout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront experience"]
  node_storefront_app["Storefront app<br/>[app.module.ts]"]
  node_cms_pages["CMS pages"]
  node_search["Search"]
end

subgraph group_commerce["Commerce journeys"]
  node_product["Product details"]
  node_cart["Cart"]
  node_checkout["Checkout"]
  node_checkout_query["Checkout query"]
  node_orders["Order history"]
end

subgraph group_platform["Core platform"]
  node_authentication["User authentication"]
  node_client_auth["Client authentication"]
  node_anonymous_consent["Anonymous consent"]
  node_configuration["Configuration"]
  node_feature_config["Feature toggles"]
  node_i18n["Internationalization"]
  node_event_service["Event service<br/>[event.service.ts]"]
  node_query_service["Query service<br/>[query.service.ts]"]
end

subgraph group_server["Server rendering"]
  node_ssr_entry["Express engine"]
  node_ssr_decorator["SSR decorator"]
  node_optimized_ssr["Optimized SSR"]
  node_render_cache[("Rendering cache<br/>[rendering-cache.ts]")]
end

node_shopper(("Shopper"))
node_commerce_api["Commerce REST API"]
node_commerce_cms["Commerce CMS"]

node_shopper -->|"uses"| node_storefront_app
node_storefront_app -->|"calls REST"| node_commerce_api
node_storefront_app -->|"fetches content"| node_commerce_cms
node_storefront_app -.->|"renders pages"| node_cms_pages
node_shopper -->|"searches"| node_search
node_shopper -->|"views products"| node_product
node_shopper -->|"manages cart"| node_cart
node_shopper -->|"checks out"| node_checkout
node_shopper -->|"views orders"| node_orders
node_checkout -.->|"uses query"| node_checkout_query
node_checkout_query -->|"creates query"| node_query_service
node_checkout_query -->|"reads cart"| node_cart
node_checkout_query -.->|"loads details"| node_commerce_api
node_ssr_decorator -->|"wraps engine"| node_ssr_entry
node_ssr_decorator -->|"enables optimization"| node_optimized_ssr
node_optimized_ssr -->|"uses cache"| node_render_cache
node_ssr_entry -.->|"renders response"| node_shopper

click node_storefront_app "https://github.com/sap/spartacus/blob/develop/projects/storefrontapp/src/app/app.module.ts"
click node_cms_pages "https://github.com/sap/spartacus/tree/develop/core-libs/core/src/cms"
click node_search "https://github.com/sap/spartacus/blob/develop/core-libs/storefront/cms-components/navigation/search-box/search-box-component.service.ts"
click node_product "https://github.com/sap/spartacus/tree/develop/feature-libs/product"
click node_cart "https://github.com/sap/spartacus/blob/develop/feature-libs/cart/base/core/facade/active-cart.service.ts"
click node_checkout "https://github.com/sap/spartacus/blob/develop/feature-libs/checkout/base/components/services/checkout-flow-orchestrator.service.ts"
click node_checkout_query "https://github.com/sap/spartacus/blob/develop/feature-libs/checkout/base/core/facade/checkout-query.service.ts"
click node_orders "https://github.com/sap/spartacus/blob/develop/feature-libs/order/core/facade/my-account-v2-order-history.service.ts"
click node_authentication "https://github.com/sap/spartacus/tree/develop/core-libs/core/src/auth/user-auth"
click node_client_auth "https://github.com/sap/spartacus/tree/develop/core-libs/core/src/auth/client-auth"
click node_anonymous_consent "https://github.com/sap/spartacus/tree/develop/core-libs/core/src/anonymous-consents"
click node_configuration "https://github.com/sap/spartacus/tree/develop/core-libs/core/src/config"
click node_feature_config "https://github.com/sap/spartacus/tree/develop/core-libs/core/src/features-config"
click node_i18n "https://github.com/sap/spartacus/tree/develop/core-libs/core/src/i18n"
click node_event_service "https://github.com/sap/spartacus/blob/develop/core-libs/core/src/event/event.service.ts"
click node_query_service "https://github.com/sap/spartacus/blob/develop/core-libs/core/src/util/command-query/query.service.ts"
click node_ssr_entry "https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/engine/ng-express-engine.ts"
click node_ssr_decorator "https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts"
click node_optimized_ssr "https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts"
click node_render_cache "https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/optimized-engine/rendering-cache/rendering-cache.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_storefront_app,node_cms_pages,node_search toneBlue
class node_product,node_cart,node_checkout,node_checkout_query,node_orders toneAmber
class node_authentication,node_client_auth,node_anonymous_consent,node_configuration,node_feature_config,node_i18n,node_event_service,node_query_service,node_commerce_api toneMint
class node_ssr_entry,node_ssr_decorator,node_optimized_ssr,node_render_cache toneRose
class node_shopper,node_commerce_cms toneIndigo
```

## Components

### Storefront experience

- [Storefront app](https://github.com/sap/spartacus/blob/develop/projects/storefrontapp/src/app/app.module.ts): `projects/storefrontapp/src/app/app.module.ts`
- [CMS pages](https://github.com/sap/spartacus/tree/develop/core-libs/core/src/cms): `core-libs/core/src/cms`
- [Search](https://github.com/sap/spartacus/blob/develop/core-libs/storefront/cms-components/navigation/search-box/search-box-component.service.ts): `core-libs/storefront/cms-components/navigation/search-box/search-box-component.service.ts`

### Commerce journeys

- [Product details](https://github.com/sap/spartacus/tree/develop/feature-libs/product): `feature-libs/product`
- [Cart](https://github.com/sap/spartacus/blob/develop/feature-libs/cart/base/core/facade/active-cart.service.ts): `feature-libs/cart/base/core/facade/active-cart.service.ts`
- [Checkout](https://github.com/sap/spartacus/blob/develop/feature-libs/checkout/base/components/services/checkout-flow-orchestrator.service.ts): `feature-libs/checkout/base/components/services/checkout-flow-orchestrator.service.ts`
- [Checkout query](https://github.com/sap/spartacus/blob/develop/feature-libs/checkout/base/core/facade/checkout-query.service.ts): `feature-libs/checkout/base/core/facade/checkout-query.service.ts`
- [Order history](https://github.com/sap/spartacus/blob/develop/feature-libs/order/core/facade/my-account-v2-order-history.service.ts): `feature-libs/order/core/facade/my-account-v2-order-history.service.ts`

### Core platform

- [User authentication](https://github.com/sap/spartacus/tree/develop/core-libs/core/src/auth/user-auth): `core-libs/core/src/auth/user-auth`
- [Client authentication](https://github.com/sap/spartacus/tree/develop/core-libs/core/src/auth/client-auth): `core-libs/core/src/auth/client-auth`
- [Anonymous consent](https://github.com/sap/spartacus/tree/develop/core-libs/core/src/anonymous-consents): `core-libs/core/src/anonymous-consents`
- [Configuration](https://github.com/sap/spartacus/tree/develop/core-libs/core/src/config): `core-libs/core/src/config`
- [Feature toggles](https://github.com/sap/spartacus/tree/develop/core-libs/core/src/features-config): `core-libs/core/src/features-config`
- [Internationalization](https://github.com/sap/spartacus/tree/develop/core-libs/core/src/i18n): `core-libs/core/src/i18n`
- [Event service](https://github.com/sap/spartacus/blob/develop/core-libs/core/src/event/event.service.ts): `core-libs/core/src/event/event.service.ts`
- [Query service](https://github.com/sap/spartacus/blob/develop/core-libs/core/src/util/command-query/query.service.ts): `core-libs/core/src/util/command-query/query.service.ts`

### Server rendering

- [Express engine](https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/engine/ng-express-engine.ts): `core-libs/setup/ssr/engine/ng-express-engine.ts`
- [SSR decorator](https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts): `core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts`
- [Optimized SSR](https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts): `core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts`
- [Rendering cache](https://github.com/sap/spartacus/blob/develop/core-libs/setup/ssr/optimized-engine/rendering-cache/rendering-cache.ts): `core-libs/setup/ssr/optimized-engine/rendering-cache/rendering-cache.ts`

### Other components

- **Shopper**
- **Commerce REST API**
- **Commerce CMS**

## Connections

- Shopper → Storefront app: uses (evidence: `README.md`)
- Storefront app → Commerce REST API: calls REST (evidence: `README.md`)
- Storefront app → Commerce CMS: fetches content (evidence: `README.md`)
- Storefront app → CMS pages: renders pages
- Shopper → Search: searches (evidence: `README.md`)
- Shopper → Product details: views products (evidence: `README.md`)
- Shopper → Cart: manages cart (evidence: `README.md`)
- Shopper → Checkout: checks out (evidence: `README.md`)
- Shopper → Order history: views orders (evidence: `README.md`)
- Checkout → Checkout query: uses query
- Checkout query → Query service: creates query (evidence: `feature-libs/checkout/base/core/facade/checkout-query.service.ts`)
- Checkout query → Cart: reads cart (evidence: `feature-libs/checkout/base/core/facade/checkout-query.service.ts`)
- Checkout query → Commerce REST API: loads details
- SSR decorator → Express engine: wraps engine (evidence: `core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts`)
- SSR decorator → Optimized SSR: enables optimization (evidence: `core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts`)
- Optimized SSR → Rendering cache: uses cache (evidence: `core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts`)
- Express engine → Shopper: renders response
