Architecture, spatial metabolism and stress response of bacterial biofilms