Background: Wastewater is considered as a renewable resource water and energy. An advantage of decentralized sanitation systems is the separation of the blackwater (BW) stream, which is highly contaminated with human pathogens, from the remaining household water. However, the composition and functions of the microbial community in BW are not known. In this study, we used shotgun metagenomics to assess the dynamics of microbial community structure and function throughout a new BW anaerobic digestion system installed at The Netherlands Institute of Ecology. Samples from the influent (BW), primary effluent (anaerobic digested BW), sludge and final effluent of the pilot upflow anaerobic sludge blanket (UASB) reactor and microalgae pilot tubular photobioreactor (PBR) were analyzed.Results: Our results showed a decrease in microbial richness and diversity followed by a decrease in functional complexity and co-occurrence along the different modules of the bioreactor. The microbial diversity and function decrease were reflected both changes in substrate composition and wash conditions. The most prevalent core functions in influent (BW) were related to metabolism of carbohydrates, response to chemicals and drugs, and nitrogen. The core functions in anaerobic digested BW and upflow anaerobic sludge blanket reactor were related to response to stress, viral processes and iron-sulfur metabolism. Methanogenesis-related functions were most abundant in upflow anaerobic sludge blanket reactor. Effluent from tubular photobioreactor presented high abundances of functions related to nitrogen utilization, metal ion binding and antibiotic biosynthetic processes. Interestingly, the abundance of sequences related to ‘pathogenesis’ decreased from influent BW to SP1 to effluent from tubular photobioreactor. Our wastewater treatment system also decreased potential microbial functions related to pathogenesis. Conclusions: The new sanitation system studied here fosters microbial groups and functions that allow the system to efficiently and robustly recover carbon and nutrients while reducing pathogenic groups, ultimately generating a final effluent safe for discharge and reuse.