Worldwide urbanization calls for a deeper understanding of epidemic spreading within urban environments. Here, we tackle this problem through an agent-based model, in which agents move in a two-dimensional physical space and interact according to proximity criteria. The planar space comprises several locations, which represent bounded regions of the urban space. Based on empirical evidence, we consider locations of different density and place them in a core-periphery structure, with higher density in the central areas and lower density in the peripheral ones. Each agent is assigned to a base location, which represents where their home is. Through analytical tools and numerical techniques, we study the formation mechanism of the network of contacts, which is characterized by the emergence of heterogeneous interaction patterns. We put forward an extensive simulation campaign to analyze the onset and evolution of contagious diseases spreading in the urban environment. Interestingly, we find that, in the presence of a core-periphery structure, the diffusion of the disease is not affected by the time agents spend inside their base location before leaving it, but it is influenced by their motion outside their base location: a strong tendency to return to the base location favors the spreading of the disease. A simplified one-dimensional version of the model is examined to gain analytical insight into the spreading process and support our numerical findings. Finally, we investigate the effectiveness of vaccination campaigns, supporting the intuition that vaccination in central and dense areas should be prioritized.