added some endpoints + minor refactoring
Now write the db to the storage folder