Smart cities are proposed as a medium-term option for all cities. This article aims to propose an architecture that allows cities to provide solutions to interconnect all their elements. The study case focuses in locating and optimized regulation of traffic in cities. However, thanks to the proposed structure and the applied algorithms, the architecture is scalable in size of the sensor network, in functionality or even in the use of resources. A simulation environment which is able to show the operation of the architecture in the same way that a real city would, is presented.