Clean Architectures in Python
Clean Architectures in Python
A practical approach to better software design
About the Book
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.
You can read the book online at The Digital Cat Books.
Bundles that include this book
Table of Contents
-
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
- 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
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Do Well. Do Good.
Authors have earned$12,027,705writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Functional Programming Made Easier
Charles ScalfaniA Functional Programming book from beginner to advanced without skipping a single step along the way.
In my 40 years of programming, I've felt that programming books always let me down, especially Functional Programming books. So, I wrote the book I wish I had 5 years ago.
Functional Programming will never be easy, but it can be easier.
node-opcua by example
Etienne RossignonGet the best out of node-opcua through a set of documented examples by the author himself that will allow you to create stunning OPCUA Servers or Clients.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
Microsoft Dynamics 365 Business Central Field Guide
Erik HougaardA companion book for implementing Microsoft Dynamics 365 Business Central. Targeted end-users, super-users and administrators, this book covers many of the challenges you're faced when implementing a cloud-based ERP system. From setting up the system and creating the first company to user customizations and integration. Updated to 2022 Wave 2 v21.
Modern IT Automation with PowerShell
The DevOps Collective, Inc. and Michael ZanattaA PowerShell Textbook written by the community for the community!
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
Effective Kotlin
Marcin MoskałaEffective Kotlin summarizes the best practices and experiences of the Kotlin community, together with a deep explanation of some lesser-known Kotlin functionalities. All of the best practices are presented as simple rules with detailed explanations.
Applied Medical Statistics for Beginners
Mohamed ElsherifThis book is written to simplify statistics to those who used to struggle with it.
This book is written in a simplified way that is suitable for absolute beginners who wish to learn medical statistics.
It is practice oriented with many tips and instructions that make the statistical analysis easier.
Top Bundles
- #1

Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2

Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #3

Practical FP in Scala + Functional event-driven architecture
2 Books
Practical FP in Scala (A hands-on approach) & Functional event-driven architecture, aka FEDA, (Powered by Scala 3), together as a bundle! The content of PFP in Scala is a requirement to understand FEDA so why not take advantage of this bundle!? - #6

9 Books-Bundle: Shut Up and Code!
9 Books
"Shut up and code." Laughter in the audience. The hacker had just plugged in his notebook and started sharing his screen to present his super-smart Python script. "Shut up and code" The letters written in a white literal coding font on black background was the hackers' home screen background mantra. At the time, I was a first-year computer... - #7

Retromat eBook Bundle for Agile Retrospectives
3 Books
If you facilitate retrospectives this bundle is for you: "Plans for Retrospectives" helps beginners learn the lay of the land with tried-and-true plans. Once you know your way around, "Run great agile retrospectives" contains all 135+ activities in Retromat for you to mix and match. - #8

Statistics - All Lee Baker's Books
10 Books
This bundle includes all of the statistics books that Lee Baker has published at LeanPub 13 Statistics Books*1 PlaceNo Hassle! All in both epub and mobi formats - perfect for all devices and screen sizes. --------------------------------------------------------- *The book listed as Getting Started With Statistics is a bundle of 4 books... - #10

Go Optimizations 101 + Go Details & Tips 101 + Go Generics 101
3 Books
This book bundle includes the following three books: * Go Optimizations 101: https://leanpub.com/go-optimizations-101 * Go Details & Tips 101: https://leanpub.com/go-details-and-tips-101 * Go Generics 101: https://leanpub.com/go-generics-101




