save state in db and use to construct UI