This study presents a real-time optimization-based strategy for sustainable energy management using an energy hub that integrates combined heat and power (CHP) units, heat pumps, and fuel-cell technology to meet community electricity, heating, and cooling demands. It incorporates renewable-based R2 stations that leverage photovoltaic and wind power, integrated with hydrogen production and storage, to supply stationary energy consumers and the transportation sector. The system provides hydrogen for fuel cell electric vehicles (FCEVs) and electricity for electric vehicles (EVs). Integrating the R2 station with the primary energy hub optimizes the use of locally generated power, reducing dependence on external sources. Hydrogen fuel is produced on-site and off-site, focusing on solving the capacitated routing problem for efficient delivery. The system's architecture is modeled using a mixed-integer linear programming (MILP) approach. According to the results, no energy is drawn from the grid to meet the end-user's electricity demand.