Lots of people use enclosures, and it’s always a good idea for anything not actually inside a box in the wall. They’ve been discussed in a number of different project reports. These are often called “project boxes” and any electrical supply house will have them. Or you can get one on Amazon or at Home Depot.
Here’s an example of a thread with a project similar to yours I think:
https://community.smartthings.com/t/starting-from-zero-smartthings-and-fibaro-rgbw/84775/25
I like Hammond boxes, but there are lots of different brands
https://www.amazon.com/Hammond-1591ESBK-ABS-Project-Black/dp/B0002BSRIO
And here’s one for a gate opener project:
If nothing else, they help keep dust from settling on the connections, and mice from chewing (or peeing) on them.