r/DomainDrivenDesign • • May 25 '26

How we prevented invalid Quran verses from ever existing in our system

0 Upvotes

So we're building a Quran app and we ran into a classic DDD invariant enforcement problem. Thought I'd share because it's a clean real-world example.

The problem

The Quran has a strict structure. Al-Fatiha has exactly 7 verses. Al-Baqarah has exactly 286. Every surah has a fixed, known, immutable verse count.

Our system had this:

java

public record AyahRankInSurah(int value) {
    public AyahRankInSurah {
        if (value < 1)
            throw new IllegalArgumentException("rank must be >= 1");
    }
}

Looks fine right? But nothing stopped this from happening anywhere in the codebase:

java

new Ayah(surahId_alFatiha, new AyahRankInSurah(300), ...)

Verse 300 of Al-Fatiha. Doesn't exist. Never existed. Never will. But our system would happily create it.

Why it's tricky

The >= 1 check is easy — the value object knows that itself. But rank <= maxForThisSurah requires external knowledge. The Ayah doesn't know how many verses its surah has. That data lives in a JSON file loaded by a provider.

So we had:

  1. The data => done

  2. The rule => done

  3. The enforcement => :((

What we tried first

Put the check in the use case:

java

// application layer
int max = metadataProvider.getMaxAyahForSurah(surahId);
if (rank > max) throw new InvalidAyahRankException(...);

ayahRepository.save(new Ayah(...)); // still directly constructable

The problem? Anyone can bypass the use case and construct an Ayah directly. The invariant lives one layer above the object it protects. That's not an invariant, that's just a hope.

edit :
im looking for the solution .
im not junior yet so every suggestion would be appreciated <33


r/DomainDrivenDesign • • Jun 16 '26

Building Adaptive Solution Engineering Model

Thumbnail
linkedin.com
0 Upvotes

Most engineering transformations focus on only one part of the system.
Some focus on teams.
Others focus on architecture.
Others focus on strategy.
The problem is that none of these elements operate in isolation.
Strategy without architecture becomes ambition without execution.

Architecture without strategy becomes technical elegance without direction.
Engineering without architecture becomes local optimization without coherence.

Over time, I've come to view successful engineering organizations as operating across three interconnected layers:

🔹 Strategic Leadership
Provides purpose, understands the landscape, establishes doctrine, and adapts to changing conditions.

🔹 Solution Architecture
Translates strategic intent into technical structures through Domain-Driven Design, Enterprise Integration Patterns, and Cloud Native Architecture Styles.

🔹 Engineering Delivery
Organizes execution through Stream-Aligned Teams, Enabling Teams, Complicated Subsystem Teams, and Platform Teams.

Together, these form what I call the Adaptive Engineering Operating Model (AEOM).

The goal is not to create a rigid hierarchy but to establish a continuous flow from strategic intent to architectural decisions to engineering execution, while maintaining the ability to adapt as the landscape evolves.

Many organizations invest heavily in improving one of these layers.
The real challenge is creating alignment between all three.

I'm curious:
Which layer creates the most friction in your organization today: Strategic Leadership, Solution Architecture, or Engineering Delivery?


r/DomainDrivenDesign • • Apr 09 '26

Most DDD Advice Starts in the Wrong Place

Thumbnail reddit.com
0 Upvotes

r/DomainDrivenDesign • • Mar 16 '24

Use of MS CoPilot versus hiring DDD architect

0 Upvotes

Instead of hiring DDD architect, can I use Microsoft CoPilot and train the model? Over the time it will beat any architect...and that time could be a year or few based on the complexity of the model.

Thoughts?


r/DomainDrivenDesign • • Jan 27 '23

Are you willing to learn Domain-Driven Design in Python?

1 Upvotes
56 votes, Feb 03 '23
28 Yes
28 No

r/DomainDrivenDesign • • Aug 05 '26

I built a DDD modeling tool that refuses to let you draw invalid relationships — not sure yet if that’s the right call

6 Upvotes

I’ve spent years watching domain models rot the moment they leave the whiteboard. The photo of the event storming goes in Confluence, the code drifts, and six months later nobody trusts the diagram enough to open it. So I built the thing I kept wishing existed: DDD Studio, a browser tool where the canvas is a projection of an actual domain model rather than a drawing surface.

The core decision, and the one I’m least sure about: you compose semantic artifacts — bounded contexts, aggregates, commands, events, read models, policies — and a constraint engine rejects relationships the metamodel doesn’t allow. You cannot draw a command that publishes nothing, or hang an aggregate somewhere it can’t live. Every operation goes through structural, cardinality and scope-consistency rules, so the model is closer to something that compiles than to something you drew.

The obvious objection is that whiteboards are useful because they let you write nonsense while you’re still figuring it out, and a tool that says no during discovery is a tool you stop using. My current answer is that this isn’t a discovery tool — it’s for the stage after, where you’re trying to hold a model steady across a team and a codebase. But I’d genuinely like to hear from people who think that split is wrong, or who’ve tried strict modeling tools and bounced off them.
Some specifics, so this isn’t vague:

• Three views on one model: flows of command/read-model slices in swimlanes, a static structural view, and Given/When/Then scenarios per aggregate and read model, where the editor only offers what the model permits and derives input fields from the artifact schemas.

• The underlying language is ESDM (github.com/thenativeweb/esdm), an event-sourced domain modeling format from the native web. Import/export is plain .esdm.yaml, so models live in Git next to the code, get reviewed in PRs and pass esdm lint. No proprietary file format to be trapped in.

• There’s an MCP server on the backend, so a coding agent can read and edit the same workspaces you can, with the same account and the same validation. When it proposes something invalid it gets the exact violations back and corrects itself rather than inventing a plausible aggregate

What it isn’t: no real-time collaborative editing, no share-by-URL, no offline mode, and only a subset of ESDM’s artifact kinds so far. Strategic context mapping — the OHS/ACL/Conformist relationship layer — isn’t in there at all yet; today the only thing crossing a bounded context is events and commands.

app.ddd-studio.dev if you want to poke at it; it can seed an example domain so you can look around without modeling anything first.

The question I actually care about: if you’ve tried to keep a domain model alive alongside a real codebase, what made it fail? I’m fairly convinced the problem is that models can’t be wrong in a way anyone notices, but I’d rather be argued out of that than build six more months on it.


r/DomainDrivenDesign • • Jun 01 '25

Aligning URLs, Classes, and file names with Business Logic - Is this what DDD encourages?

0 Upvotes

Hi everyone, I’ve just recently started reading about DDD, and been trying to relate with my web app projects. I wanna ask your opinion if I’m thinking in the right direction.

I’m developing web apps using Django, and the process typically goes like this in sequence:

  1. URL

  2. View class / function

  3. Form class

  4. Template filename

  5. Page title

Am I correct to think that a DDD-first approach would prefer (obviously never a rule cast in stone without exception), at least as a first step to think about it, to align all these 5 things with the business logic, attempting to apply the “ubiquitous language” it proposes?

Thus for a simple example, if the business logic understands “My Profile”, the ubiquitous language would penetrate throughout:

  1. URL: /my-profile

  2. View class: MyProfileView

  3. Form class: MyProfileForm

  4. Template filename: my_profile.html

  5. Page title: My Profile

Am I on the right track?


r/DomainDrivenDesign • • Apr 09 '23

I don't understand the use of both Entities and Value Objects for one-to-one relationships in Vaughn Vernon's repository, can someone explain?

0 Upvotes

I am reviewing Vaughn Vernon's repository that has examples of DDD, and I do not understand how in the Discussion entity, he uses the entity for some relationships and Value Objects for others. What is the proper property for one-to-one relationships? I know that I should not think about storage when modeling the domain, but I am confused after looking at the repository.

Here is the direct link:https://github.com/VaughnVernon/IDDD_Samples/blob/master/iddd_collaboration/src/main/java/com/saasovation/collaboration/domain/model/forum/Discussion.java

He uses the following properties in the Discussion entity:

  private Author author; // entity
  private ForumId forumId; // value object 
  private Tenant tenant; // entity

r/DomainDrivenDesign • • Sep 17 '23

Discovering a Game-Changing Tool for Domain-Driven Design Enthusiasts 🌐

0 Upvotes

Hello fellow domain-driven design enthusiasts!

If you're like me and are deeply passionate about crafting robust and well-structured domain models, you understand the challenges of ensuring clarity and precision in your work. That's where Clariteia comes in. Powered by GenAI, this platform has been a game-changer for my domain-driven design projects.

It simplifies the process, provides a visual representation of complex domains, and enhances collaboration among cross-functional teams. I've found it particularly valuable for ensuring that the software architecture aligns perfectly with the domain model.

If you're looking to take your domain-driven design efforts to the next level, I encourage you to explore Clariteia. It's been a valuable addition to my toolkit, and I believe it could be a valuable asset for this community as well. https://clariteia.com/landing


r/DomainDrivenDesign • • Aug 23 '23

I created a guestbook for all your domains.

0 Upvotes

Recently I felt, that there are thousands of ideas and projects floating around on the internet, and as a result thousands of cool domains, it'd be awesome if we could keep track of some of those or I don't know, provide some momentary spotlight. Need the community's feedback on this

https://www.domaindrivendevelopment.xyz/


r/DomainDrivenDesign • • Sep 08 '26

Production-grade Go microservices marketplace following DDD

3 Upvotes

I have been building a Go-based microservices marketplace using Domain-Driven Design (DDD) and Clean Architecture. The project is still actively evolving, and I would be interested in getting feedback from people who have experience running microservices in production.

A few of the architectural decisions so far:

Domain-Driven Design & Clean Architecture: The codebase is organized into explicit layers (domain, application, infrastructure, and interfaces). The goal is to keep business logic isolated from framework and infrastructure concerns, such as Gin or a specific database implementation.

Database per Service: Each microservice owns its own data store (PostgreSQL, Elasticsearch, or Redis), with no shared databases between services. This keeps service boundaries explicit and reduces coupling between services.

Transactional Outbox Pattern: Rather than publishing events directly to RabbitMQ as part of an HTTP request, domain/integration events are persisted in a PostgreSQL outbox table within the same transaction as the business operation. Background workers then relay those events to RabbitMQ, helping avoid inconsistencies when message publishing fails.

Asynchronous Event-Driven Communication: RabbitMQ is used for asynchronous communication between services. For example, the notification-service runs purely as a background worker with no public HTTP endpoints and reacts to messages from its queues.

API Gateway & Network Isolation: Traefik v3 acts as the entry point for external traffic, while individual services remain on a private Docker network. JWT authentication is used as part of the API security layer.

I am currently following the project roadmap and would especially appreciate feedback on observability, orchestration, CI/CD, and cloud deployment. What would you change or add if you were taking this from a local Docker-based setup toward a production cloud environment?

If you find the project useful or interesting, feel free to check it out or give it a ⭐ on GitHub:

https://github.com/tarique-iqbal/pizza-marketplace


r/DomainDrivenDesign • • Mar 30 '22

Domain-Driven Design vs. “Functional Core, Imperative Shell”

1 Upvotes

r/DomainDrivenDesign • • May 11 '23

Great article on Uber's adoption of DDD and its overall benefits and emerging trends.

Thumbnail
applandeo.com
0 Upvotes

r/DomainDrivenDesign • • May 16 '25

AI Prompts within DDD Domain

7 Upvotes

Has anyone experience with creating anything meaningful or useful with LLMs around your DDD work? maybe models, service descriptions, storming, story telling?


r/DomainDrivenDesign • • Aug 27 '25

What are the main cons of DDD bounded context?

8 Upvotes

Context Is King

One of DDD's most profound insights:

The same object can be an Entity in one context and a Value Object in another.

A ship in maintenance (history matters) vs. a ship in logistics (only specs matter).

Identity isn't universal truth—it's practical choice based on what questions you need to answer.

Curious about your take on this principle, that I used successfully and unsuccessfully.

What is the trade-off here?


r/DomainDrivenDesign • • Oct 17 '25

JESUS CHRIST DDD is harder than I thought

44 Upvotes

OK. Just my rant. I thought DDD is cool and easy once you are the domain expert...

AHHHH.

I LOVE IT it though! I am forced to follow good architecture.


r/DomainDrivenDesign • • Jan 07 '26

5 tips to improve your domain models

Thumbnail
aardling.eu
5 Upvotes

Full disclosure, Stijn is a colleague of mine!


r/DomainDrivenDesign • • Aug 29 '24

Can you do DDD in a Monolith? How would you separate Bounded Contexts in a SprinBoot Monolith?

2 Upvotes

Is there any particular guideline to structure your SpringBoot project to keep multiple Bounded Contexts in the same Monolith?


r/DomainDrivenDesign • • Aug 25 '25

Bounded Context Wisdom

10 Upvotes

Here's a powerful DDD insight:

The same "ship" can be:

• An Entity in Maintenance Context (history matters)

• A Value Object in Fleet Planning (only specs matter)

• A Risk Assessment in Insurance Context (condition over identity)

Identity isn't universal truth—it's pragmatic choice determined by context.

The question isn't "What is this thing?" but "What is this thing FOR?"

BoundedContext #DDD #SoftwareDesign

https://open.substack.com/pub/antoninorau/p/the-ship-of-theseus-and-the-soul?r=pfd15&utm_campaign=post&utm_medium=web&showWelcomeOnShare=false


r/DomainDrivenDesign • • Nov 12 '24

If Discord, Reddit, Twitter, and Uber Don’t Use DDD, How Are Their Designs So Solid? Do I Really Need to Learn DDD?

10 Upvotes

Hi everyone, I’m a .NET developer with 3.5 years of experience, and I’m currently reading Eric Evans’ DDD book. I’ve been diving into Domain-Driven Design (DDD) and its principles, but I’ve noticed that massive, successful companies like Discord, Reddit, Twitter, and Uber don’t seem to be using DDD in their architectures.

Given how well-designed and scalable their systems are, I’m curious about how they’ve managed to achieve this without adopting DDD. Is DDD really necessary for creating robust, scalable systems, or is it overhyped for certain use cases?

I’d love to hear from other experienced developers on how you approach architecture and design, especially in fast-paced, high-scale environments. Do you think DDD is something worth prioritizing in learning, or are there alternative approaches that can be just as effective?

Thanks in advance for your insights!


r/DomainDrivenDesign • • May 13 '25

Web session in a repository?

0 Upvotes

I’m getting into DDD and I was wondering if a web session should be considered persistence just like any other kind.

If I have a GuestShoppingBasket (not belonging to a Customer entity/aggregate yet) then should the controller get the session ID and pass it to the UseCase? The UseCase could then ask the BasketRepository for the basket. The repository would use the session ID, get the raw basket data and hydrate it into an object.

It seems the concept of a basket belongs in the domain (and allowed in the UseCase). Session storage is certainly infrastructure. I don’t want to leak the notion of a session ID from the controller into the UseCase though.


r/DomainDrivenDesign • • Jan 18 '21

Event Driven Podcast is streaming live now, with Adam Dymitruk and host Sebastian Bortz!

0 Upvotes

It's the second podcast, usually the Event Driven Meetup but now streaming in podcast formhttps://www.youtube.com/watch?v=lns83LtLcfY


r/DomainDrivenDesign • • Aug 16 '24

functional core, imperative shell with data storing

0 Upvotes

Here's article about how to have Functional Programming and immutable data combined with efficient storing:

https://programmingfunl.wordpress.com/2024/08/16/fp-and-data-store/


r/DomainDrivenDesign • • Jun 11 '23

Balancing Attention Economy, AI, Sustainability, and Global Connectivity

0 Upvotes

Together, we can explore how a holistic perspective and systems thinking can transform the way we allocate capital and resources. In our pursuit of sustainable goals, it's crucial to question the status quo and identify inefficient uses of capital. By redirecting resources more effectively, we can align our investments with long-term sustainability objectives.

As we delve deeper, we'll explore how value goes beyond financial returns, encompassing social, environmental, and cultural dimensions. By adopting this broader perspective, we can make decisions that create sustainable and resilient systems while considering the well-being of communities and the planet. It's an exciting paradigm shift that requires us to think beyond short-term gains and embrace a value-driven approach that prioritizes privacy, autonomy, and inclusivity.

Now, let's consider the context of future space-enabled internet architecture and its potential to bridge the digital divide and empower individuals and communities worldwide. By extending connectivity to underserved regions, we can foster economic and social development, creating a more equitable and interconnected world. But, of course, this transformative shift cannot be accomplished in isolation. I invite you to subscribe and become part of a global community actively working towards these goals.

As we explore the convergence of the attention economy and AI advancements, we must also be aware of the risks and challenges they present. But this is not a solitary endeavour - I encourage you to engage in the conversation, share your thoughts, and be part of the change we want to see in the world. Your engagement and participation in ongoing dialogue and education will empower us all to make informed decisions, advocate for responsible practices, and safeguard our privacy in this increasingly connected world.

https://open.substack.com/pub/phantomobserver/p/navigating-the-internet-age-balancing?r=gb8pd&utm_campaign=post&utm_medium=web

What domains do you see automation of systems in space enabling?

1 votes, Jun 16 '23
0 Earth Observation
1 Enhanced collaboration
0 Better alignment with holistic requirements