A

clean architecture in 3 minutes

Clean Architecture Notes

Chapter 1: Application Are Your Models

  • Clean architecture focuses on logically breaking an application into distinct pieces.

  • Models serve as the only elements that cross the entire application, representing:

    • Database entities or persistence.

    • Incoming requests and outgoing responses.

  • Basic flow of an application:

    1. Request comes in via API, socket listener, or user interface.

    2. Application layer handles business logic and processes the request.

    3. Response sent back out.

  • Application layer often categorizes logic into features or use cases.

Chapter 2: A Larger Action

  • User actions correlate with specific business logic (e.g., register, sign in, add to cart).

  • Business logic resides entirely within the application layer.

  • Larger actions may call smaller actions during their processing.

  • Application is unaware of the persistence layer and shared services.

  • Defined Interfaces:

    • Application defines interfaces (e.g., an email class must have a sendMessage method).

    • Services plugged in must align with these interfaces to ensure flexibility.

  • Benefits of clean architecture:

    • Prevents stray logic in repositories or web APIs.

    • Allows easy swapping of databases or services without modifying business logic.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.

Chapter 3: It Doesn't Need

  • Business logic should not reside in data retrieval or storage layers.

  • Responsibilities of data layer:

    • Getting, retrieving, and storing data.

  • Business application processes requests in a streamlined manner, sending back responses without extraneous concerns.