Skip to main content

Overview

Spree is built around a set of interconnected models that represent the core concepts of e-commerce: products, orders, payments, and shipments. Understanding how these pieces fit together is essential for customizing and extending Spree.

Core Commerce Flow

The following diagram shows how the main models interact during a typical customer purchase: How it works:
  1. Catalog - Products have Variants (SKUs) with prices and inventory tracked at Stock Locations
  2. Shopping - Customers add Variants to their cart, creating an Order with Line Items
  3. Checkout - The Order collects Addresses, calculates Shipping options, and processes Payments
  4. Fulfillment - Shipments are created from Stock Locations, tracking individual Inventory Units
  5. Pricing & Adjustments - Taxes and Promotions create Adjustments that modify order totals

Core Model Relationships

This diagram shows the key database relationships between Spree’s main models:

Multi-Store Architecture

Spree supports multiple Stores from a single installation. Each Store can have:
  • Its own domain and branding
  • Different currencies and locales
  • Separate product catalogs
  • Independent payment and shipping methods
  • Isolated orders and customers
This makes Spree suitable for multi-brand retailers, international expansion, or B2B/B2C hybrid setups.

Extension Points

Spree is designed to be customized without modifying core code. The main extension mechanisms are:
MechanismUse CaseDocumentation
Events & SubscribersReact to order completion, payment, shipment eventsEvents Guide
WebhooksNotify external systems of changesWebhooks Guide
DependenciesSwap out services (tax calculation, shipping estimation)Dependencies Guide
DecoratorsModify existing model/controller behavior (use sparingly)Decorators Guide
For most customizations, prefer Events and Dependencies over Decorators. They’re easier to maintain and won’t break during upgrades.

Code Conventions

Spree is built on Ruby on Rails and follows Model-View-Controller (MVC) architecture. All Spree code is namespaced under Spree:: to avoid conflicts with your application code. Example: Product
ComponentLocationClass Name
Modelcore/app/models/spree/product.rbSpree::Product
Admin Controlleradmin/app/controllers/spree/admin/products_controller.rbSpree::Admin::ProductsController
API Serializerapi/app/serializers/spree/v2/storefront/product_serializer.rbSpree::V2::Storefront::ProductSerializer

Packages

Spree is distributed as a set of Ruby gems (packages). Most users run Spree in headless mode with a custom frontend built using the Storefront API or Platform API. Core packages (required):
PackagePurpose
spree_coreModels, services, and business logic
spree_apiStorefront API, Platform API, and Webhooks
Optional packages:
PackagePurpose
spree_adminAdmin dashboard for managing your store
spree_cliCLI tool to interact with your Spree installation
spree_storefrontPre-built Rails storefront (not needed for headless setups)
spree_emailsTransactional email templates (order confirmation, shipping, etc.)
spree_page_builderVisual page builder for the Rails storefront
spree_sampleSample data (products, categories, etc.) for development and testing
spree_dev_toolsDevelopment and testing utilities for Spree applications and extensions
For headless commerce, you only need spree_core and spree_api. Build your customer-facing frontend with any technology (Next.js, Nuxt, mobile apps) using the Storefront API.