There are things missing here, current limiting and a protection diode for example but it's a start. Adjust the levels of the 3 batteries on the left. If any go over 4.2v a mosfet opens, if the total voltage goes too high the relay opens and charging stops. My long term goal is a 13s charger for my ebike. It would never fit in here but I can work out ideas at 3s then scale up.