Switch to using a database and expose an api