As practiced in Africa, urban agriculture (UA) has been examined in the literature and by architecture and urban planning experts, revealing both advantages and disadvantages for health. While the recognized disadvantages are not negligible, the literature focuses mainly on the positive outcomes about food security and improved socio-economic conditions for farmers. However, little research has focused on farmers' perceptions of the effect of this practice on their psychological well-being. This study seeks to delve into this aspect by surveying 733 farmers in Dar es Salaam and Greater Lomé to map UA's distribution, assess its benefits and challenges, study its psychosocial associations, and demonstrate how architectural design and urban planning can enhance its spatial distribution and overall benefits. The standardized Mental Health Continuum-Short Form (MHC-SF) and non-standardized questionnaires are used to evaluate their responses. Using logistic regression and spatial analysis techniques with Python and QGIS 3.32.2-Lima, the analysis uncovers that farmers attribute improved psychological well-being to their involvement in UA. The study found that farmers' happiness due to UA varies by location within a city, with those on the outskirts generally more satisfied than those in urban centers. Additionally, women farmers reported greater happiness than men farmers, highlighting UA's role in empowering women. The research underscores UA's positive association with practitioners' psychological health in Africa and advocates for its integration into urban planning to promote equitable and beneficial urban spaces.