Clean Architectures in Python
258 pages
English
PDF
4.5

Clean Architectures in Python

Clean Architectures in Python

Author:

Year:

Summary:

Introduction

Leonardo Giordani's book "Clean Architectures in Python" (2021, 258 pages) is not just another reference guide on Python syntax or libraries. It is a deep dive into the world of software design, aimed at developers who want to build truly maintainable, testable, and scalable systems. The author, known for his articles on clean architecture and Python, offers a practical approach to applying Robert Martin's (Uncle Bob) principles within the context of the Python ecosystem.

The book was published in 2021, but its ideas remain relevant today, as Python is increasingly used not only for scripts and prototypes but also for building complex enterprise applications, microservices, and high-load systems.

What is this book about?

The main theme of the book is the application of Clean Architecture and related concepts: Domain-Driven Design (DDD), Hexagonal Architecture (Ports and Adapters), and SOLID principles. Giordani does not simply retell Martin's ideas; he adapts them to Python's specifics, showing how to avoid common mistakes and how to build a layered architecture where business logic does not depend on frameworks, databases, or external APIs.

The book consists of several parts: from an introduction to basic concepts (dependencies, inversion of control, dependency injection) to building a complete example application using repositories, a service layer, and unit tests. Special attention is paid to testing — the author shows how clean architecture makes tests simple and fast.

Who is this book for?

  • Intermediate Python developers who already know how to write code but want to understand how to design application architectures that do not turn into a "big ball of mud" after six months of development.
  • Team leads and architects looking for practical examples of implementing DDD and hexagonal architecture in Python projects.
  • Developers transitioning from other languages (Java, C#) to Python who want to apply best design practices without falling into excessive abstraction.
  • Anyone who wants to write testable code and understand how to organize a project so that tests are not a burden but a tool for confidence.

What will the reader learn?

  • SOLID principles in the context of Python: how to properly define interfaces (via abstract base classes or protocols), how to avoid circular dependencies.
  • Inversion of Control and Dependency Injection: manual DI vs. frameworks (like dependency_injector), when to use which.
  • Hexagonal Architecture: how to separate business logic from adapters (databases, web frameworks, external APIs).
  • Domain-Driven Design (DDD): aggregates, entities, value objects, repositories, and domain services.
  • Testing: how to write fast unit tests for business logic without spinning up a database or HTTP server.
  • Practical example: building a simple task management application (todo list) from scratch, going through all stages — from domain modeling to implementing adapters.

Strengths of the book

1. Practical focus. Unlike many architecture books that remain at the level of abstractions, Giordani provides concrete Python code. You don't just read about principles; you see how they are implemented in a real project. Each chapter contains examples that can be run and modified.

2. Adaptation to Python. The author does not blindly transfer Java patterns to Python. He shows how to use dynamic typing, protocols (PEP 544), and other language features to simplify architecture. For example,

Recommendations