Facing the transition of the current fossil-based energy system towards a more sustainable one, new challenges and opportunities arise. The future energy system will be more electrified, de-carbonised, digitalised and decentralised, a sustainable environment where the concepts of renewable energy communities (REC) and energy sharing could play an important role. By aggregating the right actors in a community, it could be possible to integrate renewable energy sources (RES) more optimally into the system. Combination of RES with conventional energy conversion technologies, energy storage systems and electric vehicles allows the coupling of different energy networks toward providing electricity, heating, cooling, mobility, and flexibility services. However, combining all these technical aspects in one community results in a highly complex system. The complexity is not only technical, but also includes economic, environmental, and legal aspects. Therefore, there is a need for energy models to optimally design and plan the operation of such complex multi-energy systems (MES) considering both environmental and socio-economic objectives. The present work focuses on the development of an optimisation framework capable of bringing added values toward energy-efficient MES. It includes technology and topology selection, sizing, siting, connection infrastructures, and scheduling operations. The general goal will be searching for the best combination of technologies and operational strategies to provide energy in a reliable, affordable, and sustainable way for different socio-economic situations. Starting from the state-of-the-art, mixed-integer linear programming optimisation techniques besides a combination of modelling methodologies will be examined to find the optimal solutions for the understudying problem types. Data provided from demonstration sites around the World will be used to assess the model and to further develop MES, while considering regulatory decisions, electricity tariffs, and profitability aspects.Throughout the thesis, it became clear that increasing local renewable energy production consistently reduces energy costs and greenhouse gas emissions. Electrification of heating and transportation also proved effective in reducing energy consumption and emissions, but the choice of technology depends on local conditions and electricity tariffs. RECs and energy sharing among consumers can reduce costs and promote renewable energy adoption. However, challenges such as regulatory barriers and infrastructure costs become one of the most important hurdles, which are also discussed in this thesis. Coupling different energy sectors, such as electricity, heat, and mobility, offers benefits in terms of energy efficiency and emissions reduction, but also poses technical and regulatory challenges. The introduction of capacity and variable electricity tariffs can influence renewable energy investments and electrification strategies, with outcomes depending on tariff design and regional conditions. In conclusion, this research provides valuable insights into sustainable energy systems and the challenges and opportunities they present. Continued use of optimisation models and data-driven approaches is essential for achieving cost-effective and resilient energy systems as we navigate the complex journey of the energy transition towards a greener future.