The core of the electronics is a simple op-amp voltage follower:
But I need to supply up to 1A, which (most) op-amps can't do. So, the next step is to buffer the voltage with two bipolar transistors. This is a classic "push-pull" class-B amplifier arrangement:
(*also up to limits of power supply, wiring, etc, etc...)
If the "battery" is being discharged, the op-amp will raise its output voltage, causing the NPN to turn on and feed current from the supply.
If the "battery" is being charged, the op-amp will lower its output voltage, causing the PNP to turn on and pull current from the charger.
Inputs and Outputs
In general I want each battery "variable" (voltage, temperature and "is it connected or not") to be controllable from both on the board and from an external source (like an Arduino or whatever - the possibilities are endless).
So, the VIN control voltage comes from an onboard potentiometer or from an external connection: