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.
To fully appreciate the book you need to know Python and be familiar with TDD, in particular with unit testing and mocks. Please refer to the series TDD in Python with pytest published on my blog if you need to refresh your knowledge about these topics.
After the two introductory parts that you are reading, 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.
Conditions of Use
This book is licensed under a Creative Commons License (CC BY-NC-SA). You can download the ebook Clean Architectures in Python for free.
- Title
- Clean Architectures in Python
- Subtitle
- A practical approach to better software design
- Publisher
- Leanpub
- Author(s)
- Leonardo Giordani
- Published
- 2023-05-10
- Edition
- 1
- Format
- eBook (pdf, epub, mobi)
- Pages
- 153
- Language
- English
- License
- CC BY-NC-SA
- Book Homepage
- Free eBook, Errata, Code, Solutions, etc.
Introduction What is a software architecture? Why is it called “clean”? Why “architectures”? Why Python? Acknowledgments About the book Prerequisites and structure of the book Typographic conventions Why this book comes for free Submitting issues or patches About the author Changes in the second edition Chapter 01 A day in the life of a clean system The data flow Advantages of a layered architecture Chapter 02 Components of a clean architecture Chapter 03 A basic example Chapter 04 Add a web application Flask setup Test and create an HTTP endpoint WSGI Chapter 05 Error management Request and responses Basic structure Requests and responses in a use case Request validation Responses and failures Error management in a use case Integrating external systems Chapter 06 Integration with a real external system postgres Decoupling with interfaces A repository based on PostgreSQL Label integration tests Create SQLAlchemy classes Orchestration management Database fixtures Integration tests Chapter 07 Integration with a real external system mongodb Fixtures Docker Compose configuration Application configuration Integration tests The MongoDB repository Chapter 08 Run a production ready system Build a web stack Connect to a production-ready database Changelog Colophon Notes