DEV Community

Software Architecture ideas every developer should know

The payment went through but that's not the end, the account needs updating, a receipt needs to be sent, the user needs a notification and analytics need to record it.
One simple payment just triggered an entire chain of events. So how do we design a system where all these parts work together without creating a mess. Our application has different services running independently payment, notifications, analytics, we could make the payment service call each one directly.
Now everything starts depending on everything else, a better approach is event driven architecture. Instead of calling everyone the payment service can just announce, payment completed the other services listen for that event then react. The payment service doesn't need to know who is listening bit now what should actually be separated should payments be its own service, should refunds belong to payments, where does fraud detection fit, where do we draw the boundaries, that's where domain driven design comes in.
A Domain Driven Design software around the business and it rules instead of starting with database tables, we start with what the business actually does. For example payment, accounts, refunds, Fraud detection. notification, all these represent different business responsibilities and define where the boundaries should be.
Now we know what belongs where and how these parts communicate but inside each part we can still create a mess. Controllers talking directly to databases, business rules mixed with frameworks, payment providers spread throughout the code so how do we structure this code itself. That's why clean architecture come's in.
Clean Architecture structures the software such that the core business logic is separated from external technologies. The domain shouldn't care whether you're using Postgresql, Mongodb, Paysack or something else because technology changes every sing time but the core business logic should not have to change with it and now we connect the three ideas;
first, Domain Driven Design helps you understand the business and defines the boundaries.
second, Event Drive Architecture helps those parts communicate without tight coupling
Third, Clean Architecture structures the code inside those boundaries while protecting the business logic
But you don't need all three for every single application . A simple crud app probably doesn't need this architecture, this ideas become useful when your system and the complexity actually justify them. So we're not just adding more patterns make sure you are actually solving a problem.

Top comments (0)