DEV Community

Cover image for Clean Architectures in Python
Leonardo Giordani
Leonardo Giordani

Posted on

Clean Architectures in Python

The clean architecture is the opposite of spaghetti code, where everything is interlaced and there are no single elements that can be easily detached from the rest and replaced without the whole system collapsing. The main point of the clean architecture is to make clear "what is where and why", and this should be your first concern while you design and implement a software system, whatever architecture or development methodology you want to follow.

In 2018 I wrote the free book "Clean Architectures in Python" and published it on Leanpub because I wanted to help fellow developers to understand some concepts behind software architecture design, and in particular behind the Clean Architecture popularised by Robert Martin in recent years. In 2020 I published the second edition with revised code and an additional chapter. The book has been a great success and has been downloaded by more that 16000 readers so far!

After two introductory parts, chapter 1 goes through a 10,000 feet overview of a system designed with a clean architecture, while chapter 2 briefly discusses the components and the ideas behind this software architecture. Chapter 3 runs through a concrete example of clean architecture and chapter 4 expands the example adding a web application on top of it. Chapter 5 discusses error management and improvements to the Python code developed in the previous chapters. Chapters 6 and 7 show how to plug different database systems to the web service created previously, and chapter 8 wraps up the example showing how to run the application with a production-ready configuration.

You can read the book online at or download the PDF at The PDF can be downloaded for free, but any contribution is welcome and will help me to create more quality content. Please also share this with friends or other people you think might be interested in the topic.

I hope you enjoy the book!

Top comments (0)