Sorting out the power supply system was one of the most annoying parts of this project. I needed a power controller that would seamlessly handle battery charging, battery protection, battery power supply and external power supply.
Other similar builds have used the Adafruit Powerboost (
https://learn.adafruit.com/adafruit-powerboost-1000c-load-share-usb-charge-boost/overview), and it's pretty much exactly what I needed except it's only rated for 1A power output, but the new Raspberry Pi 3 is a hungry beast and recommends a 2A supply.
Turns out that USB power banks are also quite ideal since they contain all that charging and protection circuitry, and some can output 2A. That mess above is one of those.
However there was an annoying issue with it since it's not designed to have both its output and input connected to the same thing (the Raspberry Pi in this case). The input and output of the power supply seemed to be isolated circuits (not common ground) and when the grounds were connected it caused the charger to enter some kind of semi-on state.
The solution was to use a mini relay to connect the charger input to the RPI when there is external power supplied.