You may want to consider using a battery charger IC with the ability to seamlessly switch between DC Input and Battery Input. Its normally called Dynamic Power Management (DPM) and Dynamic Power-Path Management (DPPM). [![MPS Power Path Managment Example][1]][1] [MPS have a nice primer page explaining some of the concepts][2] I'd highly recommend designing a circuit or using a module that implements the battery management and power path functionality as it'll make your life much easier as battery charging can be a pain to implement and you'll save yourself a lot of space with a more integrated solution which is something I think you'd find valuable being space constrained in your application. [1]: https://i.sstatic.net/s797f.png [2]: https://www.monolithicpower.com/en/power-path-management-in-charger-ics