In order to be attractive in a very competitive market, hybrid electric buses and full electric buses need to reduce the total cost of ownership (TCO) compared to conventional buses. In this regard, the sizing of the onboard energy storage and the charging infrastructure becomes a key design stage. An optimal onboard storage and charging facilities are necessary to offer an appropriate vehicle autonomy, but they involve high investment costs for the manufacturer and fleet operator. Furthermore, the complex interrelations between these parameters make the best-performed system design a challenging process. To face this issue, the paper proposes an optimization methodology for the onboard storage capacity sizing, charging points rate and charging points location, aiming a total cost of ownership improvement for hybrid and full electric bus routes. As case study, several routes have been selected in the city of Donostia (Spain) to techno-economically evaluate the proposed methodology regarding factors such as: onboard storage cost, charging infrastructure cost, fuel cost, and electricity-grid cost.