---
title: "Shopify-Made Patterns in Our Rails Apps"
description: "Shopify'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."
url: "https://swe.quest/articles/shopify-made-patterns-in-our-rails-apps-92bda4387ca54f09"
canonical: "https://shopify.engineering/shopify-made-patterns-in-our-rails-apps"
source: "Shopify Engineering"
published: "2021-07-13"
difficulty: "easy"
kind: "Case study"
reading_minutes: 8
tags: ["ruby","developer-productivity","distributed-databases","system-design","schema-migrations"]
---

# Shopify-Made Patterns in Our Rails Apps

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2021-07-13, 8 min read, Case study. Original: [https://shopify.engineering/shopify-made-patterns-in-our-rails-apps](https://shopify.engineering/shopify-made-patterns-in-our-rails-apps)

## Summary

Shopify'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.

Written by swe.quest, not by the author.

**Difficulty:** Easy: no special background needed; explains what something is and why it matters

## Topics

- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [Developer productivity](https://swe.quest/tags/developer-productivity.md) (Engineering practices)
- [Distributed databases](https://swe.quest/tags/distributed-databases.md) (Data & databases)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)

## Prerequisites

- Ruby on Rails basics ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))
- database sharding ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))

## Keywords

Ruby on Rails, Shopify Core, dev, Pods, Monorail, Kafka, Active Job, structure.sql

## Related posts

- [Building a Business System Integration and Automation Platform at Shopify](https://swe.quest/articles/building-a-business-system-integration-and-automation-platform-at-shopify-ca92d2227e71ff9f.md): Shopify Engineering · 2022-04-22 · Medium · 11 min read · Ruby, System design, API design, Testing
  Shopify 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.
- [Reusing Code with React Native Packages at Shopify](https://swe.quest/articles/reusing-code-with-react-native-packages-at-shopify-881b73cbad48dfac.md): Shopify Engineering · 2021-09-29 · Medium · 9 min read · React, Mobile, Build systems, Developer productivity, Version control
  Shopify consolidated shared React Native code (login, foundational blocks) across apps like Shop, Inbox and Point of Sale into a monorepo of npm packages rather than many separate repos, mainly to cut maintenance costs.
- [From Ruby to Node: Overhauling Shopify’s CLI for a Better Developer Experience](https://swe.quest/articles/from-ruby-to-node-overhauling-shopify-s-cli-for-a-better-developer-experience-c31f4bbd707f942e.md): Shopify Engineering · 2023-01-10 · Medium · 12 min read · Developer tools, TypeScript, JavaScript, Refactoring & migrations, Testing
  Shopify rewrote its CLI from Ruby to TypeScript on Node to reduce system requirements, unify the Theme, App and Hydrogen workflows, and stay easy for internal teams to contribute to.
- [Remove Circular Dependencies by Using Dependency Injection and the Repository Pattern in Ruby](https://swe.quest/articles/remove-circular-dependencies-by-using-dependency-injection-and-the-repository-605bdeddd937fd64.md): Shopify Engineering · 2021-03-19 · Medium · 8 min read · Ruby, Refactoring & migrations, Type systems, Testing
  Shopify broke a circular dependency between an internal pricing gem and its two consumers (the Shopify Core Rails monolith and the Storefront Renderer) by applying the Repository pattern with constructor-based dependency injection.
- [Horizontally scaling the Rails backend of Shop app with Vitess](https://swe.quest/articles/horizontally-scaling-the-rails-backend-of-shop-app-with-vitess-03c7b2da20f98ec3.md): Shopify Engineering · 2024-01-17 · Medium · 27 min read · MySQL, Distributed databases, Ruby, Scaling, Schema migrations
  Shop app outgrew a single MySQL database despite federating tables across databases, so the team moved its Rails backend to Vitess, sharding user-owned tables by user\_id into a "users" keyspace and keeping the rest in an unsharded "global" keyspace.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
