This is a demo project to show how we can use the 'Clean Architecture' from Uncle Bob (https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) in Python. To show how flexible and decoupled the architecture can be, we are using two different databases: one in SqlLite and the other in MySQL, both of them using a different schema. For the user interface, we are using both QT and Flask (HTML). The specificities on the databases and the user interface APIs have no impact on the core implementation of the tool, proving that we can keep the volatile details outside the core in an easy fashion.
The demo project is a fictional tool for a VFX studio. The users are artist managers and the finance department.
The business rules are that the shots need to follow a specific nomenclature. Also, it needs to show if it is over budget or not.
The use cases are that artist managers should be able to list, create, edit and delete shots.
We need to have a view for artist managers and another one for finance. Technically, we don't want to share financial information with artist managers. The color coding required by both finance and artist managers are different for the shot listing.
In terms of framework, the tool should be able to run as a standalone and a webpage. The database will be migrated soon to a new database with a new schema, so we need to support MySQL and SqlLite.
- Python 3.8.1
- PySide 2
- Flask
- MySql
cd clean-architecture\clean_architecture\frameworks\user_interface\flask $env:FLASK_APP='app.py'
flask run
Add the project folder to the python path, then run:
python clean-architecture\clean_architecture\frameworks\user_interface\qt\app.py
In the following figure, we can see that all the dependencies are towards abstraction, from the bottom (the outer circle of clean architecture) to the top (the inner circle).
We received a new feature request where we are asked to improve performances when listing information. Therefore, adding a caching approach seems to be the right solution. Thanks to the layered architecture, in this case, we only need to add two new classes in the framework layer: one for the caching server REST API and the other one is the caching gateway, as illustrated in the next figure.