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

Value Object - DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

Introduction to DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

Safe data migrations in Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Backend
Tutorial

I love dev, and so do we!

14
.
11
.
2023
Michał Łęcicki
Software
Conferences

Updated guide to recruitment process at Visuality

14
.
11
.
2023
Michał Łęcicki
Visuality
HR

Visuality Academy for wannabe Junior Engineers

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

How to approach funding as an MVP

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

Visuality 13th birthday

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

How To Receive Emails With a Rails App in 2021

14
.
11
.
2023
Michał Łęcicki
Ruby on Rails
Tutorial

Project Quality in IT - How to Make Sure You Will Get What You Want?

14
.
11
.
2023
Wiktor De Witte
Ruby on Rails
Project Management
Business

5 Trends in HR Tech For 2021

14
.
11
.
2023
Maciej Zdunek
Business
Project Management

Is Go Language the Right Choice for Your Next Project?

14
.
11
.
2023
Maciej Zdunek
Backend
Business

SXSW Tradeshow 2020: Get Your FREE Tickets and Meet Us

14
.
11
.
2023
Michał Krochecki
Ruby on Rails
Conferences
Frontend
Backend
Business

How to build effective website: simplicity & McDonald's

14
.
11
.
2023
Lukasz Jackiewicz
Ruby on Rails
Frontend
Design

Thermal Printer Protocols for Image and Text

14
.
11
.
2023
Burak Aybar
Backend
Tutorial
Software

WebUSB - Print Image and Text in Thermal Printers

14
.
11
.
2023
Burak Aybar
Backend
Tutorial
Software

What happened in Visuality in 2019

14
.
11
.
2023
Maciej Zdunek
Visuality
HR

Three strategies that work in board games and in real life

14
.
11
.
2023
Michał Łęcicki
Ruby on Rails