In this paper, we provide a decentralized theoretical framework for coordination of connected and automated vehicles (CAVs) at different traffic scenarios. The framework includes: (1) an upper-level optimization that yields for each CAV its optimal time trajectory and lane to pass through a given traffic scenario while alleviating congestion; and (2) a low-level optimization that yields for each CAV its optimal control input (acceleration/deceleration). We provide a complete, analytical solution of the low-level optimization problem that includes the rear-end, speed-dependent safety constraint. Furthermore, we provide a problem formulation for the upper-level optimization in which there is no duality gap. The latter implies that the optimal time trajectory for each CAV does not activate any of the state, control, and safety constraints of the low-level optimization, thus allowing for online implementation. Finally, we present a geometric duality framework with hyperplanes to derive the condition under which the optimal solution of the upper-level optimization always exists. We validate the effectiveness of the proposed theoretical framework through simulation.