This study focuses on developing a mathematical model for a hybrid energy system in a building that primarily relies on the grid with a small auxiliary solar setup. Real power consumption data will be used to design and analyse a hybrid configuration combining solar generation, grid power, and an optional battery storage unit. The model integrates mathematical methods from existing research to enhance energy utilization and reliability while reducing grid dependency. A comparative techno-economic analysis between the proposed hybrid model and the current grid–solar system will be carried out using parameters such as Levelized Cost of Energy (LCOE), Net Present Cost (NPC), and CO₂ reduction. The study aims to identify an optimal and economically feasible system that minimizes electricity bills and supports sustainable energy usage. The proposed framework can be applied to similar urban-scale systems for improved energy efficiency and cost savings.