I put the Shelly relay in a pre-existing junction box in the basement.
Previously, this box worked like this: There were romex cables for power/neutral, lights, and the switch itself all inside of that box. The switch, located elsewhere, interrupted power to the lights. (This isn't necessarily the most-typical arrangement, but it's how it is in the house I've got.)
Currently, the box works like this: We still have romex cables for power/neutral, lights, and the switch itself inside of that box. That part hasn't changed at all. But now the Shelly relay interrupts power to the lights.
Thus, the lights are always controlled by software.
And the light switch? That just provides an input that is acted upon by a software script.
The script (which runs internally within the Shelly relay) only does 3 things:
1. If relay is on and switch toggles, turn relay off.
2. If relay is off and switch toggles, turn relay on.
3. If relay is turned on by any mechanism, start timer, and then turn off after timer expires. (Plus other useful timer mechanics like resets on additional toggling, but you get the idea.)
---
It's easiest to think of a Shelly relay like a replacement for a light switch, but that's kind of a limiting way to think about it because that line of thought strongly implies that it should to be located where the switch is. And while it certainly can be installed that way, in practice it really doesn't have that limitation.
For my unfinished basement, there's no neutral at the light switch location so using a regular smart switch didn't pan out. (I could have added a neutral but that would have meant using more parts and getting into some drywall and paint.)
Instead, there's that neat (who am I kidding, it's a mess) junction box I that described, up on the ceiling where all of the things come together... So that's where I put the relay.
Or: There's a box behind a light fixture (well, there "should" be anyway). Often, this box will have the same functions available inside that my junction box happened to have. Power, neutral, light(s), switch input. A relay can go there.
But many houses do have neutral at the light switch location, so a relay can go there instead. Power/neutral feeds in, power for lights feeds out, with a switch (and/or relay!) in the middle. All in one accessible box on the wall. This matches the easy-to-think-of scenario. (IIRC all new homes are supposed to be this way in the US, but...)
It's (usually!) just a matter of finding the right physical location in which to install the relay.
(Note: None of this is intended to be an exhaustive list of variations. Things can and do get weird with household wiring, and regional variations of what "normal" means can vary quite tremendously.)
So everything I automate has a fallback option that exists outside of HA. My regular light fixtures, with smart bulbs? I can turn those on and off using their light switch in the event that Home Assistant is dead, like I would if they were dumb bulbs. (I seldom use them that way, but I can.)
And my basement lights have their smarts all programmed directly in the Shelly relay. It works without networking or HA or anything else. So while the basement lights are completely software-operated, they aren't dependent upon the relatively giant stack of software and complex hardware that HA brings
As long as the Shelly relay works, then the basement lights also work -- with a timer.
(That relay can fail, but it is is unlikely to fail soon. I don't worry about it any more than I do a major appliance failing: If/when it happens, I'll deal with it. It's easy to take out again.)