https://clojurians.slack.com/archives/C015AL9QYH1/p1767017939300159.
Wanna make a (very) delayed (and brief, and overdue) shout-out for a big Clojure/Polylith success-story at our company. We migrated an old PHP-based system of ours to a component in our growing Polylith repo:
The system was ultimately a light rules-engine, determining which of our ad-campaigns a user meets targeting for. The PHP implementation was one-part data-processing/coercion of the user's info (comes in one of an indeterminate number of possible forms, because every generation of our company's projects has different/ever-changing data-structures), and one-part 300-400+ LINE MYSQL QUERY WITH THE ENTIRE RULEBOOK OF ACTUAL BUSINESS LOGIC.
As expected, that brick of mysql was an absolute beast to break apart; it's for the longest time made the server it runs on scream in pain (for good chunks of the day, that query is being run several-hundred times a minute), and was also impossible to introspect (something either 'passed' or 'failed', and that's all you'd ever know).
All the 'rules' were also far from homogeneous, and actually encompassed 4 different categories of rules: 3 different categories of meta-rules dealing with date-ranges, volume-caps, and data of the campaign itself- and then the rule-category caring about actual user attributes. We were able to break all these out with a clean dispatching interface (each category has its own namespace, and each rule is just a defmethod).
The output of this system is way more fine (with individual rule-results), makes adding new rules much less scary, and has also resulted in a substantial performance improvement for our battered little server (and mysql DB)!
I thank Polylith's organization-strategy for helping me stay (mostly) sane ❤️
Out of curiosity what were the stats of the project after migration. How many bases/components/projects?
Our current count is 29 components, 5 bases/projects (two actually 'active' bases, and dev), the new component ended up using 7 others
How great that Polylith is working so well for you! Thank you for sharing this @sludwig.dev.
Yes, there is https://davidvujic.github.io/python-polylith-docs/ but not for Rust, as far as I know. I can recommend you @tlonist.sang to write a small poly tool for Rust (and maybe publish it as open source), but that you start with the bare minimum, by supporting the check command. Then you can expand with more commands if you want, but then you can at least ensure that the codebase follows the Polylith constraints. If you want to discuss any design decisions, feel free to reach out to me.
yea, by supporting I specifically meant the tooling support. So from what I understand there is not an official plan for it, but making one is encouraged. I guess this can be a good side quest @coderoundhoon
Side quest accepted 👨💻
If you start working on this, @coderoundhoon, I recommend copying some of my design choices that have worked out really well for me: • Do all IO first, like reading all the files in the workspace, into a data structure (a single hash map). • Then let all commands be side-effect free, and only operate on that data structure (or enhanced versions of it). • Make sure most commands can operate on an exported version of that data structure, so users can share it with you to make problem identification easier. It also makes testing a lot easier. Good luck!
Thanks for the solid tips @tengstrand! I'll share my progress time to time 👍
We recently added Rust to our language stack; and we like to reason about our codebase in the same manner, so we just made it look like a polylith architecture and carried on.
The tooling only supports Clojure/Script, but you can use the Polylith architecture in pretty much any language. I know there are folks using it with Python (and maybe there is a Python-based tool for that, written by the community?).