I’d recommend checking out the PiJuice hat schematics as a reference:
You can generally have two setups:
First, where it’s always powered from the battery, and the charger keeps the battery topped up:
Or second, where the battery is disconnected when power is available:
There are some great IC’s available that take care of everything, eg.
https://www.microchip.com/wwwproducts/en/en027785
Which is what Adafruit use in their chargers:
Since you’re running a Pi, which is a 3.3v device, if you don’t need 5v you’re probably best to go with the former setup since it’s simper to implement. That way you just need a LDO 3.3v regulator/buck converter (though if you want to eek the last bit of life out of your batteries you’d need a buck/boost converter for when they get really flat. You’ll probably just need to pick a chip that can supply enough current to charge the battery and power the device simultaneously.