In recent years, with the globe facing a significant sustainability challenge due to emissions from various transport systems, numerous transit agencies throughout the world have begun to replace their conventional fleet with electric. Transitioning from diesel to electric buses is a complex process that necessitates extensive planning to ensure a smooth transition. To reduce initial financial costs, it is necessary to select the best battery size and number of chargers with their optimal location. So that any infeasibility of operation owing to electric buses' range, charger availability, and total fleet constraint can be eliminated. So, this paper addresses the facility location problem for charging stations and optimize the battery size while considering the diesel bus schedule as input to solve the problem. The suggested framework combines current diesel schedules, such as trip arrival time, departure time, distance travelled, layover periods, and potential charging location, to develop an optimization model that finds the best location to installed charging stations and the right battery size for replacing the diesel buses with electric buses. By aligning electric bus requirements with charging stations and battery size, the model ensures the feasibility of the operation and minimizes the cost of battery procurement and charging station installation. To test the effectiveness of the developed methodology, a realistic network from Bangalore is selected and tested. By implementing this, transit agencies can optimize the bus charging schedule, battery size, charging location and number of chargers.