The emerging customized bus system based on modular autonomous electric vehicles (MAEVs) shows tremendous potential to improve the mobility, accessibility and environmental friendliness of a public transport system. However, the existing studies in this area almost focus on human-driven vehicles which face some striking limitations (e.g., restricted crew scheduling and fixed vehicle capacity) and can weaken the overall benefits. This paper proposes a two-phase optimization procedure to fully unleash the potential of MAEVs by leveraging the strengths of MAEVs, including automatic allocation and charging of modules. In the first phase, a mixed integer programming model is established in the space-time-state framework to jointly optimize the MAEV routing and charging, passenger-to-vehicle assignment and vehicle capacity management for reserved passengers. A Lagrangian relaxation algorithm is developed to solve the model efficiently. In the second phase, three dispatching strategies are designed and optimized by a dynamic dispatching procedure to properly adapt the operation of MAEVs to emerging travel demands. A case study conducted on a major urban area of Beijing, China, demonstrates the high efficiency of the MAEV adoption in terms of resource utilization and environmental friendliness across a range of travel demand distributions, vehicle supply and module capacity scenarios.