Choosing a backend programming design pattern - Domain Driven Design + Uber’s CleanArchitecture

We’re using a Domain Driven Design (DDD) approach and Uber’s Clean Architecture (aka Uber FX)

decision table

Proposed Solution

We’re using a Domain Driven Design (DDD) approach to think about how to structure our services & codes at a high level (ie the C1/C2 level as we’re using also using the C4 Model approach to visualize our software architecture & design).  

When it comes to the lower level of design (ie C3/C4 level), we’ve chosen Uber’s Clean Architecture (aka Uber FX) where every service is structured as: 

  • [INPUT] Handlers - handle info coming from

    • GraphQL used as the comms protocol

  • [LOGIC] Domain (aka controller) - does all the logic

    • Entities

    • Interface

    • Services (business logic)

  • [OUTPUT] Adapters - update the database

    • Database - Update database (PostgreSQL / Aurora)

      • Debezium will send every change in the database to Kafka and save so that we have a record of all the changes / immutability

    • Kafka folder - async communication with other services internal/external

Alternative Solutions

  • At high level design (C1/C2) 

    • Domain-Driven Design (DDD): is an approach to software development that emphasizes understanding and modeling the domain of the problem at hand. It focuses on building a shared understanding of the domain between technical and domain experts and using that understanding to inform the design of software. DDD was introduced by Eric Evans in his book "Domain-Driven Design: Tackling Complexity in the Heart of Software."  Domain Driven Design: What You Need To Know

  • At implementation level design (C3/C4) level

    • Hexagonal (Ports & Adapters): focuses on isolating the core domain logic from external concerns such as user interfaces, databases, or third-party services. It emphasizes the use of ports and adapters to define clear boundaries and enable flexibility and testability. It was introduced by Alistair Cockburn and popularized by developers like Steve Freeman and Nat Pryce. Hexagonal Architecture: What You Need To Know - Simple Explanation

    • Clean Architecture (aka Uber FX): is a software architecture design paradigm that emphasizes separation of concerns and dependency inversion. It aims to create systems that are maintainable, scalable, and adaptable to change over time. It was popularized by Robert C. Martin in his book "Clean Architecture: A Craftsman's Guide to Software Structure and Design." 

    • Model View Controller (MVC): MVC is generally used for dynamic applications, where things are changing and reacting over time. Your "view" is a single value returned once per request so it doesn't really fit that mold. MVC has been the dominant pattern for web apps (which was the main development focus pre-2010 when smartphones came into play) and can be leveraged for client side applications but isn’t very well suited for back-end.