Galaxy ecosystems: gas contents, inflows and outflows