Overview
Openfront’s data layer is powered by 88 KeystoneJS models organized into logical domains. Each model is defined declaratively and automatically generates GraphQL queries, mutations, and database tables.All models are located in
features/keystone/models/ and exported from features/keystone/models/index.ts.Model Categories
Core E-Commerce Models
Product Models
Product
Product
The main product model representing items in your catalog.Key Fields:
title(text, required) - Product namehandle(text, unique) - URL-friendly slugdescription(document) - Rich text descriptionstatus(enum) - draft | proposed | published | rejectedisGiftcard(boolean) - Whether this is a gift card productdiscountable(boolean) - Whether discounts can be applied
productVariants→ ProductVariant (one-to-many)productImages→ ProductImage (many-to-many)productCollections→ ProductCollection (many-to-many)productCategories→ ProductCategory (many-to-many)productTags→ ProductTag (many-to-many)productType→ ProductTypeshippingProfile→ ShippingProfile
thumbnail- First product image URLdimensionsRange- Min/max dimensions from variantsdefaultDimensions- Default variant dimensions
ProductVariant
ProductVariant
Product variations (size, color, etc.) with separate SKUs and pricing.Key Fields:
title(text) - Variant name (e.g., “Large / Blue”)sku(text, unique) - Stock keeping unitbarcode(text) - UPC/EAN barcodeinventoryQuantity(integer) - Stock on handallowBackorder(boolean) - Allow orders when out of stockmanageInventory(boolean) - Track inventory for this variant
product→ Product (required)productOptionValues→ ProductOptionValue (many-to-many)moneyAmounts→ MoneyAmount (one-to-many)measurements→ Measurement (one-to-many)
formattedPrice- Formatted price stringinStock- Whether variant has inventory
ProductImage
ProductImage
Product images with S3 storage integration.Key Fields:
image(image) - S3-stored imagealtText(text) - Accessibility descriptionimagePath(text) - External image URL
products→ Product (many-to-many)
ProductCollection
ProductCollection
Product groupings for merchandising and organization.Key Fields:
title(text, required)handle(text, unique)metadata(json)
products→ Product (many-to-many)
ProductCategory
ProductCategory
Hierarchical product categorization.Key Fields:
name(text, required)handle(text, unique)isActive(boolean)isInternal(boolean)
products→ Product (many-to-many)parent→ ProductCategory (self-referencing)
MoneyAmount
MoneyAmount
Multi-currency pricing for product variants.Key Fields:
amount(integer) - Price in smallest currency unit (cents)minQuantity(integer) - Minimum order quantitymaxQuantity(integer) - Maximum order quantity
productVariant→ ProductVariantregion→ Regioncurrency→ CurrencypriceList→ PriceList
calculatedPrice- Final price after rules and lists
Order Models
Order
Order
Customer orders with complete lifecycle management.Key Fields:
displayId(integer, required) - Human-readable order numberemail(text, required) - Customer emailstatus(enum) - pending | completed | archived | canceled | requires_actiontaxRate(float) - Applied tax ratecanceledAt(timestamp) - Cancellation datesecretKey(text, auto-generated) - Order verification key
user→ User - Customer who placed the ordercart→ Cart - Original shopping cartlineItems→ OrderLineItem (one-to-many)shippingAddress→ AddressbillingAddress→ Addressregion→ Regioncurrency→ Currencypayments→ Payment (one-to-many)fulfillments→ Fulfillment (one-to-many)returns→ Return (one-to-many)discounts→ Discount (many-to-many)events→ OrderEvent (one-to-many)
subtotal- Formatted subtotalshipping- Formatted shipping costdiscount- Formatted discount amounttax- Formatted tax amounttotal- Formatted total pricerawTotal- Numeric total (in cents)fulfillmentStatus- Fulfillment progresspaymentDetails- Payment informationunfulfilled- Items not yet fulfilled
afterOperation- Sends order confirmation email on creationbeforeOperation- Creates order events for status changes
Cart
Cart
Shopping cart with automatic calculations.Key Fields:
email(text) - Guest checkout emailtype(enum) - default | swap | draft_order | payment_link | claimmetadata(json) - Custom datacontext(json) - Session contextabandonedEmailSent(boolean) - Abandoned cart tracking
user→ User (optional for guest carts)region→ Region (required)lineItems→ LineItem (one-to-many)shippingAddress→ AddressbillingAddress→ AddressshippingMethods→ ShippingMethod (one-to-many)discounts→ Discount (many-to-many)paymentCollection→ PaymentCollectionorder→ Order (when completed)
subtotal- Formatted subtotaltotal- Formatted total with tax and shippingrawTotal- Numeric total (in cents)discount- Applied discount amounttax- Calculated taxshipping- Shipping costcheckoutStep- Current checkout step (cart | address | delivery | payment | review)status- ACTIVE | COMPLETED
beforeOperation- Auto-assigns user, handles region changes
LineItem
LineItem
Cart line items with quantity and pricing.Key Fields:
title(text, required) - Product title (snapshot)quantity(integer, required) - Item quantitysku(text) - SKU at time of add to cartthumbnail(text) - Product image URLvariantTitle(text) - Variant namefulfillQuantity(integer) - Quantity fulfilledreturnedQuantity(integer) - Quantity returned
cart→ CartproductVariant→ ProductVariantorder→ Order (when cart is completed)
formattedUnitPrice- Formatted price per unitformattedTotal- Formatted line total
OrderLineItem
OrderLineItem
Order-specific line items (created from cart line items).Key Fields:
title(text, required)quantity(integer, required)sku(text)variantTitle(text)productData(json) - Product snapshotvariantData(json) - Variant snapshot
order→ OrdermoneyAmount→ OrderMoneyAmountfulfillmentItems→ FulfillmentItem (one-to-many)
Customer Models
User
User
Customer and admin user accounts.Key Fields:
name(text, required) - Full nameemail(text, unique, required) - Email addresspassword(password, required) - Hashed passwordphone(text) - Phone numberhasAccount(boolean) - Whether user has account accesscustomerToken(text, unique) - API token for customeronboardingStatus(enum) - not_started | in_progress | completed | dismissed
role→ Role - Permission roleaddresses→ Address (one-to-many)orders→ Order (one-to-many)carts→ Cart (one-to-many)customerGroups→ CustomerGroup (many-to-many)accounts→ Account (one-to-many) - Business accountsapiKeys→ ApiKey (one-to-many)
firstName- Extracted first namelastName- Extracted last nameactiveCartId- Most recent active cart IDbillingAddress- Primary billing address
Address
Address
Shipping and billing addresses.Key Fields:
firstName(text)lastName(text)company(text)address1(text, required)address2(text)city(text, required)province(text) - State/provincepostalCode(text, required)phone(text)isBilling(boolean)isShipping(boolean)
user→ Usercountry→ Country (required)ordersUsingAsShippingAddress→ Order (one-to-many)ordersUsingAsBillingAddress→ Order (one-to-many)
formattedAddress- Full formatted address string
CustomerGroup
CustomerGroup
Customer segmentation for targeted pricing and discounts.Key Fields:
name(text, required)metadata(json)
users→ User (many-to-many)priceLists→ PriceList (many-to-many)
Payment & Billing Models
Payment
Payment
Payment records for orders.Key Fields:
status(enum) - pending | authorized | captured | failed | canceledamount(integer, required) - Amount in centscurrencyCode(text, required)amountRefunded(integer) - Total refundeddata(json) - Provider-specific datacapturedAt(timestamp)canceledAt(timestamp)
order→ Ordercart→ Cartcurrency→ Currencyuser→ Usercaptures→ Capture (one-to-many)refunds→ Refund (one-to-many)paymentCollection→ PaymentCollection
paymentLink- Link to payment provider dashboard (Stripe/PayPal)
beforeOperation- Creates order events and capture records
PaymentProvider
PaymentProvider
Payment integration configuration (Stripe, PayPal, etc.).Key Fields:
name(text, required) - Provider namecode(text, unique, required) - Must start with “pp_”isInstalled(boolean) - Whether provider is activecredentials(json) - API keys and secretscreatePaymentFunction(text) - Adapter function namecapturePaymentFunction(text) - Adapter function namerefundPaymentFunction(text) - Adapter function namehandleWebhookFunction(text) - Webhook handler name
regions→ Region (many-to-many)sessions→ PaymentSession (one-to-many)
PaymentSession
PaymentSession
Temporary payment sessions during checkout.Key Fields:
amount(integer) - Session amountstatus(enum) - pending | authorized | requires_moreisSelected(boolean) - Currently selected payment methoddata(json) - Session data from provider
paymentProvider→ PaymentProviderpaymentCollection→ PaymentCollection
PaymentCollection
PaymentCollection
Collection of payment sessions for a checkout.Key Fields:
amount(integer, required)currencyCode(text, required)status(enum) - not_paid | awaiting | authorized | partially_authorized | canceled
cart→ Cartregion→ RegionpaymentSessions→ PaymentSession (one-to-many)payments→ Payment (one-to-many)
Fulfillment & Shipping Models
Fulfillment
Fulfillment
Order fulfillment records.Key Fields:
canceledAt(timestamp)shippedAt(timestamp)metadata(json)
order→ OrderfulfillmentItems→ FulfillmentItem (one-to-many)shippingLabels→ ShippingLabel (one-to-many)location→ Location - Fulfillment warehouse
ShippingMethod
ShippingMethod
Selected shipping method for cart/order.Key Fields:
price(integer) - Shipping cost in centsdata(json) - Method details
shippingOption→ ShippingOptioncart→ Cartorder→ Order
ShippingLabel
ShippingLabel
Shipping labels from providers (Shippo, ShipEngine).Key Fields:
trackingNumber(text)trackingUrl(text)labelUrl(text) - PDF label URLcarrier(text) - USPS, FedEx, UPS, etc.service(text) - Service levelrate(integer) - Actual shipping cost
fulfillment→ Fulfillmentorder→ Order
ShippingProvider
ShippingProvider
Shipping integration configuration.Key Fields:
name(text, required)code(text, unique) - Must start with “sp_”isInstalled(boolean)credentials(json)getRatesFunction(text) - Adapter functioncreateLabelFunction(text) - Adapter functionvalidateAddressFunction(text) - Adapter function
shippingOptions→ ShippingOption (one-to-many)
Discount & Promotion Models
Discount
Discount
Discount codes and automatic promotions.Key Fields:
code(text, unique) - Discount code (e.g., “SUMMER20”)isDynamic(boolean) - Auto-generated codesisDisabled(boolean)startsAt(timestamp)endsAt(timestamp)usageLimit(integer)usageCount(integer)
discountRule→ DiscountRule - Discount logicregions→ Region (many-to-many)carts→ Cart (many-to-many)orders→ Order (many-to-many)
DiscountRule
DiscountRule
Discount calculation logic.Key Fields:
type(enum) - percentage | fixed | free_shippingvalue(float) - Discount value (percentage or amount)allocation(enum) - total | item
discount→ DiscountdiscountConditions→ DiscountCondition (one-to-many)products→ Product (many-to-many) - Direct product targeting
DiscountCondition
DiscountCondition
Conditions for discount application.Key Fields:
type(enum) - products | product_types | product_collections | product_tags | customer_groupsoperator(enum) - in | not_in
discountRule→ DiscountRuleproducts→ Product (many-to-many)productTypes→ ProductType (many-to-many)productCollections→ ProductCollection (many-to-many)productTags→ ProductTag (many-to-many)customerGroups→ CustomerGroup (many-to-many)
GiftCard
GiftCard
Gift cards with balance tracking.Key Fields:
code(text, unique) - Gift card codevalue(integer) - Original value in cents- `balance” (integer) - Remaining balance
isDisabled(boolean)endsAt(timestamp)
region→ Region- `order” → Order - Purchase order
carts→ Cart (many-to-many)transactions→ GiftCardTransaction (one-to-many)
Returns & Claims Models
Return
Return
Customer return requests.Key Fields:
status(enum) - requested | received | requires_action | canceled- `refundAmount” (integer)
- `receivedAt” (timestamp)
order→ OrderreturnItems→ ReturnItem (one-to-many)- `shippingMethod” → ShippingMethod
ClaimOrder
ClaimOrder
Order claims for damaged/missing items.Key Fields:
type(enum) - refund | replacestatus(enum) - pending | accepted | rejected- `refundAmount” (integer)
order→ OrderclaimItems→ ClaimItem (one-to-many)- `additionalItems” → LineItem (one-to-many) - Replacement items
Regional & Localization Models
Region
Region
Multi-regional commerce support.Key Fields:
name(text, required) - Region name (e.g., “North America”)- `currencyCode” (text, required)
- `taxRate” (float) - Default tax rate
- `taxCode” (text) - Tax jurisdiction code
- `giftCardsTaxable” (boolean)
- `automaticTaxes” (boolean)
currency→ Currencycountries→ Country (many-to-many)- `paymentProviders” → PaymentProvider (many-to-many)
- `fulfillmentProviders” → FulfillmentProvider (many-to-many)
- `taxRates” → TaxRate (one-to-many)
Country
Country
Supported countries.Key Fields:
iso2(text, unique) - ISO 3166-1 alpha-2 codeiso3(text, unique) - ISO 3166-1 alpha-3 code- `numCode” (integer) - ISO numeric code
- `name” (text, required) - Country name
- `displayName” (text, required) - Localized display name
regions→ Region (many-to-many)
Currency
Currency
Multi-currency support.Key Fields:
code(text, unique) - ISO 4217 code (USD, EUR, etc.)- `symbol” (text) - Currency symbol ($, €, etc.)
- `symbolNative” (text) - Native symbol
- `name” (text) - Currency name
- `noDivisionCurrency” (boolean) - No decimal places (JPY, KRW)
regions→ Region (one-to-many)- `moneyAmounts” → MoneyAmount (one-to-many)
Authentication & Authorization Models
Role
Role
Role-based access control.Key Fields:
All permission fields (boolean):
canAccessDashboardcanManageProductscanManageOrderscanManageUserscanManagePayments- … and 20+ more permissions
assignedTo→ User (one-to-many)
ApiKey
ApiKey
API keys for programmatic access.Key Fields:
name(text, required) - Descriptive name- `tokenSecret” (password, required) - Hashed token
- `tokenPreview” (text) - First/last chars for display
- `scopes” (json) - Array of permission scopes
- `status” (enum) - active | inactive | revoked
- `expiresAt” (timestamp)
- `lastUsedAt” (timestamp)
- `usageCount” (json) - Total and daily usage stats
- `restrictedToIPs” (json) - IP whitelist
user→ User
read_products,write_productsread_orders,write_ordersread_customers,write_customersread_fulfillments,write_fulfillments- … and more (see features/keystone/models/ApiKey.ts:15)
OAuthApp
OAuthApp
Third-party app integrations.Key Fields:
name(text, required)- `clientId” (text, unique) - OAuth client ID
- `clientSecret” (password) - OAuth secret
- `redirectUris” (json) - Allowed redirect URIs
- `scopes” (json) - Allowed scopes
- `status” (enum) - active | inactive | suspended
tokens→ OAuthToken (one-to-many)
OAuthToken
OAuthToken
OAuth access and refresh tokens.Key Fields:
tokenType(enum) - authorization_code | access_token | refresh_token- `token” (text, unique)
- `clientId” (text)
- `scopes” (json)
- `expiresAt” (timestamp)
- `isRevoked” (enum) - false | true
user→ User
Business Account Models
Account
Account
Business accounts for B2B commerce.Key Fields:
- `accountType” (enum) - business | personal
- `status” (enum) - active | inactive | suspended
- `creditLimit” (integer) - Maximum credit allowed
- `availableCredit” (integer) - Remaining credit
- `paymentTerms” (text) - Net 30, Net 60, etc.
user→ User- `orders” → Order (one-to-many)
- `invoices” → Invoice (one-to-many)
Invoice
Invoice
Invoices for business accounts.Key Fields:
- `invoiceNumber” (text, unique)
- `status” (enum) - draft | sent | paid | overdue | canceled
- `subtotal” (integer)
- `total” (integer)
- `amountPaid” (integer)
- `dueDate” (timestamp)
account→ Account- `user” → User
- `lineItems” → InvoiceLineItem (one-to-many)
Webhook & Event Models
WebhookEndpoint
WebhookEndpoint
Webhook endpoint configuration.Key Fields:
url(text, required) - Webhook URL- `events” (json) - Array of subscribed events
- `isActive” (boolean)
- `secret” (text) - Signature secret
webhookEvents→ WebhookEvent (one-to-many)
WebhookEvent
WebhookEvent
Webhook delivery log.Key Fields:
event(text) - Event type- `payload” (json) - Event data
- `status” (enum) - pending | sent | failed
- `attempts” (integer)
- `response” (json) - Response from endpoint
webhookEndpoint→ WebhookEndpoint
OrderEvent
OrderEvent
Order activity timeline.Key Fields:
type(text) - Event type (STATUS_CHANGE, PAYMENT_CAPTURED, etc.)- `data” (json) - Event details
order→ Order- `user” → User - Who triggered the event
STATUS_CHANGE- Order status updatedPAYMENT_CAPTURED- Payment processedTRACKING_NUMBER_ADDED- Shipping label createdRETURN_REQUESTED- Return initiatedREFUND_PROCESSED- Refund completed
Complete Model List
All 88 models exported fromfeatures/keystone/models/index.ts:
View All 88 Models
View All 88 Models
Product Domain (11 models)
- Product
- ProductVariant
- ProductImage
- ProductCollection
- ProductCategory
- ProductOption
- ProductOptionValue
- ProductTag
- ProductType
- MoneyAmount
- PriceList
- Order
- OrderLineItem
- OrderMoneyAmount
- OrderEvent
- Cart
- LineItem
- LineItemAdjustment
- LineItemTaxLine
- DraftOrder
- Swap
- IdempotencyKey
- Note
- User
- UserField
- Address
- CustomerGroup
- Team
- Invite
- Payment
- PaymentProvider
- PaymentSession
- PaymentCollection
- Capture
- Refund
- Account
- AccountLineItem
- Invoice
- InvoiceLineItem
- BusinessAccountRequest
- Fulfillment
- FulfillmentItem
- FulfillmentProvider
- ShippingMethod
- ShippingMethodTaxLine
- ShippingOption
- ShippingOptionRequirement
- ShippingProfile
- ShippingProvider
- ShippingLabel
- Location
- StockMovement
- Measurement
- Discount
- DiscountRule
- DiscountCondition
- GiftCard
- GiftCardTransaction
- ClaimOrder
- ClaimItem
- ClaimImage
- ClaimTag
- Return
- ReturnItem
- ReturnReason
- Region
- Country
- Currency
- TaxRate
- TaxProvider
- SalesChannel
- ApiKey
- OAuthApp
- OAuthToken
- WebhookEndpoint
- WebhookEvent
- NotificationProvider
- Notification
- BatchJob
- PriceRule
- PriceSet
- RuleType
- Store
- Role
- CustomShippingOption
Model Relationships Diagram
Working with Models
Querying Models
Creating Records
Using Virtual Fields
Next Steps
Architecture
Learn about the overall system architecture
Authentication
Understand auth models and security
GraphQL API
Explore the complete API reference
Custom Mutations
Build custom business logic