A framework for efficient wastewater treatment and recycling systems