Focus On Behavior, Not State, for a More Maintainable Codebase
When adding pre-orders and try-before-you-buy to Shopify's Purchase Options APIs, code that equated "has a selling plan" with "is a subscription" forced repeated refactors. The fix was to model behavior rather than state: wrap selling plans in an object that answers questions like "has recurring deliveries?" or "is billing deferred?" (upfront/deferred/recurring × billing/delivery), so payments, delivery and inventory code ask only what they need and conditionals disappear. To shield the data team from schema churn, a separate reporting table records these traits and labels per order, acting as a translation layer between platform code and merchant-facing domain concepts.
Related posts
- Redefining impact as a data scientist
Figma mediumAdept
On Figma's billing infrastructure, data science work centered on making a complex, stateful system legible and correct rather than on experiments. The team built the Invoice Seat Report, which reconstructs each seat charge from product events, contract metadata and billing rules into a plain-language explanation. They also built consistency checkers, SQL-based invariant tests that run on a cadence across product logs, billing state, payments and CRM data and route structured alerts with offending rows to engineers. The checkers caught race conditions and logging gaps during the billing model refresh, contributing to an uneventful rollout, and were later adopted by security, identity and growth teams. The broader argument is that the standard DS process (domain understanding, data cleaning, EDA) still applies, but deliverables can be durable data applications instead of models or reports.
- Building a Business System Integration and Automation Platform at Shopify
Shopify Engineering mediumAdeptShopify replaced Mulesoft with an in-house Ruby on Rails platform for integrating internal business systems such as Salesforce, Airtable and Netsuite, because the proprietary JVM/XML tool sat outside Shopify's stack and couldn't easily reach internal services like Kafka. The platform is built around five priorities: minimal, transparent, flexible, secure and reusable. It implements them as a modular monolith of Rails Engines, single-method Actions for business logic, raw hashes instead of typed structs for data transformations, no business-data storage, and WebMock request-level tests. After a year it ran 18 integrations, had absorbed all the former Mulesoft apps, and was being used by other teams.
- Shopify-Made Patterns in Our Rails Apps
Shopify Engineering easyNoviceShopify's Rails monolith relies on a set of in-house patterns: the dev CLI for consistent environment setup, a podded architecture that shards the full infrastructure stack by shop, and domain-driven components that share a single database with no database-level foreign keys. Migrations are periodically squashed into structure.sql, and quality is kept up as the org grows through a git-based translation platform, an open-source maintenance tasks engine built on Active Job, and Monorail, which enforces versioned Kafka event schemas with PII annotations. It is pitched as an onboarding overview for new Shopify developers rather than a detailed implementation guide.
- ShopifyQL Notebooks: Simplifying Querying with Commerce Data Models
Shopify Engineering mediumAdeptShopify built commerce data models behind ShopifyQL Notebooks so merchants can query metrics like sales and view-to-purchase conversion without SQL or joining across departmental datasets. Good models are purpose-driven, explorable (right granularity, useful dimensions, fully additive metrics rather than semi- or non-additive ones) and extensible. The process runs from business questions to mock data and template queries, then to sourcing upstream tables, checking quality and consistency, and deriving freshness from upstream SLOs. Build time improved by switching from full-drop to incremental pipelines, at some cost in maintainability, and query speed improved with daily per-product roll-up tables for high-cardinality GROUP BYs.
- Double Entry Transition Tables: How We Track State Changes At Shopify
Shopify Engineering mediumAdeptDouble entry transition tables record each state change as two rows, a -1 row for the previous state and a +1 row for the new state, so counting entities in any state reduces to summing a net_change column. Shopify built a PySpark pipeline that merges per-attribute transition tables (Balance account status and Shopify account status) on a partition key and a sort key, forward-fills missing values, and uses a row-number index to break timestamp ties. The result answers how many merchants actively use Shopify Balance over time. New attributes can be added without rewriting downstream SQL or PySpark, at the cost of significant up-front build effort.