Senior Track Roadmap

Architecture: repository pattern

This course examines the repository pattern in a Rails application by measuring what the codebase already has. It covers the difference between a shape boundary and a persistence boundary, the four promises the pattern makes, and how the Active Record and Data Mapper patterns differ. It looks at query objects and what they return, service objects on the write side, and twenty-two ActiveRecord calls found in controllers. It closes with four situations where a repository pays for itself and a short list of concrete changes.

What you'll learn

  • ✓The difference between a shape boundary and a persistence boundary
  • ✓What the repository pattern promises and how each promise fares over ActiveRecord
  • ✓Why never to return a relation, and when to return a Data object or plain data
  • ✓What service objects own on the write side, and the aggregate problem
  • ✓A rule for which ActiveRecord calls can stay in controllers
  • ✓Four situations where a repository is worth its cost
Free preview · Lesson 1 4 min read

The boundary that already exists

The repository pattern is a way to keep data access out of everything else. Before judging it, measure how much of that this application already has. The numbers below were taken on 2026-09-28.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...