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

WebUSB - Bridge between USB devices and web browsers

14
.
11
.
2023
Burak Aybar
Ruby on Rails
Frontend
Backend
Tutorial

Visuality comes to town - this time it's Poznań

14
.
11
.
2023
Michał Piórkowski
Visuality
HR

CSS Modules in Rails

14
.
11
.
2023
Adam Król
Ruby on Rails
Tutorial
Backend
Frontend

How to choose a software house.

14
.
11
.
2023
Michał Piórkowski
Ruby on Rails
Business
Visuality

JSON API versus the NIH syndrome

14
.
11
.
2023
Nadia Miętkiewicz
Backend
Frontend
Tutorial

From Idea to Concept

02
.
10
.
2024
Michał Krochecki
Ruby on Rails
Business
Startups

Styling React Components

14
.
11
.
2023
Umit Naimian
Ruby on Rails
Frontend
Tutorial

How good design can help your business grow

14
.
11
.
2023
Lukasz Jackiewicz
Design
Business
Marketing

TODO not. Do, or do not.

29
.
11
.
2023
Stanisław Zawadzki
Ruby on Rails
Software

CS Lessons #003: Density map in three ways

14
.
11
.
2023
Michał Młoźniak
Ruby
Backend
Tutorial
Software

Clean code for the win

14
.
11
.
2023
Michał Piórkowski
Ruby on Rails
Backend
Frontend
Business

Crowd-operated Christmas Lights

14
.
11
.
2023
Nadia Miętkiewicz
Ruby on Rails
Backend

How to startup and be mature about it

14
.
11
.
2023
Rafał Maliszewski
Ruby on Rails
Startups
Business

A journey of a thousand miles begins with workshops

14
.
11
.
2023
Michał Piórkowski
Software
HR

CS Lessons #002: Data structures

14
.
11
.
2023
Michał Młoźniak
Ruby
Software

Summary of Phoenix workshop at Visuality

14
.
11
.
2023
Karol Słuszniak
Ruby on Rails
Visuality
Backend

CS Lessons #000: Introduction and motivation

14
.
11
.
2023
Michał Młoźniak
Ruby
Software

CS Lessons #001: Working with binary files

14
.
11
.
2023
Michał Młoźniak
Ruby
Software

Working with 40-minute intervals

14
.
11
.
2023
Sakir Temel
Software
HR

THE MATURE TECH STARTUP DILEMMA: WHAT'S NEXT

14
.
11
.
2023
Susanna Romantsova
Startups

Win MVP workshop!

14
.
11
.
2023
Susanna Romantsova
Startups

FINTECH WEEK IN OSLO: WHATs & WHYs

14
.
11
.
2023
Susanna Romantsova
Conferences

MY FIRST MONTH AT VISUALITY

14
.
11
.
2023
Susanna Romantsova
Visuality
HR

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

14
.
11
.
2023
Rafał Maliszewski
Ruby on Rails

Berlin StartupCamp 2016 summary

14
.
11
.
2023
Michał Piórkowski
Conferences
Startups