29
.
04
.
2024
25
.
11
.
2022
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

Example Application - DDD in Ruby on Rails

Paweł Strzałkowski
Chief Technology Officer

There is a ton of materials on Domain-Driven Design. There are books, lectures, videos - you can choose whatever works for you. But one question is often asked - how to put all those concepts in code.

I have seen a lot of comments, that Ruby on Rails is not suitable for the domain-driven approach. That it somehow lacks the ability to hold and make use of all its elements.

Presentation of the application

Recently, at a Ruby meetup at Visuality, I have had a great pleasure to give a talk describing an example DDD application written in Ruby on Rails. The application uses plain Rails, with no additional gems (there is a glimpse of Sidekiq - just to see how well it fits).

It contains:
- Bounded contexts,
- Layered architecture,
- Application services,
- Entities,
- Aggregates,
- Repositories,
- Factory methods,
- Domain events and domain event handlers,
- Read models,
- and much more

All of the above, without using any additional dependencies. If you are interested, please check the presentation:

Code Example

Unfortunately I cannot share the code for this application. I use it for educational purposes - for individual research and in-house workshops.

However, I've written a small example, which contains (or will contain shortly) all the pieces included in the presentation. If you'd like to play with it, please take a look at https://github.com/pstrzalk/ddd-example-in-ruby-on-rails

Honestly, it's just a piece of code written in a few hours. It's not perfect (by far) and it's not supposed to be. I wanted to give you a piece of code, which can be the base for future discussions. I would love if you could let me know on Twitter / Mastodon / Miłośnicy Ruby discord if you found it useful or if you have any comments.

Articles in this series

Do you want to know more? Register for our DDD webinar

Paweł Strzałkowski
Chief Technology Officer

Check my Twitter

Check my Linkedin

Did you like it? 

Sign up To VIsuality newsletter

READ ALSO

Summary of Phoenix workshop at Visuality

11
.
06
.
2025
Karol Słuszniak
Ruby on Rails
Visuality
Backend

CS Lessons #001: Working with binary files

11
.
06
.
2025
Michał Młoźniak
Ruby
Software

CS Lessons #000: Introduction and motivation

11
.
06
.
2025
Michał Młoźniak
Ruby
Software

Working with 40-minute intervals

11
.
06
.
2025
Sakir Temel
Software
HR

THE MATURE TECH STARTUP DILEMMA: WHAT'S NEXT

11
.
06
.
2025
Susanna Romantsova
Startups

Win MVP workshop!

11
.
06
.
2025
Susanna Romantsova
Startups

FINTECH WEEK IN OSLO: WHATs & WHYs

11
.
06
.
2025
Susanna Romantsova
Conferences

MY FIRST MONTH AT VISUALITY

11
.
06
.
2025
Susanna Romantsova
Visuality
HR

NASA 1st global hackaton in Poland? Visuality Created it!

11
.
06
.
2025
Rafał Maliszewski
Ruby on Rails

Berlin StartupCamp 2016 summary

11
.
06
.
2025
Michał Piórkowski
Conferences
Startups

Investment Days for productivity

11
.
06
.
2025
Rafał Maliszewski
Visuality
HR

Happy new year

11
.
06
.
2025
Michał Piórkowski
Visuality

Does Norway need Polish software development?

11
.
06
.
2025
Rafał Maliszewski
Ruby on Rails

Visuality is 8 years old

11
.
06
.
2025
Michał Piórkowski
Visuality
Backend

Use less javascript plugins

11
.
06
.
2025
Michał Młoźniak
Frontend

Front-Trends 2015

11
.
06
.
2025
Adam Król
Frontend

Automatic door opener controlled through slack

11
.
06
.
2025
Sakir Temel
Backend
Software
Tutorial

Wolves Summit

11
.
06
.
2025
Michał Piórkowski
Conferences
Business

Berlin Startup Camp

11
.
06
.
2025
Michał Piórkowski
Ruby on Rails
Conferences

Why you shouldn't work at Visuality

11
.
06
.
2025
Michał Piórkowski
Visuality
HR

SaaS Meetup #People

11
.
06
.
2025
Michał Piórkowski
Conferences

Startup Safary Berlin 2015

11
.
06
.
2025
Michał Piórkowski
Conferences

Optional dependencies in gems

11
.
06
.
2025
Karol Słuszniak
Ruby on Rails
Backend

Emmet makes HTML and CSS easier

11
.
06
.
2025
Michał Piórkowski
Frontend
Tutorial