Biogas is a promising renewable and distributed source of energy derived from the anaerobic treatment of organic residues. Different production routes using biogas have been proposed in the literature, such as power and heat cogeneration, biomethane or hydrogen production. However, few studies have evaluated the technical, economic and environmental performance of these production routes in the Brazilian context. In addition, although biogas can provide substantial benefits for the environment, its application may be restricted to large industrial facilities due to the lack of efficient conversion systems at small facilities. An interesting technology alternative for biogas conversion is the use of high temperature fuel cells, such as solid oxide fuel cells (SOFC), due to their high efficiency and modularity. However, the influence of operational parameters in the optimization of revenues, efficiency and environmental impact has been seldom studied for these novel polygeneration systems. Thus, this thesis aims to develop a systematic framework to design, evaluate and optimize biogas production and conversion systems, with a modern approach to modelling and optimization. The research discuss and compare the technical, economic and environmental performance of different biogas conversion routes (electricity, methane and hydrogen) based on the principles of exergoeconomic analysis.Next, different designs for fuel cell systems working with biogas to produce electricity and hydrogen optimized for exergy efficiency and net present value or electricity costs.The results indicate that hydrogen production using biogas is the most profitable production route and its efficiency/economic return can be improved by integrating this process with fuel cells. Moreover, the distributed generation of electricity using fuel cells requires further reductions in equipment costs to be economically viable at competitive interest return ratios.