how to read and write to the DB, and how to generate ToJSON instances that can be sent as responses