## 1 Introduction  
Nowadays, planet earth is dealing with two significant issues: energy and water crises. According to [1], between 2015 and 2040, the global energy consumption is expected to rise by 28%, while the global use of petroleum-based fossil fuels would rise from 190 to 230 quadrillion British thermal unit. Additionally, excessive fossil fuel use not only depletes natural resources but causes continual increases in the carbon dioxide emissions, which contributes toward global warming [2]. Biodiesel from microalgae has been proposed as an alternative renewable fuel source [3], but the cost of production (160-480 USD BBL\({}^{-1}\)) is more than the cost of crude oil and over 50% of the overall price is often attributed to the price of freshwater, fertilizers and the harvesting procedure [4]. Freshwater represents only 0.5% of the global water on planet earth, and its consumption increases with the increasing population and industrial activity, which generate 380 trillion L y\({}^{-1}\) of wastewater in the world [5]. In addition, by 2050, more than 50% of the planet's population is projected to face chronic water shortages, hence the need for wastewater recycling [6]. As reported in this review, domestic, agricultural and industrial wastewaters contain significant concentrations of nutrients, including phosphorus, carbon and nitrogen, which are required for the growth of microalgae. Microalgae-based biorefineries for biofuels and wastewaters treatment have received a lot of interest to tackle the energy and water scarcity [1; 5; 7]. Consequently, researchers have frequently used wastewater from different sources for microalgae cultivation, in order to determine the potential of microalgae for simultaneous wastewater treatment. Recently, _Chlorella pyrenoidosa_ (No. FACHB-863) was employed for its wastewater treatment ability to eliminate contaminants from synthetic tobacco wastewater [8]. The study's findings demonstrated that _Chlorella pyrenoidosa_ may grow in this kind of effluent, with a maximum biomass of 540.24 mg L\({}^{-1}\). _Arthospira_ has been cultivated in seawater with the addition of anaerobic animal waste effluent to produce biofuels (biogas, biodiesel and biohydrogen) and high added value materials [7]. Although it has been widely studied in previous research, the use of wastewater for a biorefinery system at a low cost is rare on an industrial scale, because this cultivation method still has challenges that limit its application; however, several pieces of research are now underway for its implementation in the future. In order to identify prospective directions for future research on microalgae-based bioremediation, this review intends to highlight the advances and existing work concerning the use of microalgae in wastewater treatment for a biorefinery system. Following these guidelines, the available literature was assessed to accomplish the purpose of this review:  
1. Wastewater treatment by microalgae: In this section we present the physicochemical properties of domestic wastewater that have been used in domestic wastewater treatment by microalgae, followed by the pretreatment of domestic wastewater before microalgae cultivation, as well as pollutant removals such as chemical oxygen demand (COD), total nitrate (TN) and total phosphate (TP) removals, biomass generation and the productivity of biomolecules after microalgae cultivation, using different species that have been tested in the literature. The same parameters have been explored for both agricultural wastewater and industrial wastewater. 2. Microalgal mechanisms for wastewater bioremediation: As the biodegradation response of microalgae to contaminants varies from one pollutant to another, we focus on the following mechanisms in this section: CO\({}_{2}\) fixation, nitrogen sources assimilation, phosphate sources assimilation and heavy metals biodegradation mechanisms. 3.