Run something like Zoneminder or Shinobi (
https://shinobi.video/) on hardware that is on your local network. Use their hardware compatibility list to select a suitable camera that is known to work well.
The author of Shinobi has recommended to me the Reolink line of cameras, which appear to be just about the only wifi cameras available anywhere that do both 2.4Ghz and 5Ghz wifi. Virtually everything else I can find seems to do 2.4GHz only.
If you don’t want to run Zoneminder or Shinobi, there are other packages on other platforms, such as Bensoft SecuritySpy. See also: https://alternativeto.net/software/shinobi/