How feedback shapes galaxies: an analytic model