The present article proposes a novel smart building energy system utilizing deep geothermal resources through naturally-driven borehole thermal energy storage interacting with the district heating network. It includes an intelligent control strategy for lowering operational costs, making better use of renewables, and avoiding CO2 emissions by eliminating heat pumps and cooling machines to address the heating and cooling demands of a commercial building in Uppsala, a city near Stockholm, Sweden. After comprehensively conducting techno-environmental and economic assessments, the system is fine-tuned using artificial neural networks (ANN) for optimization. The study aims to determine which ANN design and training procedure is the most efficient in terms of accuracy and computing speed. It also assesses well-known optimization algorithms using the TOPSIS decision-making technique to find the best trade-off among various indicators. According to the parametric results, deeper boreholes can collect more geothermal energy and reduce CO2 emissions. However, deep drilling becomes more expensive overall, suggesting the need for multi-objective optimization to balance costs and techno-environmental benefits. The results indicate that Levenberg-Marquardt algorithms offer the optimum trade-off between computation time and error minimization. From a TOPSIS perspective, while the dragonfly algorithm is not ideal for optimizing the suggested system, the non-dominated sorting genetic algorithm is the most efficient since it yields more ideal points rated below 100. The optimization yields a higher energy production of 120 kWh/m2, as well as a decreased levelized cost of energy of 57 $/MWh, a shorter payback period of two years, and a reduced CO2 index of 1.90 kg/MWh. The analysis reveals that despite the high investment costs of 382.50 USD/m2, the system is financially beneficial in the long run due to a short payback period of around eight years, which aligns with the goals of future smart energy systems: reduce pollution and increase cost-effectiveness.