Endosymbiosis as a compact ecosystem with material cycling: parasitism or mutualism?