In this paper, we provide a decentralized theoretical framework for coordination of connected and automated vehicles (CAVs) in different traffic scenarios. The framework includes: (1) an upper-level optimization that yields for each CAV its optimal path, including the time, 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) to achieve the optimal path and time derived in the upper-level. We provide a complete, analytical solution of the low-level optimization problem that includes the rear-end safety constraint, where the safe distance is a function of speed, in addition to the state and control constraints. Furthermore, we provide a geometric duality framework using hyperplanes to prove strong duality of the upper-level optimization problem. The latter implies that the optimal path and time for each CAV does not activate any of the state, control, and safety constraints of the low-level optimization, thus allowing for online implementation. We validate the effectiveness of the proposed theoretical framework through simulation.