Thursday, August 6, 2026

SAP Commerce Architecture Explained (Complete Guide for Beginners & Experienced Developers)

Introduction

SAP Commerce (formerly known as Hybris) is one of the world's leading enterprise eCommerce platforms. It is widely used by global organizations in industries such as retail, manufacturing, telecommunications, healthcare, and consumer goods to build scalable B2B and B2C commerce solutions.

One of the biggest reasons behind SAP Commerce's popularity is its modular architecture. Every feature—from product management to checkout, search, promotions, and order processing—is built on a layered architecture that is highly extensible.

Whether you are preparing for an interview or starting your first SAP Commerce project, understanding the platform architecture is essential.

In this guide, we'll explore the major architectural components of SAP Commerce and how they work together.


What is SAP Commerce?

SAP Commerce is an enterprise eCommerce platform built on Java and the Spring Framework.

It provides capabilities such as:

  • Product Catalog Management
  • Customer Management
  • Shopping Cart
  • Checkout
  • Promotions
  • Pricing
  • Search
  • Order Management
  • CMS
  • Multi-language support
  • Multi-currency support
  • B2B and B2C commerce

It is designed to support high-traffic enterprise applications.


High-Level Architecture

                Users
                  │
        Web Browser / Mobile App
                  │
      Storefront / OCC REST APIs
                  │
           Controller Layer
                  │
            Facade Layer
                  │
            Service Layer
                  │
             DAO Layer
                  │
        Persistence / Type System
                  │
             Database

Each layer has a specific responsibility.


Presentation Layer

The Presentation Layer is responsible for interacting with end users.

Typical components include:

  • Accelerator Storefront
  • Spartacus Frontend
  • OCC REST APIs
  • SmartEdit

Responsibilities:

  • Receive requests
  • Display pages
  • Validate user input
  • Invoke business logic

The presentation layer should remain lightweight.


Controller Layer

Controllers receive incoming HTTP requests.

Example:

@Controller
public class ProductPageController {

    @GetMapping("/product/{code}")
    public String productDetails() {

        return "productPage";
    }

}

Responsibilities:

  • Handle requests
  • Read request parameters
  • Call Facades
  • Return views or JSON responses

Controllers should not contain business logic.


Facade Layer

The Facade Layer acts as a bridge between controllers and services.

Responsibilities:

  • Aggregate data from multiple services
  • Convert Models to Data objects
  • Simplify controller logic

Typical example:

ProductFacade

↓

ProductData

This keeps controllers clean and reusable.


Service Layer

This is the heart of SAP Commerce.

Services contain all business logic.

Examples:

  • CartService
  • UserService
  • ProductService
  • OrderService
  • CommerceCartService

Responsibilities:

  • Business validations
  • Transactions
  • Integration with DAOs
  • Calling external services

DAO Layer

DAO stands for Data Access Object.

Responsibilities:

  • Execute FlexibleSearch queries
  • Retrieve database records
  • Save model objects

Example:

FlexibleSearchQuery query =
        new FlexibleSearchQuery(
                "SELECT {pk} FROM {Product}"
        );

The DAO layer should never contain business logic.


Type System

The Type System is one of SAP Commerce's unique features.

Every item in SAP Commerce is defined through XML.

Example:

<itemtype code="Product"
          extends="GenericItem">

The platform generates:

  • Model classes
  • Jalo classes (legacy)
  • Constants
  • Database schema

This model-driven approach reduces repetitive coding.


Model Layer

Each item type has a corresponding model.

Example:

ProductModel product =
        modelService.create(
                ProductModel.class
        );

The Model Layer represents business entities such as:

  • Products
  • Customers
  • Orders
  • Categories
  • Carts

Model Service

The Model Service manages model lifecycle operations.

Common methods include:

modelService.create();

modelService.save();

modelService.remove();

modelService.refresh();

Most business operations interact with models through ModelService.


Spring Framework Integration

SAP Commerce is built on the Spring Framework.

Spring provides:

  • Dependency Injection
  • Bean Management
  • Transactions
  • AOP
  • MVC

Example:

@Resource
private ProductService productService;

This enables loose coupling and easier testing.


Search Layer (Solr)

Product search is powered by Apache Solr.

Capabilities include:

  • Full-text search
  • Faceted search
  • Auto-suggestions
  • Sorting
  • Filtering
  • Spell correction

Solr significantly improves search performance compared to database queries.


OCC Layer

OCC (OmniCommerce Connect) exposes REST APIs for:

  • Products
  • Customers
  • Carts
  • Orders
  • Checkout

These APIs are commonly consumed by:

  • Spartacus
  • Mobile applications
  • Third-party integrations

Business Process Engine

Business processes automate long-running workflows.

Examples:

  • Order Confirmation
  • Order Fulfilment
  • Return Process
  • Consignment Processing

The Business Process Engine executes these workflows asynchronously.


CronJobs

CronJobs handle scheduled tasks such as:

  • Solr indexing
  • Data synchronization
  • Catalog imports
  • Cleanup jobs
  • Email processing

They are essential for background processing.


Integration Layer

SAP Commerce integrates with systems such as:

  • SAP ERP
  • SAP S/4HANA
  • SAP CPI
  • Payment gateways
  • Tax providers
  • Shipping providers
  • CRM systems

Integration options include REST APIs, OCC, SAP Integration APIs, events, and messaging.


Real-World Request Flow

Imagine a customer opens a product page.

  1. The browser sends a request.
  2. The controller receives it.
  3. The facade prepares the response.
  4. The service applies business rules.
  5. The DAO retrieves product data.
  6. The model is populated.
  7. The page is rendered to the customer.

This layered approach improves maintainability and scalability.


Best Practices

Keep Controllers Thin

Controllers should only coordinate requests and responses.


Place Business Logic in Services

Avoid implementing business rules in controllers or DAOs.


Use Facades for Data Transformation

Convert models into DTOs before exposing them to the presentation layer.


Optimise FlexibleSearch Queries

Retrieve only the required data and avoid executing queries inside loops.


Follow Extension-Based Development

Create custom extensions instead of modifying SAP-provided code to simplify upgrades.


Common Interview Questions

What are the main layers of SAP Commerce?

Presentation Layer, Controller Layer, Facade Layer, Service Layer, DAO Layer, Type System, and Persistence Layer.


Why is the Facade Layer used?

It aggregates business data, converts models to DTOs, and keeps controllers simple.


What is the purpose of ModelService?

ModelService creates, saves, refreshes, and removes model objects while managing persistence.


What is the Type System?

The Type System defines business entities in XML, from which SAP Commerce generates Java models and database schema.


Why does SAP Commerce use Solr?

Solr provides fast, scalable product search with features such as full-text search, faceting, filtering, and ranking.


Conclusion

Understanding SAP Commerce architecture is essential for building scalable, maintainable enterprise eCommerce applications.

In this guide, you learned:

  • The layered architecture of SAP Commerce
  • The responsibilities of each layer
  • The role of the Type System
  • How ModelService and DAOs work
  • Spring Framework integration
  • Solr search architecture
  • OCC APIs
  • Business Process Engine
  • Enterprise best practices

A strong understanding of these concepts will help you design better solutions, troubleshoot production issues, and perform confidently in SAP Commerce technical interviews.

No comments:

Post a Comment